Skip to content

Merge pull request #2 from jackdbd/canary #25

Merge pull request #2 from jackdbd/canary

Merge pull request #2 from jackdbd/canary #25

Workflow file for this run

name: 'CI'
on:
pull_request:
push:
branches:
- canary
- main
jobs:
audit-build-test-release:
name: Audit, build, test, release on ${{ matrix.os }}, Node ${{ matrix.node }}
# The minimum set of permissions required by semantic-release/github for
# the GITHUB_TOKEN and this job is explained here:
# https://github.com/semantic-release/github#configuration
# https://github.com/semantic-release/semantic-release/issues/2481#issuecomment-1409780688
permissions:
contents: write
issues: write
pull-requests: write
runs-on: ${{ matrix.os }}
strategy:
matrix:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
os: [ubuntu-latest]
# Test all packages with:
# 1. Maintenance LTS
# 2. Active LTS
# 3. Current (i.e. the latest Node.js version available)
# https://nodejs.org/en/about/previous-releases
node: [lts/Iron]
# node: [lts/Hydrogen, lts/Iron, current]
steps:
- name: πŸ›ŽοΈ Checkout repo
uses: actions/checkout@v4
- name: βš™οΈ Set up Node.js ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: ⬇️ Install dependencies
run: npm ci
- name: πŸ›‘οΈ Audit dependencies (audit-level high)
# https://docs.npmjs.com/cli/v8/commands/npm-audit#audit-level
run: npm audit --audit-level high
- name: πŸ›‘οΈ Audit dependencies (audit-level moderate)
continue-on-error: true
run: npm audit --audit-level moderate
- name: πŸ”¨ Build TypeScript files
run: npm run build:ts
- name: πŸ” Test
run: npm run test
- name: πŸ” Test CI
continue-on-error: true
# From time to time the Node.js test runner fails when generating a coverage report. No idea why.
run: npm run test:ci
- name: ⬆️ Upload test coverage to Codecov
if: runner.os == 'Linux'
# https://github.com/marketplace/actions/codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
fail_ci_if_error: false
files: ./coverage/lcov.info
verbose: true
- name: πŸ“¦ Size report
if: ${{ github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest' }}
uses: pkg-size/action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
build-command: false # because we have just built (otherwise: npm run build:ts)
display-size: uncompressed,gzip,brotli
# ignore all docs, TS type definitions and JS/TS source maps
hide-files: '{api-docs/**,docs/**,*.d.ts,*.map}'
unchanged-files: show
- name: πŸš€ Release to npmjs
if: ${{ matrix.os == 'ubuntu-latest' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/canary') }}
env:
# This github token must allow to push to this GitHub repository.
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_NPM_TOKEN }}
run: npx semantic-release --ci
macos-build-test:
name: Build & test on ${{ matrix.os }}, Node ${{ matrix.node }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [macos-latest]
node: [lts/Iron]
steps:
- name: πŸ›ŽοΈ Checkout repo
uses: actions/checkout@v4
- name: βš™οΈ Set up Node.js ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: ⬇️ Install dependencies
run: npm ci
- name: πŸ“¦ Build npm package
run: npm run build:ts
- name: πŸ” Test
run: npm run test
windows-build-test:
name: Build & test on ${{ matrix.os }}, Node ${{ matrix.node }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [windows-latest]
node: [lts/Iron]
steps:
- name: πŸ›ŽοΈ Checkout repo
uses: actions/checkout@v4
- name: βš™οΈ Set up Node.js ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: ⬇️ Install dependencies
run: npm ci
- name: πŸ“¦ Build npm package
run: npm run build:ts
- name: πŸ” Test
run: npm run test