# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs # https://hanxiao.io/2021/01/24/Speedup-CI-Workflow-in-Github-Actions-via-Strategy-Matrix/ name: Node.js Test on: pull_request: workflow_dispatch: inputs: ref: description: 'Git ref (refs/heads/, refs/tags/, etc.) or SHA' required: true type: string concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true env: ref: ${{ inputs.ref || github.sha || github.ref }} jobs: path-filter: permissions: pull-requests: read runs-on: ubuntu-latest outputs: should-test: ${{ steps.filter.outputs.should-test }} should-delete-prebuilds: ${{ steps.filter.outputs.should-delete-prebuilds }} steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 with: ref: ${{ env.ref }} - id: filter uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 with: filters: | should-test: - '.github/workflows/node-test.yml' - 'packages/**' - 'src/**' - 'test/**' - '*' should-delete-prebuilds: - '.github/workflows/napi-prebuild.yml' - 'packages/zlib*/**' - 'packages/zstd*/**' - 'package*.json' node-lint: needs: - path-filter if: ${{ needs.path-filter.outputs.should-test == 'true' }} runs-on: ubuntu-latest steps: # Setup and install - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 with: ref: ${{ env.ref }} submodules: 'recursive' - uses: volta-cli/action@5c175f92dea6f48441c436471e6479dbc192e194 # v4.2.1 - uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 with: path: | ~/.npm ~\AppData\Roaming\npm-cache key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-npm- ${{ runner.os }}- - run: npm ci # Lint the source files - run: npm start -- --help - run: npm run lint # TODO(cemmer): check for deprecated dependencies # https://stackoverflow.com/questions/44097267/find-packages-that-give-deprecated-warning-npm node-unit: needs: - path-filter if: ${{ needs.path-filter.outputs.should-test == 'true' }} name: node-unit (${{ matrix.os }}, ${{ matrix.node-version || 'package.json' }}) runs-on: ${{ matrix.os }} timeout-minutes: 20 strategy: fail-fast: false matrix: # TODO(cemmer): chdman-js and maxcso-js don't have Windows ARM builds, so it won't test the same os: [ ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-13, windows-latest ] node-version: [ '' ] include: - os: ubuntu-latest node-version: 18 - os: macos-latest node-version: 18 - os: windows-latest node-version: 20 steps: # Setup and install - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 with: ref: ${{ env.ref }} submodules: 'recursive' - uses: volta-cli/action@5c175f92dea6f48441c436471e6479dbc192e194 # v4.2.1 with: node-version: ${{ matrix.node-version }} - uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 with: path: | ~/.npm ~\AppData\Roaming\npm-cache key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-npm- ${{ runner.os }}- - if: ${{ needs.path-filter.outputs.should-delete-prebuilds == 'true' }} shell: bash run: rm -rf packages/*/addon* packages/*/prebuilds* - run: npm ci --foreground-scripts - if: ${{ startsWith(matrix.os, 'ubuntu') }} run: | sudo apt-get update sudo apt-get install -y libsdl2-2.0-0 libsdl2-ttf-2.0-0 # Test the source files - run: npm run test:unit node-e2e: needs: - path-filter if: ${{ needs.path-filter.outputs.should-test == 'true' }} name: node-e2e (${{ matrix.node-version || 'package.json' }}) runs-on: ubuntu-latest timeout-minutes: 10 strategy: matrix: node-version: [ '', 18 ] steps: # Setup and install - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 with: ref: ${{ env.ref }} submodules: 'recursive' - uses: volta-cli/action@5c175f92dea6f48441c436471e6479dbc192e194 # v4.2.1 with: node-version: ${{ matrix.node-version }} - uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 with: path: | ~/.npm ~\AppData\Roaming\npm-cache key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-npm- ${{ runner.os }}- - run: npm ci --foreground-scripts - run: | sudo apt-get update sudo apt-get install -y libsdl2-2.0-0 libsdl2-ttf-2.0-0 # Test the built files - run: ./test/endToEndTest.sh # !!! This check should be required by GitHub !!! test-status-check: if: always() needs: - path-filter - node-lint - node-unit - node-e2e runs-on: ubuntu-latest steps: - uses: re-actors/alls-green@release/v1 with: jobs: ${{ toJSON(needs) }} allowed-skips: node-lint, node-unit, node-e2e, node-package