Skip to content

Commit f564a33

Browse files
authored
test: allow to run tests in parallel (#115)
1 parent 417cf78 commit f564a33

File tree

4 files changed

+61
-14
lines changed

4 files changed

+61
-14
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,36 @@ on:
77
pull_request:
88

99
jobs:
10-
test:
10+
build:
1111
strategy:
1212
fail-fast: false # prevent test to stop if one fails
1313
matrix:
1414
node-version: [18.x, 20.x]
1515
os: [ubuntu-latest, windows-latest, macos-latest]
1616
runs-on: ${{ matrix.os }}
1717
steps:
18-
- uses: actions/checkout@v3
19-
- uses: actions/setup-node@v3
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-node@v4
2020
with:
2121
node-version: ${{ matrix.node-version }}
22-
- uses: actions/cache@v3
23-
with:
24-
path: ~/.pkg-cache/
25-
key: ${{ matrix.os }}-${{ matrix.node-version }}
22+
cache: 'yarn'
2623

2724
- run: yarn install
2825

2926
- if: matrix['node-version'] == '18.x' && matrix['os'] == 'ubuntu-latest'
3027
run: yarn lint
3128
- run: yarn build
32-
- run: yarn test
33-
env:
34-
CI: true
35-
timeout-minutes: 30
29+
test_host:
30+
uses: ./.github/workflows/test.yml
31+
with:
32+
npm_command: test:host
33+
34+
test_18:
35+
uses: ./.github/workflows/test.yml
36+
with:
37+
npm_command: test:18
38+
39+
test_20:
40+
uses: ./.github/workflows/test.yml
41+
with:
42+
npm_command: test:20

.github/workflows/test.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
npm_command:
7+
description: 'NPM command to run'
8+
type: string
9+
required: true
10+
default: 'install'
11+
jobs:
12+
test:
13+
strategy:
14+
fail-fast: false # prevent test to stop if one fails
15+
matrix:
16+
node-version: [18.x, 20.x]
17+
os: [ubuntu-latest, windows-latest, macos-latest]
18+
runs-on: ${{ matrix.os }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: 'yarn'
25+
- uses: actions/cache@v4
26+
with:
27+
path: ~/.pkg-cache/
28+
key: ${{ matrix.os }}-${{ matrix.node-version }}
29+
30+
- run: yarn install
31+
32+
- run: yarn build
33+
- run: yarn ${{ inputs.npm_command }}
34+
env:
35+
CI: true
36+
timeout-minutes: 30

test/test-80-compression-node-opcua/main.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ const assert = require('assert');
1414
const utils = require('../utils.js');
1515
const pkgJson = require('./package.json');
1616

17+
// FIXME: this test takes a long time to run (from 5min on linux up to 10 minuntes on windows)
18+
// run only on linux to save time on CI
19+
if (process.platform !== 'linux') {
20+
return;
21+
}
22+
1723
const isWindows = process.platform === 'win32';
1824
const buildDir = 'build';
1925

test/test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ async function run() {
189189
} catch (error) {
190190
failed.push({
191191
file,
192-
error: error.message,
193192
output: error.logOutput,
194193
});
195194
addLog(
@@ -219,10 +218,9 @@ async function run() {
219218
console.log(`Ok: ${ok}`);
220219
console.log(`Failed: ${failed.length}`);
221220
// print failed tests
222-
for (const { file, error, output } of failed) {
221+
for (const { file, output } of failed) {
223222
console.log('');
224223
console.log(`--- ${file} ---`);
225-
console.log(pc.red(error));
226224
console.log(pc.red(output));
227225
}
228226
console.log(`Time: ${msToHumanDuration(end - start)}`);

0 commit comments

Comments
 (0)