Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add possibility to test node packages against multiple node versions #51

Merged
merged 13 commits into from
Jun 12, 2024
20 changes: 12 additions & 8 deletions .github/workflows/build_node_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,37 @@ name: Build and test npm package
on:
workflow_call:
inputs:
run_tests:
description: 'Run tests'
node:
description: 'JSON array of Node.js versions and parameters'
required: false
type: boolean
default: false
type: string
default: '[{"version": "18", "tests": true, "lint": true}]'

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [16.x]
node: ${{ fromJson(inputs.node)}}
name: Build on ${{ matrix.node.version }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Use Node.js ${{ inputs.node_version }}
- name: Use Node.js ${{ matrix.node.version}}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node_version }}
node-version: ${{ matrix.node.version }}

- name: Install Dependencies
run: npm ci

- name: Run lint
if: ${{ fromJson(matrix.node.lint) }}
run: npm run lint

- name: Run tests
if: ${{ fromJson(inputs.run_tests)}}
if: ${{ fromJson(matrix.node.tests) }}
run: npm run test