-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Travis CI with Github Actions
... and replace mocha+istanbul with built-in "node:test" module and rely on the --experimental-test-coverage option. Although not used anywhere, include an example with genhtml (part of GCC's lcov package) in case someone is interested in locally viewing the coverage data in HTML format.
- Loading branch information
Showing
6 changed files
with
105 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
on: [ push, pull_request ] | ||
|
||
name: Tests | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
- run: npm install # install eslint | ||
- run: npm run lint | ||
|
||
test-old-node: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node_version: [ 6.4.0 ] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Use Node.js ${{ matrix.node_version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node_version }} | ||
cache: npm | ||
|
||
# Note: no npm ci / npm install: | ||
# The package has no non-dev dependencies. | ||
# Old Node.js does not have built-in coverage reporting, so we use packages from before. | ||
# - run: npm install [email protected] # TODO: can be removed? Not needed with github action? | ||
- run: npm install [email protected] | ||
- run: npm install [email protected] | ||
|
||
# test-coverage will also run the tests, but does not print helpful output upon test failure. | ||
# So we also run the tests separately. | ||
- run: ./node_modules/.bin/mocha ./test.js --reporter spec | ||
# ^ instead of: npm test | ||
|
||
- run: ./node_modules/.bin/istanbul cover ./node_modules/.bin/mocha -- --reporter spec # creates coverage/lcov.info | ||
# ^ instead of: npm run test-coverage | ||
|
||
- name: Send coverage for Node ${{ matrix.node_version }} to Coveralls | ||
uses: coverallsapp/github-action@v2 | ||
with: | ||
parallel: true | ||
file: coverage/lcov.info | ||
flag-name: coverage-node-${{ matrix.node_version }} | ||
|
||
test-recent-node: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node_version: [ 18, 20 ] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Use Node.js ${{ matrix.node_version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node_version }} | ||
cache: npm | ||
|
||
# Note: no npm ci / npm install: | ||
# The package has no non-dev dependencies. | ||
# We rely on Node.js's built-in test module and reporter, | ||
# and do not require any dev dependencies either. | ||
|
||
# test-coverage will also run the tests, but does not print helpful output upon test failure. | ||
# So we also run the tests separately. | ||
- run: npm test | ||
|
||
# note: --experimental-test-coverage requires Node v18.15.0+ | ||
- run: npm run test-coverage | ||
|
||
- name: Send coverage for Node ${{ matrix.node_version }} to Coveralls | ||
uses: coverallsapp/github-action@v2 | ||
with: | ||
parallel: true | ||
file: lcov.info | ||
flag-name: coverage-node-${{ matrix.node_version }} | ||
|
||
coveralls: | ||
needs: [ test-old-node, test-recent-node ] | ||
if: ${{ always() }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Report to Coveralls | ||
uses: coverallsapp/github-action@v2 | ||
with: | ||
parallel-finished: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.swp | ||
coverage/ | ||
lcov.info | ||
node_modules/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters