Skip to content

Commit

Permalink
test: allow to run tests in parallel (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando authored Oct 24, 2024
1 parent 417cf78 commit f564a33
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 14 deletions.
29 changes: 18 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,36 @@ on:
pull_request:

jobs:
test:
build:
strategy:
fail-fast: false # prevent test to stop if one fails
matrix:
node-version: [18.x, 20.x]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v3
with:
path: ~/.pkg-cache/
key: ${{ matrix.os }}-${{ matrix.node-version }}
cache: 'yarn'

- run: yarn install

- if: matrix['node-version'] == '18.x' && matrix['os'] == 'ubuntu-latest'
run: yarn lint
- run: yarn build
- run: yarn test
env:
CI: true
timeout-minutes: 30
test_host:
uses: ./.github/workflows/test.yml
with:
npm_command: test:host

test_18:
uses: ./.github/workflows/test.yml
with:
npm_command: test:18

test_20:
uses: ./.github/workflows/test.yml
with:
npm_command: test:20
36 changes: 36 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI

on:
workflow_call:
inputs:
npm_command:
description: 'NPM command to run'
type: string
required: true
default: 'install'
jobs:
test:
strategy:
fail-fast: false # prevent test to stop if one fails
matrix:
node-version: [18.x, 20.x]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- uses: actions/cache@v4
with:
path: ~/.pkg-cache/
key: ${{ matrix.os }}-${{ matrix.node-version }}

- run: yarn install

- run: yarn build
- run: yarn ${{ inputs.npm_command }}
env:
CI: true
timeout-minutes: 30
6 changes: 6 additions & 0 deletions test/test-80-compression-node-opcua/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ const assert = require('assert');
const utils = require('../utils.js');
const pkgJson = require('./package.json');

// FIXME: this test takes a long time to run (from 5min on linux up to 10 minuntes on windows)
// run only on linux to save time on CI
if (process.platform !== 'linux') {
return;
}

const isWindows = process.platform === 'win32';
const buildDir = 'build';

Expand Down
4 changes: 1 addition & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ async function run() {
} catch (error) {
failed.push({
file,
error: error.message,
output: error.logOutput,
});
addLog(
Expand Down Expand Up @@ -219,10 +218,9 @@ async function run() {
console.log(`Ok: ${ok}`);
console.log(`Failed: ${failed.length}`);
// print failed tests
for (const { file, error, output } of failed) {
for (const { file, output } of failed) {
console.log('');
console.log(`--- ${file} ---`);
console.log(pc.red(error));
console.log(pc.red(output));
}
console.log(`Time: ${msToHumanDuration(end - start)}`);
Expand Down

0 comments on commit f564a33

Please # to comment.