|
| 1 | +on: [ push, pull_request ] |
| 2 | + |
| 3 | +name: Tests |
| 4 | + |
| 5 | +jobs: |
| 6 | + lint: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + steps: |
| 9 | + - uses: actions/checkout@v4 |
| 10 | + - uses: actions/setup-node@v4 |
| 11 | + - run: npm install # install eslint |
| 12 | + - run: npm run lint |
| 13 | + |
| 14 | + test-old-node: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + node_version: [ 6.4.0 ] |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Use Node.js ${{ matrix.node_version }} |
| 23 | + uses: actions/setup-node@v4 |
| 24 | + with: |
| 25 | + node-version: ${{ matrix.node_version }} |
| 26 | + cache: npm |
| 27 | + |
| 28 | + # Note: no npm ci / npm install: |
| 29 | + # The package has no non-dev dependencies. |
| 30 | + # Old Node.js does not have built-in coverage reporting, so we use packages from before. |
| 31 | + # - run: npm install [email protected] # TODO: can be removed? Not needed with github action? |
| 32 | + - run: npm install [email protected] |
| 33 | + - run: npm install [email protected] |
| 34 | + |
| 35 | + # test-coverage will also run the tests, but does not print helpful output upon test failure. |
| 36 | + # So we also run the tests separately. |
| 37 | + - run: ./node_modules/.bin/mocha ./test.js --reporter spec |
| 38 | + # ^ instead of: npm test |
| 39 | + |
| 40 | + - run: ./node_modules/.bin/istanbul cover ./node_modules/.bin/mocha -- --reporter spec # creates coverage/lcov.info |
| 41 | + # ^ instead of: npm run test-coverage |
| 42 | + |
| 43 | + - name: Send coverage for Node ${{ matrix.node_version }} to Coveralls |
| 44 | + uses: coverallsapp/github-action@v2 |
| 45 | + with: |
| 46 | + parallel: true |
| 47 | + file: coverage/lcov.info |
| 48 | + flag-name: coverage-node-${{ matrix.node_version }} |
| 49 | + |
| 50 | + test-recent-node: |
| 51 | + name: Build |
| 52 | + runs-on: ubuntu-latest |
| 53 | + strategy: |
| 54 | + matrix: |
| 55 | + node_version: [ 18, 20 ] |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v4 |
| 58 | + |
| 59 | + - name: Use Node.js ${{ matrix.node_version }} |
| 60 | + uses: actions/setup-node@v4 |
| 61 | + with: |
| 62 | + node-version: ${{ matrix.node_version }} |
| 63 | + cache: npm |
| 64 | + |
| 65 | + # Note: no npm ci / npm install: |
| 66 | + # The package has no non-dev dependencies. |
| 67 | + # We rely on Node.js's built-in test module and reporter, |
| 68 | + # and do not require any dev dependencies either. |
| 69 | + |
| 70 | + # test-coverage will also run the tests, but does not print helpful output upon test failure. |
| 71 | + # So we also run the tests separately. |
| 72 | + - run: npm test |
| 73 | + |
| 74 | + # note: --experimental-test-coverage requires Node v18.15.0+ |
| 75 | + - run: npm run test-coverage |
| 76 | + |
| 77 | + - name: Send coverage for Node ${{ matrix.node_version }} to Coveralls |
| 78 | + uses: coverallsapp/github-action@v2 |
| 79 | + with: |
| 80 | + parallel: true |
| 81 | + file: lcov.info |
| 82 | + flag-name: coverage-node-${{ matrix.node_version }} |
| 83 | + |
| 84 | + coveralls: |
| 85 | + needs: [ test-old-node, test-recent-node ] |
| 86 | + if: ${{ always() }} |
| 87 | + runs-on: ubuntu-latest |
| 88 | + steps: |
| 89 | + - name: Report to Coveralls |
| 90 | + uses: coverallsapp/github-action@v2 |
| 91 | + with: |
| 92 | + parallel-finished: true |
0 commit comments