|
| 1 | +name: legacy |
| 2 | + |
| 3 | +on: |
| 4 | +- pull_request |
| 5 | +- push |
| 6 | + |
| 7 | +jobs: |
| 8 | + test: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + strategy: |
| 11 | + fail-fast: false |
| 12 | + matrix: |
| 13 | + name: |
| 14 | + - Node.js 11.x |
| 15 | + - Node.js 12.x |
| 16 | + - Node.js 13.x |
| 17 | + - Node.js 14.x |
| 18 | + - Node.js 15.x |
| 19 | + - Node.js 16.x |
| 20 | + - Node.js 17.x |
| 21 | + |
| 22 | + include: |
| 23 | + - name: Node.js 11.x |
| 24 | + node-version: "11.15" |
| 25 | + |
| 26 | + |
| 27 | + - name: Node.js 12.x |
| 28 | + node-version: "12.22" |
| 29 | + |
| 30 | + |
| 31 | + - name: Node.js 13.x |
| 32 | + node-version: "13.14" |
| 33 | + |
| 34 | + |
| 35 | + - name: Node.js 14.x |
| 36 | + node-version: "14.20" |
| 37 | + |
| 38 | + - name: Node.js 15.x |
| 39 | + node-version: "15.14" |
| 40 | + |
| 41 | + - name: Node.js 16.x |
| 42 | + node-version: "16.20" |
| 43 | + |
| 44 | + - name: Node.js 17.x |
| 45 | + node-version: "17.9" |
| 46 | + |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + |
| 50 | + - name: Install Node.js ${{ matrix.node-version }} |
| 51 | + shell: bash -eo pipefail -l {0} |
| 52 | + run: | |
| 53 | + nvm install --default ${{ matrix.node-version }} |
| 54 | + dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH" |
| 55 | +
|
| 56 | + - name: Configure npm |
| 57 | + run: | |
| 58 | + npm config set loglevel error |
| 59 | + if [[ "$(npm config get package-lock)" == "true" ]]; then |
| 60 | + npm config set package-lock false |
| 61 | + else |
| 62 | + npm config set shrinkwrap false |
| 63 | + fi |
| 64 | +
|
| 65 | + - name: Install npm module(s) ${{ matrix.npm-i }} |
| 66 | + run: npm install --save-dev ${{ matrix.npm-i }} |
| 67 | + if: matrix.npm-i != '' |
| 68 | + |
| 69 | + - name: Remove non-test dependencies |
| 70 | + run: npm rm --silent --save-dev connect-redis |
| 71 | + |
| 72 | + - name: Setup Node.js version-specific dependencies |
| 73 | + shell: bash |
| 74 | + run: | |
| 75 | + # eslint for linting |
| 76 | + # - remove on Node.js < 12 |
| 77 | + if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 12 ]]; then |
| 78 | + node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \ |
| 79 | + grep -E '^eslint(-|$)' | \ |
| 80 | + sort -r | \ |
| 81 | + xargs -n1 npm rm --silent --save-dev |
| 82 | + fi |
| 83 | +
|
| 84 | + - name: Install Node.js dependencies |
| 85 | + run: npm install |
| 86 | + |
| 87 | + - name: List environment |
| 88 | + id: list_env |
| 89 | + shell: bash |
| 90 | + run: | |
| 91 | + echo "node@$(node -v)" |
| 92 | + echo "npm@$(npm -v)" |
| 93 | + npm -s ls ||: |
| 94 | + (npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT" |
| 95 | +
|
| 96 | + - name: Run tests |
| 97 | + shell: bash |
| 98 | + run: | |
| 99 | + npm run test-ci |
| 100 | + cp coverage/lcov.info "coverage/${{ matrix.name }}.lcov" |
| 101 | +
|
| 102 | + - name: Lint code |
| 103 | + if: steps.list_env.outputs.eslint != '' |
| 104 | + run: npm run lint |
| 105 | + |
| 106 | + - name: Collect code coverage |
| 107 | + run: | |
| 108 | + mv ./coverage "./${{ matrix.name }}" |
| 109 | + mkdir ./coverage |
| 110 | + mv "./${{ matrix.name }}" "./coverage/${{ matrix.name }}" |
| 111 | +
|
| 112 | + - name: Upload code coverage |
| 113 | + uses: actions/upload-artifact@v3 |
| 114 | + with: |
| 115 | + name: coverage |
| 116 | + path: ./coverage |
| 117 | + retention-days: 1 |
| 118 | + |
| 119 | + coverage: |
| 120 | + needs: test |
| 121 | + runs-on: ubuntu-latest |
| 122 | + steps: |
| 123 | + - uses: actions/checkout@v4 |
| 124 | + |
| 125 | + - name: Install lcov |
| 126 | + shell: bash |
| 127 | + run: sudo apt-get -y install lcov |
| 128 | + |
| 129 | + - name: Collect coverage reports |
| 130 | + uses: actions/download-artifact@v3 |
| 131 | + with: |
| 132 | + name: coverage |
| 133 | + path: ./coverage |
| 134 | + |
| 135 | + - name: Merge coverage reports |
| 136 | + shell: bash |
| 137 | + run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./coverage/lcov.info |
| 138 | + |
| 139 | + - name: Upload coverage report |
| 140 | + uses: coverallsapp/github-action@master |
| 141 | + with: |
| 142 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments