|
| 1 | +name: ci |
| 2 | + |
| 3 | +on: |
| 4 | +- pull_request |
| 5 | +- push |
| 6 | + |
| 7 | +jobs: |
| 8 | + test: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + strategy: |
| 11 | + matrix: |
| 12 | + name: |
| 13 | + - Node.js 0.6 |
| 14 | + - Node.js 0.8 |
| 15 | + - Node.js 0.10 |
| 16 | + - Node.js 0.12 |
| 17 | + - io.js 1.x |
| 18 | + - io.js 2.x |
| 19 | + - io.js 3.x |
| 20 | + - Node.js 4.x |
| 21 | + - Node.js 5.x |
| 22 | + - Node.js 6.x |
| 23 | + - Node.js 7.x |
| 24 | + - Node.js 8.x |
| 25 | + - Node.js 9.x |
| 26 | + - Node.js 10.x |
| 27 | + - Node.js 11.x |
| 28 | + - Node.js 12.x |
| 29 | + - Node.js 13.x |
| 30 | + - Node.js 14.x |
| 31 | + - Node.js 15.x |
| 32 | + |
| 33 | + include: |
| 34 | + - name: Node.js 0.6 |
| 35 | + node-version: "0.6" |
| 36 | + |
| 37 | + npm-rm: nyc |
| 38 | + |
| 39 | + - name: Node.js 0.8 |
| 40 | + node-version: "0.8" |
| 41 | + |
| 42 | + npm-rm: nyc |
| 43 | + |
| 44 | + - name: Node.js 0.10 |
| 45 | + node-version: "0.10" |
| 46 | + |
| 47 | + npm-rm: nyc |
| 48 | + |
| 49 | + - name: Node.js 0.12 |
| 50 | + node-version: "0.12" |
| 51 | + |
| 52 | + npm-rm: nyc |
| 53 | + |
| 54 | + - name: io.js 1.x |
| 55 | + node-version: "1.8" |
| 56 | + |
| 57 | + npm-rm: nyc |
| 58 | + |
| 59 | + - name: io.js 2.x |
| 60 | + node-version: "2.5" |
| 61 | + |
| 62 | + npm-rm: nyc |
| 63 | + |
| 64 | + - name: io.js 3.x |
| 65 | + node-version: "3.3" |
| 66 | + |
| 67 | + npm-rm: nyc |
| 68 | + |
| 69 | + - name: Node.js 4.x |
| 70 | + node-version: "4.9" |
| 71 | + |
| 72 | + npm-rm: nyc |
| 73 | + |
| 74 | + - name: Node.js 5.x |
| 75 | + node-version: "5.12" |
| 76 | + |
| 77 | + npm-rm: nyc |
| 78 | + |
| 79 | + - name: Node.js 6.x |
| 80 | + node-version: "6.17" |
| 81 | + |
| 82 | + npm-rm: nyc |
| 83 | + |
| 84 | + - name: Node.js 7.x |
| 85 | + node-version: "7.10" |
| 86 | + |
| 87 | + npm-rm: nyc |
| 88 | + |
| 89 | + - name: Node.js 8.x |
| 90 | + node-version: "8.17" |
| 91 | + |
| 92 | + |
| 93 | + - name: Node.js 9.x |
| 94 | + node-version: "9.11" |
| 95 | + |
| 96 | + |
| 97 | + - name: Node.js 10.x |
| 98 | + node-version: "10.23" |
| 99 | + |
| 100 | + - name: Node.js 11.x |
| 101 | + node-version: "11.15" |
| 102 | + |
| 103 | + - name: Node.js 12.x |
| 104 | + node-version: "12.20" |
| 105 | + |
| 106 | + - name: Node.js 13.x |
| 107 | + node-version: "13.14" |
| 108 | + |
| 109 | + - name: Node.js 14.x |
| 110 | + node-version: "14.15" |
| 111 | + |
| 112 | + - name: Node.js 15.x |
| 113 | + node-version: "15.4" |
| 114 | + |
| 115 | + steps: |
| 116 | + - uses: actions/checkout@v2 |
| 117 | + |
| 118 | + - name: Install Node.js ${{ matrix.node-version }} |
| 119 | + shell: bash -l {0} |
| 120 | + run: | |
| 121 | + nvm install --default ${{ matrix.node-version }} |
| 122 | + if [[ "${{ matrix.node-version }}" == 0.* ]]; then |
| 123 | + npm config set strict-ssl false |
| 124 | + fi |
| 125 | + dirname "$(npm which)" >> "$GITHUB_PATH" |
| 126 | +
|
| 127 | + - name: Configure npm |
| 128 | + run: npm config set shrinkwrap false |
| 129 | + |
| 130 | + - name: Remove non-test npm modules |
| 131 | + run: npm rm --silent --save-dev bluebird co cogent csv-parse gnode raw-body stream-to-array |
| 132 | + |
| 133 | + - name: Remove npm module(s) ${{ matrix.npm-rm }} |
| 134 | + run: npm rm --silent --save-dev ${{ matrix.npm-rm }} |
| 135 | + if: matrix.npm-rm != '' |
| 136 | + |
| 137 | + - name: Install npm module(s) ${{ matrix.npm-i }} |
| 138 | + run: npm install --save-dev ${{ matrix.npm-i }} |
| 139 | + if: matrix.npm-i != '' |
| 140 | + |
| 141 | + - name: Setup Node.js version-specific dependencies |
| 142 | + shell: bash |
| 143 | + run: | |
| 144 | + # eslint for linting |
| 145 | + # - remove on Node.js < 10 |
| 146 | + if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 8 ]]; then |
| 147 | + node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \ |
| 148 | + grep -E '^eslint(-|$)' | \ |
| 149 | + sort -r | \ |
| 150 | + xargs -n1 npm rm --silent --save-dev |
| 151 | + fi |
| 152 | +
|
| 153 | + - name: Install Node.js dependencies |
| 154 | + run: npm install |
| 155 | + |
| 156 | + - name: List environment |
| 157 | + id: list_env |
| 158 | + shell: bash |
| 159 | + run: | |
| 160 | + echo "node@$(node -v)" |
| 161 | + echo "npm@$(npm -v)" |
| 162 | + npm -s ls |
| 163 | + npm -s ls --depth=0 | awk -F'[ @]' 'NR>1 && $2 { print "::set-output name=" $2 "::" $3 }' |
| 164 | +
|
| 165 | + - name: Run tests |
| 166 | + shell: bash |
| 167 | + run: | |
| 168 | + if npm -ps ls nyc | grep -q nyc; then |
| 169 | + npm run test-ci |
| 170 | + else |
| 171 | + npm test |
| 172 | + fi |
| 173 | +
|
| 174 | + - name: Lint code |
| 175 | + if: steps.list_env.outputs.eslint != '' |
| 176 | + run: npm run lint |
| 177 | + |
| 178 | + - name: Collect code coverage |
| 179 | + uses: coverallsapp/github-action@master |
| 180 | + if: steps.list_env.outputs.nyc != '' |
| 181 | + with: |
| 182 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 183 | + flag-name: run-${{ matrix.test_number }} |
| 184 | + parallel: true |
| 185 | + |
| 186 | + coverage: |
| 187 | + needs: test |
| 188 | + runs-on: ubuntu-latest |
| 189 | + steps: |
| 190 | + - name: Uploade code coverage |
| 191 | + uses: coverallsapp/github-action@master |
| 192 | + with: |
| 193 | + github-token: ${{ secrets.github_token }} |
| 194 | + parallel-finished: true |
0 commit comments