Skip to content

CI

CI #134

Workflow file for this run

name: CI
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
schedule:
- cron: '0 15 * * 5'
jobs:
build:
runs-on: ubuntu-slim
permissions:
contents: read
id-token: write
attestations: write
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
submodules: recursive
persist-credentials: false
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: lts/*
- run: mkdir -p pkg
- name: Package
run: npm pack --pack-destination pkg
- id: attest
uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4.1.0
with:
subject-path: pkg/*
- name: Copy attestation bundle
run: |
cp "$BUNDLE" pkg/provenance.json
env:
BUNDLE: ${{ steps.attest.outputs.bundle-path }}
- id: upload
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: package
path: pkg/
outputs:
artifact-id: ${{ steps.upload.outputs.artifact-id }}
test:
needs: [build]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
node: [20, 22, 24, 26]
runs-on: ${{ matrix.os }}
permissions:
contents: read
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- name: Install
run: |
if type apt-get >/dev/null; then
clang_version=$(clang --version | perl -e '<> =~ /(\d+)\.\d+\.\d+/ && print $1')
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends lcov llvm-"${clang_version}"
sudo update-alternatives --install /usr/bin/llvm-cov llvm /usr/bin/llvm-cov-"${clang_version}" 100
elif type brew >/dev/null; then
brew install lcov
fi
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ matrix.node }}
cache: npm
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: /home/runner/.cmake-js
key: node-${{ matrix.node }}-cmake-js
- name: Setup compilers
if: startsWith(matrix.os, 'macos-')
run: |
cd /usr/local/bin
ln -sf gcc-12 gcc
ln -sf g++-12 g++
ln -sf gcov-12 gcov
ln -sf /Library/Developer/CommandLineTools/usr/bin/llvm-cov .
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
artifact-ids: ${{ needs.build.outputs.artifact-id }}
path: pkg/
- name: Test with GCC
run: |
if [[ $(uname -s) == Darwin ]]; then
unset NODE_JSONNET_ENABLE_COVERAGE
fi
./scripts/test-packaging.sh pkg/*.tgz
env:
CC: gcc
CXX: g++
CMAKE_BUILD_PARALLEL_LEVEL: '4'
NODE_JSONNET_ENABLE_COVERAGE: gcc
- name: Test with Clang
run: |
if [[ $(uname -s) == Darwin ]]; then
unset NODE_JSONNET_ENABLE_COVERAGE
fi
./scripts/test-packaging.sh pkg/*.tgz
env:
CC: clang
CXX: clang++
CMAKE_BUILD_PARALLEL_LEVEL: '4'
NODE_JSONNET_ENABLE_COVERAGE: clang
- name: Coveralls
continue-on-error: true
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
with:
github-token: ${{ secrets.github_token }}
flag-name: ${{ matrix.os }}-${{ matrix.node }}
parallel: true
test-finish:
needs: test
runs-on: ubuntu-latest
permissions: {}
steps:
- name: Upload to Coveralls
continue-on-error: true
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
typetest:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: lts/*
cache: npm
- name: Install
run: npm install --ignore-scripts
- name: Test
run: npm run typetest
- name: Typecheck scripts
run: npm run typecheck -w .github/scripts
docs:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: lts/*
cache: npm
- name: Install
run: npm install --ignore-scripts
- name: Generate docs
run: |
cd types
npm exec -- typedoc --out "../docs/tmp"
publish:
if: startsWith(github.ref, 'refs/tags/v')
needs: [test-finish, typetest, build]
runs-on: ubuntu-slim
permissions:
contents: write
id-token: write
environment: npmjs.com
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: lts/*
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
artifact-ids: ${{ needs.build.outputs.artifact-id }}
path: pkg/
- id: release
name: Upload to GitHub releases
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: await require("./.github/scripts/release.cjs")({ github, context, core });
- name: Publish to npmjs
shell: bash
run: |
if "$PRE"; then
tag=(--tag prerelease)
else
tag=()
fi
npm publish ./pkg/*.tgz --provenance-file ./pkg/provenance.json "${tag[@]}"
env:
PRE: ${{ steps.release.outputs.prerelease }}