|
| 1 | +name: ci |
| 2 | + |
| 3 | +on: |
| 4 | +- pull_request |
| 5 | +- push |
| 6 | + |
| 7 | +jobs: |
| 8 | + test: |
| 9 | + runs-on: ubuntu-18.04 |
| 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 | + |
| 30 | + include: |
| 31 | + - name: Node.js 0.6 |
| 32 | + node-version: "0.6" |
| 33 | + |
| 34 | + npm-rm: nyc |
| 35 | + |
| 36 | + - name: Node.js 0.8 |
| 37 | + node-version: "0.8" |
| 38 | + |
| 39 | + npm-rm: nyc |
| 40 | + |
| 41 | + - name: Node.js 0.10 |
| 42 | + node-version: "0.10" |
| 43 | + |
| 44 | + |
| 45 | + - name: Node.js 0.12 |
| 46 | + node-version: "0.12" |
| 47 | + |
| 48 | + |
| 49 | + - name: io.js 1.x |
| 50 | + node-version: "1.8" |
| 51 | + |
| 52 | + |
| 53 | + - name: io.js 2.x |
| 54 | + node-version: "2.5" |
| 55 | + |
| 56 | + |
| 57 | + - name: io.js 3.x |
| 58 | + node-version: "3.3" |
| 59 | + |
| 60 | + |
| 61 | + - name: Node.js 4.x |
| 62 | + node-version: "4.9" |
| 63 | + |
| 64 | + |
| 65 | + - name: Node.js 5.x |
| 66 | + node-version: "5.12" |
| 67 | + |
| 68 | + |
| 69 | + - name: Node.js 6.x |
| 70 | + node-version: "6.17" |
| 71 | + |
| 72 | + - name: Node.js 7.x |
| 73 | + node-version: "7.10" |
| 74 | + |
| 75 | + - name: Node.js 8.x |
| 76 | + node-version: "8.16" |
| 77 | + |
| 78 | + - name: Node.js 9.x |
| 79 | + node-version: "9.11" |
| 80 | + |
| 81 | + - name: Node.js 10.x |
| 82 | + node-version: "10.15" |
| 83 | + |
| 84 | + - name: Node.js 11.x |
| 85 | + node-version: "11.15" |
| 86 | + |
| 87 | + - name: Node.js 12.x |
| 88 | + node-version: "12.2" |
| 89 | + |
| 90 | + steps: |
| 91 | + - uses: actions/checkout@v2 |
| 92 | + |
| 93 | + - name: Install Node.js ${{ matrix.node-version }} |
| 94 | + shell: bash -eo pipefail -l {0} |
| 95 | + run: | |
| 96 | + if [[ "${{ matrix.node-version }}" == 0.6* ]]; then |
| 97 | + sudo apt-get install g++-4.8 gcc-4.8 libssl1.0-dev |
| 98 | + export CC=/usr/bin/gcc-4.8 |
| 99 | + export CXX=/usr/bin/g++-4.8 |
| 100 | + fi |
| 101 | + nvm install --default ${{ matrix.node-version }} |
| 102 | + if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then |
| 103 | + nvm install --alias=npm 0.10 |
| 104 | + nvm use ${{ matrix.node-version }} |
| 105 | + if [[ "$(npm -v)" == 1.1.* ]]; then |
| 106 | + nvm exec npm npm install -g [email protected] |
| 107 | + ln -fs "$(which npm)" "$(dirname "$(nvm which npm)")/npm" |
| 108 | + else |
| 109 | + sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")" |
| 110 | + fi |
| 111 | + npm config set strict-ssl false |
| 112 | + fi |
| 113 | + dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH" |
| 114 | +
|
| 115 | + - name: Configure npm |
| 116 | + run: npm config set shrinkwrap false |
| 117 | + |
| 118 | + - name: Remove npm module(s) ${{ matrix.npm-rm }} |
| 119 | + run: npm rm --silent --save-dev ${{ matrix.npm-rm }} |
| 120 | + if: matrix.npm-rm != '' |
| 121 | + |
| 122 | + - name: Install npm module(s) ${{ matrix.npm-i }} |
| 123 | + run: npm install --save-dev ${{ matrix.npm-i }} |
| 124 | + if: matrix.npm-i != '' |
| 125 | + |
| 126 | + - name: Setup Node.js version-specific dependencies |
| 127 | + shell: bash |
| 128 | + run: | |
| 129 | + # eslint for linting |
| 130 | + # - remove on Node.js < 8 |
| 131 | + if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 8 ]]; then |
| 132 | + node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \ |
| 133 | + grep -E '^eslint(-|$)' | \ |
| 134 | + sort -r | \ |
| 135 | + xargs -n1 npm rm --silent --save-dev |
| 136 | + fi |
| 137 | +
|
| 138 | + - name: Install Node.js dependencies |
| 139 | + run: npm install |
| 140 | + |
| 141 | + - name: List environment |
| 142 | + id: list_env |
| 143 | + shell: bash |
| 144 | + run: | |
| 145 | + echo "node@$(node -v)" |
| 146 | + echo "npm@$(npm -v)" |
| 147 | + npm -s ls ||: |
| 148 | + (npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print "::set-output name=" $2 "::" $3 }' |
| 149 | +
|
| 150 | + - name: Run tests |
| 151 | + shell: bash |
| 152 | + run: | |
| 153 | + if npm -ps ls nyc | grep -q nyc; then |
| 154 | + npm run test-ci |
| 155 | + else |
| 156 | + npm test |
| 157 | + fi |
| 158 | +
|
| 159 | + - name: Lint code |
| 160 | + if: steps.list_env.outputs.eslint != '' |
| 161 | + run: npm run lint |
| 162 | + |
| 163 | + - name: Collect code coverage |
| 164 | + uses: coverallsapp/github-action@master |
| 165 | + if: steps.list_env.outputs.nyc != '' |
| 166 | + with: |
| 167 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 168 | + flag-name: run-${{ matrix.test_number }} |
| 169 | + parallel: true |
| 170 | + |
| 171 | + coverage: |
| 172 | + needs: test |
| 173 | + runs-on: ubuntu-latest |
| 174 | + steps: |
| 175 | + - name: Upload code coverage |
| 176 | + uses: coverallsapp/github-action@master |
| 177 | + with: |
| 178 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 179 | + parallel-finished: true |
0 commit comments