Skip to content

Commit 086f5bb

Browse files
CI: run unit tests on multiple Nodejs versions (#220)
* CI: run unit tests on multiple Nodejs versions Signed-off-by: Levko Kravets <levko.ne@gmail.com> * Temporarily exclude Nodejs@14 Signed-off-by: Levko Kravets <levko.ne@gmail.com> * Collect reports for all Node versions separately Signed-off-by: Levko Kravets <levko.ne@gmail.com> --------- Signed-off-by: Levko Kravets <levko.ne@gmail.com>
1 parent a4e4aa7 commit 086f5bb

2 files changed

Lines changed: 32 additions & 21 deletions

File tree

.github/workflows/main.yml

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,39 @@ jobs:
3232
3333
unit-test:
3434
runs-on: ubuntu-latest
35+
strategy:
36+
matrix:
37+
# only LTS versions starting from the lowest we support
38+
# TODO: Include Nodejs@14
39+
node-version: ['16', '18', '20']
3540
env:
3641
cache-name: cache-node-modules
42+
NYC_REPORT_DIR: coverage_unit_node${{ matrix.node-version }}
3743

3844
steps:
45+
- uses: actions/setup-node@v4
46+
with:
47+
node-version: ${{ matrix.node-version }}
3948
- uses: actions/checkout@v3
4049
- name: Cache node modules
4150
uses: actions/cache@v3
4251
with:
4352
path: ~/.npm
44-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
53+
key: ${{ runner.os }}-${{ matrix.node-version }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
4554
restore-keys: |
46-
${{ runner.os }}-build-${{ env.cache-name }}-
47-
${{ runner.os }}-build-
48-
${{ runner.os }}-
55+
${{ runner.os }}-${{ matrix.node-version }}-build-${{ env.cache-name }}-
56+
${{ runner.os }}-${{ matrix.node-version }}-build-
57+
${{ runner.os }}-${{ matrix.node-version }}-
4958
- name: Run unit tests
5059
run: |
5160
npm ci
5261
npm run test
53-
- run: tar -cvf coverage_unit.tar coverage_unit
62+
- run: tar -cvf ${{ env.NYC_REPORT_DIR }}.tar ${{ env.NYC_REPORT_DIR }}
5463
- name: Store coverage report
55-
uses: actions/upload-artifact@v3
64+
uses: actions/upload-artifact@v4
5665
with:
57-
name: coverage_unit
58-
path: coverage_unit.tar
66+
name: ${{ env.NYC_REPORT_DIR }}
67+
path: ${{ env.NYC_REPORT_DIR }}.tar
5968
retention-days: 1
6069

6170
e2e-test:
@@ -67,6 +76,7 @@ jobs:
6776
E2E_ACCESS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
6877
E2E_TABLE_SUFFIX: ${{github.sha}}
6978
cache-name: cache-node-modules
79+
NYC_REPORT_DIR: coverage_e2e
7080

7181
steps:
7282
- uses: actions/checkout@v3
@@ -83,12 +93,12 @@ jobs:
8393
run: |
8494
npm ci
8595
NODE_OPTIONS="--max-old-space-size=4096" npm run e2e
86-
- run: tar -cvf coverage_e2e.tar coverage_e2e
96+
- run: tar -cvf ${{ env.NYC_REPORT_DIR }}.tar ${{ env.NYC_REPORT_DIR }}
8797
- name: Store coverage report
88-
uses: actions/upload-artifact@v3
98+
uses: actions/upload-artifact@v4
8999
with:
90-
name: coverage_e2e
91-
path: coverage_e2e.tar
100+
name: ${{ env.NYC_REPORT_DIR }}
101+
path: ${{ env.NYC_REPORT_DIR }}.tar
92102
retention-days: 1
93103

94104
coverage:
@@ -108,14 +118,15 @@ jobs:
108118
${{ runner.os }}-build-${{ env.cache-name }}-
109119
${{ runner.os }}-build-
110120
${{ runner.os }}-
111-
- uses: actions/download-artifact@v3
112-
with:
113-
name: coverage_unit
114-
- uses: actions/download-artifact@v3
121+
- uses: actions/download-artifact@v4
115122
with:
116-
name: coverage_e2e
117-
- run: tar -xvf coverage_unit.tar && rm coverage_unit.tar
118-
- run: tar -xvf coverage_e2e.tar && rm coverage_e2e.tar
123+
pattern: coverage_*
124+
merge-multiple: true
125+
- name: Unpack coverage reports
126+
run: |
127+
ls -1 coverage_*.tar | xargs -I '{}' -- tar -xvf '{}'
128+
rm coverage_*.tar
129+
- run: ls -la
119130
- name: Coverage
120131
uses: codecov/codecov-action@v3
121132
with:

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
},
1414
"scripts": {
1515
"prepare": "npm run build",
16-
"e2e": "nyc --reporter=lcov --report-dir=coverage_e2e mocha --config tests/e2e/.mocharc.js",
17-
"test": "nyc --reporter=lcov --report-dir=coverage_unit mocha --config tests/unit/.mocharc.js",
16+
"e2e": "nyc --reporter=lcov --report-dir=${NYC_REPORT_DIR:-coverage_e2e} mocha --config tests/e2e/.mocharc.js",
17+
"test": "nyc --reporter=lcov --report-dir=${NYC_REPORT_DIR:-coverage_unit} mocha --config tests/unit/.mocharc.js",
1818
"update-version": "node bin/update-version.js && prettier --write ./lib/version.ts",
1919
"build": "npm run update-version && tsc",
2020
"watch": "tsc -w",

0 commit comments

Comments
 (0)