Skip to content

Commit 7866008

Browse files
authored
Add version matrix to lint, codeql and test (#326)
As the prototype kit requires any nodejs version after 16, this PR introduces test matrices for codeql, linting and tests for versions from v16 onwards. We don't lint v16 or v18 as they are not supported by our linter. We don't test v16 as it is unsupported by our test framework.
1 parent b08b568 commit 7866008

File tree

4 files changed

+51
-17
lines changed

4 files changed

+51
-17
lines changed

.github/workflows/codeql.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
jobs:
1212
analyze:
13-
name: Analyze (${{ matrix.language }})
13+
name: Analyze (${{ matrix.language }}${{ matrix.node-version && format(' - Node.js {0}', matrix.node-version) || '' }})
1414
# Runner size impacts CodeQL analysis time. To learn more, please see:
1515
# - https://gh.io/recommended-hardware-resources-for-running-codeql
1616
# - https://gh.io/supported-runners-and-hardware-resources
@@ -36,12 +36,32 @@ jobs:
3636
build-mode: none
3737
- language: javascript-typescript
3838
build-mode: none
39+
node-version: '16'
40+
- language: javascript-typescript
41+
build-mode: none
42+
node-version: '18'
43+
- language: javascript-typescript
44+
build-mode: none
45+
node-version: '20'
46+
- language: javascript-typescript
47+
build-mode: none
48+
node-version: '22'
49+
- language: javascript-typescript
50+
build-mode: none
51+
node-version: '24'
3952
- language: python
4053
build-mode: none
4154
steps:
4255
- name: Checkout repository
4356
uses: actions/checkout@v4
4457

58+
# Setup Node.js for JavaScript/TypeScript analysis
59+
- name: Setup Node.js
60+
if: matrix.language == 'javascript-typescript'
61+
uses: actions/setup-node@v4
62+
with:
63+
node-version: ${{ matrix.node-version }}
64+
4565
# Initializes the CodeQL tools for scanning.
4666
- name: Initialize CodeQL
4767
uses: github/codeql-action/init@v3

.github/workflows/lint.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
name: Lint JS
22
on:
33
push:
4-
branches: [main]
4+
branches: [ main ]
55
pull_request:
6-
branches: [main]
6+
branches: [ main ]
77
jobs:
88
lint-importer:
99
defaults:
1010
run:
1111
working-directory: ./lib/importer
1212
timeout-minutes: 5
1313
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
node-version: [ '20', '22', '24' ]
17+
name: Lint Importer (Node.js ${{ matrix.node-version }})
1418
steps:
1519
- uses: actions/checkout@v4
1620
- uses: actions/setup-node@v4
1721
with:
18-
node-version: lts/*
22+
node-version: ${{ matrix.node-version }}
1923
- name: Install dependencies
2024
run: npm i
2125
- name: Run linter

.github/workflows/test.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
name: Tests
22
on:
33
push:
4-
branches: [main]
4+
branches: [ main ]
55
pull_request:
6-
branches: [main]
6+
branches: [ main ]
77
jobs:
88
test:
99
defaults:
1010
run:
1111
working-directory: ./prototypes/basic
1212
timeout-minutes: 60
1313
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
node-version: [ '18', '20', '22', '24' ]
17+
name: Test (Node.js ${{ matrix.node-version }})
1418
steps:
1519
- uses: actions/checkout@v4
1620
- uses: actions/setup-node@v4
1721
with:
18-
node-version: lts/*
22+
node-version: ${{ matrix.node-version }}
1923
- name: Install lib dependencies -- todo, check why
2024
working-directory: ./lib/importer
2125
run: npm i
@@ -28,7 +32,7 @@ jobs:
2832
- uses: actions/upload-artifact@v4
2933
if: always()
3034
with:
31-
name: test-results
35+
name: test-results-node-${{ matrix.node-version }}
3236
path: ./prototypes/basic/test-results
3337
retention-days: 30
3438
importer:
@@ -37,11 +41,15 @@ jobs:
3741
working-directory: ./lib/importer
3842
timeout-minutes: 60
3943
runs-on: ubuntu-latest
44+
strategy:
45+
matrix:
46+
node-version: [ '18', '20', '22', '24' ]
47+
name: Test Importer (Node.js ${{ matrix.node-version }})
4048
steps:
4149
- uses: actions/checkout@v4
4250
- uses: actions/setup-node@v4
4351
with:
44-
node-version: lts/*
52+
node-version: ${{ matrix.node-version }}
4553
- name: Install lib dependencies
4654
run: npm i
4755
- name: Run tests

lib/importer/src/dudk/sheets.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -422,22 +422,24 @@ const remapErrorStructure = (errors, row_data, mappingIndices, headerRangeOffset
422422
}
423423
}
424424

425-
// Convert the nested maps/sets to the desired array structure
426-
return Array.from(messageMap.values().map((errorObj) => {
427-
// Some rows may not have any errors because they are for surrounding context,
428-
// so we need to filter them out for the meta info
425+
// Collect error structures for each value in the messageMap, avoiding
426+
// .values().map(...) as that is not supported in earlier versions
427+
// of node
428+
const errorsOut = []
429+
for( const errorObj of messageMap.values()) {
429430
const errorRows = Array.from(errorObj.rows.values()).filter(rowObj => rowObj.error);
430-
431-
return {
431+
errorsOut.push({
432432
type: errorObj.type,
433433
meta: {
434434
first: errorRows[0]?.index || 0,
435435
count: errorRows?.length || 0
436436
},
437437
field: errorObj.field,
438438
rows: Array.from(errorObj.rows.values())
439-
}
440-
}));
439+
})
440+
}
441+
442+
return Array.from(errorsOut);
441443
}
442444

443445
exports.RemapErrorStructure = remapErrorStructure

0 commit comments

Comments
 (0)