-
Notifications
You must be signed in to change notification settings - Fork 18
93 lines (78 loc) · 2.93 KB
/
run-tests.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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 }}
# 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 external packages.
# - run: npm install [email protected] # TODO: can be removed? Not needed with github action?
- run: npm install [email protected]
# 6.2.0 is supposedly compatible with v6, but fails to install.
# So we use a (working) version referenced by [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: [ 20 ]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
# 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+
# note: --test-reporter=lcov requires Node v20.11.0+ (https://github.com/nodejs/node/pull/50018)
- 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