Skip to content

Add tests for Node 20.x #221

Add tests for Node 20.x

Add tests for Node 20.x #221

Workflow file for this run

# This workflow will do a clean installation of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Main Workflow
on:
push:
branches:
- main
pull_request:
jobs:
# Run code-style checks
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
# @see https://www.voorhoede.nl/en/blog/super-fast-npm-install-on-github-actions/
- uses: actions/cache@v3
id: cache-node-modules
with:
path: ./node_modules
key: ${{ runner.os }}-modules-${{ hashFiles('package-lock.json') }}
- name: Install packages
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Run Linters
run: npm run lint
# Run tests
test:
runs-on: ubuntu-latest
strategy:
matrix:
node: ['16', '18', '19', '20']
name: Test Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
# @see https://www.voorhoede.nl/en/blog/super-fast-npm-install-on-github-actions/
- uses: actions/cache@v3
id: cache-node-modules
with:
path: ./node_modules
key: ${{ runner.os }}-${{ matrix.node }}-modules-${{ hashFiles('package-lock.json') }}
- name: Install packages
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Run Tests
run: npm test
# Test building binaries
binaries:
needs: [lint, test]
name: Binaries (build)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
# @see https://www.voorhoede.nl/en/blog/super-fast-npm-install-on-github-actions/
- uses: actions/cache@v3
id: cache-node-modules
with:
path: ./node_modules
key: ${{ runner.os }}-modules-${{ hashFiles('package-lock.json') }}
- name: Install packages
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Create Binaries
run: npm run dist
- name: 'Upload Binaries'
uses: actions/upload-artifact@v3
with:
path: dist
name: linux-binaries
retention-days: 1
- name: Create Binaries (arm64)
run: npm run dist-arm
- name: 'Upload Binaries (arm64)'
uses: actions/upload-artifact@v3
with:
path: dist
name: linux-arm64-binaries
retention-days: 1
# Test building binaries on MacOS
binaries-macos:
# NOTE: This is disabled for now since Rosetta cannot be installed on the macos runners and we're running into issues…
if: false
needs: [lint, test]
name: Binaries MacOS (build)
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
# @see https://www.voorhoede.nl/en/blog/super-fast-npm-install-on-github-actions/
- uses: actions/cache@v3
id: cache-node-modules
with:
path: ./node_modules
key: ${{ runner.os }}-modules-${{ hashFiles('package-lock.json') }}
- name: Install packages
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Create Binaries (arm64)
run: npm run dist-arm-macos
- name: 'Upload Binaries'
uses: actions/upload-artifact@v3
with:
path: dist
name: macos-arm64-binaries
retention-days: 1