Skip to content

chore(deps): lock file maintenance #852

chore(deps): lock file maintenance

chore(deps): lock file maintenance #852

Workflow file for this run

name: CI
env:
DEBUG: napi:*
APP_NAME: snappy
MACOSX_DEPLOYMENT_TARGET: '10.13'
CARGO_INCREMENTAL: '1'
TARGET_CC: 'clang'
permissions:
contents: write
id-token: write
'on':
push:
branches:
- main
tags-ignore:
- '**'
paths-ignore:
- '**/*.md'
- LICENSE
- '**/*.gitignore'
- .editorconfig
- docs/**
pull_request: null
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Setup node
uses: actions/setup-node@v7
with:
node-version: 24
cache: 'yarn'
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Install dependencies
run: yarn install
- name: Oxlint
run: yarn lint
- name: Cargo fmt
run: cargo fmt -- --check
- name: Clippy
run: cargo clippy
memory-leak-detect:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Setup node
uses: actions/setup-node@v7
with:
node-version: 24
cache: 'yarn'
- name: Install
uses: dtolnay/rust-toolchain@stable
- name: 'Install dependencies'
run: yarn install --mode=skip-build
- name: 'Build binary'
run: yarn build
- name: 'Memory test'
run: yarn test:mem
build:
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest
target: x86_64-apple-darwin
build: yarn build --target x86_64-apple-darwin
- host: windows-latest
build: yarn build --target x86_64-pc-windows-msvc
target: x86_64-pc-windows-msvc
- host: windows-latest
build: yarn build --target i686-pc-windows-msvc
target: i686-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
build: yarn build --target x86_64-unknown-linux-gnu --use-napi-cross
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
build: yarn build --target x86_64-unknown-linux-musl -x
- host: macos-latest
target: aarch64-apple-darwin
build: yarn build --target aarch64-apple-darwin
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
build: yarn build --target aarch64-unknown-linux-gnu --use-napi-cross
- host: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
build: yarn build --target armv7-unknown-linux-gnueabihf --use-napi-cross
- host: ubuntu-latest
target: aarch64-linux-android
build: yarn build --target aarch64-linux-android
- host: ubuntu-latest
target: armv7-linux-androideabi
build: yarn build --target armv7-linux-androideabi
- host: ubuntu-latest
target: aarch64-unknown-linux-musl
build: yarn build --target aarch64-unknown-linux-musl -x
- host: windows-latest
target: aarch64-pc-windows-msvc
build: yarn build --target aarch64-pc-windows-msvc
- host: ubuntu-latest
target: riscv64gc-unknown-linux-gnu
build: |
sudo apt-get update
sudo apt-get install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu -y
export CC=riscv64-linux-gnu-gcc
export TARGET_CC=riscv64-linux-gnu-gcc
export CXX=riscv64-linux-gnu-g++
yarn build --target riscv64gc-unknown-linux-gnu
- host: ubuntu-latest
target: s390x-unknown-linux-gnu
build: |
export CC=clang
export CFLAGS="-fuse-ld=lld"
yarn build --target s390x-unknown-linux-gnu --use-napi-cross
- host: ubuntu-latest
target: powerpc64le-unknown-linux-gnu
build: yarn build --target powerpc64le-unknown-linux-gnu --use-napi-cross
- host: ubuntu-latest
target: aarch64-unknown-linux-ohos
build: yarn build --target aarch64-unknown-linux-ohos
- host: ubuntu-latest
target: wasm32-wasip1-threads
build: yarn build --target wasm32-wasip1-threads
name: stable - ${{ matrix.settings.target }} - node@22
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v7
- name: Setup node
uses: actions/setup-node@v7
with:
node-version: 24
cache: yarn
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
- name: Cache cargo
uses: actions/cache@v6
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.napi-rs
.cargo-cache
target/
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
- uses: mlugg/setup-zig@v2
if: ${{ contains(matrix.settings.target, 'musl') }}
with:
version: 0.15.2
- name: Install cargo-zigbuild
uses: taiki-e/install-action@v2
if: ${{ contains(matrix.settings.target, 'musl') }}
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tool: cargo-zigbuild
- name: Setup OpenHarmony SDK
if: ${{ contains(matrix.settings.target, 'ohos') }}
uses: openharmony-rs/setup-ohos-sdk@v1.0
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
shell: bash
- name: Install dependencies
run: yarn install
- name: Build
run: ${{ matrix.settings.build }}
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: bindings-${{ matrix.settings.target }}
path: |
${{ env.APP_NAME }}.*.node
${{ env.APP_NAME }}.*.wasm
if-no-files-found: error
build-freebsd:
runs-on: ubuntu-latest
name: Build FreeBSD
steps:
- uses: actions/checkout@v7
- name: Build
id: build
uses: cross-platform-actions/action@v1.5.0
env:
DEBUG: napi:*
RUSTUP_IO_THREADS: 1
with:
operating_system: freebsd
version: '15.0'
memory: 8G
cpu_count: 3
environment_variables: 'DEBUG RUSTUP_IO_THREADS'
shell: bash
run: |
sudo pkg install -y -f curl node libnghttp2 npm cmake
sudo npm install -g yarn --ignore-scripts
curl https://sh.rustup.rs -sSf --output rustup.sh
sh rustup.sh -y --profile minimal --default-toolchain stable
source "$HOME/.cargo/env"
echo "~~~~ rustc --version ~~~~"
rustc --version
echo "~~~~ node -v ~~~~"
node -v
echo "~~~~ yarn --version ~~~~"
yarn --version
pwd
ls -lah
whoami
env
freebsd-version
yarn install --mode=skip-build
yarn build
rm -rf node_modules
rm -rf target
rm -rf .yarn/cache
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: bindings-freebsd
path: ${{ env.APP_NAME }}.*.node
if-no-files-found: error
test-macOS-windows-binding:
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
needs:
- build
strategy:
fail-fast: false
matrix:
settings:
- host: windows-latest
target: x86_64-pc-windows-msvc
architecture: x64
- host: windows-11-arm
target: aarch64-pc-windows-msvc
architecture: arm64
- host: macos-latest
target: aarch64-apple-darwin
architecture: arm64
- host: macos-latest
target: x86_64-apple-darwin
architecture: x64
node:
- '22'
- '24'
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v7
- name: Setup node
uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node }}
cache: yarn
architecture: ${{ matrix.settings.architecture }}
- name: Install dependencies
run: yarn install
- name: Download artifacts
uses: actions/download-artifact@v8
with:
name: bindings-${{ matrix.settings.target }}
path: .
- name: List packages
run: ls -R .
shell: bash
- name: Test bindings
run: yarn test
test-linux-binding:
name: Test ${{ matrix.target }} - node@${{ matrix.node }}
needs:
- build
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-gnu
- aarch64-unknown-linux-musl
- armv7-unknown-linux-gnueabihf
- s390x-unknown-linux-gnu
node:
- '22'
- '24'
exclude:
- target: armv7-unknown-linux-gnueabihf
node: '24'
runs-on: ${{ contains(matrix.target, 'aarch64') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v7
- name: Setup node
uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node }}
cache: yarn
- name: Output docker params
id: docker
run: |
node -e "
if ('${{ matrix.target }}'.startsWith('aarch64')) {
console.log('PLATFORM=linux/arm64')
} else if ('${{ matrix.target }}'.startsWith('armv7')) {
console.log('PLATFORM=linux/arm/v7')
} else if ('${{ matrix.target }}'.startsWith('s390x')) {
console.log('PLATFORM=linux/s390x')
} else {
console.log('PLATFORM=linux/amd64')
}
" >> $GITHUB_OUTPUT
node -e "
if ('${{ matrix.target }}'.endsWith('-musl')) {
console.log('IMAGE=node:${{ matrix.node }}-alpine')
} else if ('${{ matrix.target }}'.startsWith('s390x')) {
// node:N-slim dropped linux/s390x; trixie-slim still publishes it
console.log('IMAGE=node:${{ matrix.node }}-trixie-slim')
} else {
console.log('IMAGE=node:${{ matrix.node }}-slim')
}
" >> $GITHUB_OUTPUT
- name: Install dependencies
run: |
yarn config set --json supportedArchitectures.cpu '["current", "arm64", "x64", "arm", "s390x"]'
yarn config set --json supportedArchitectures.libc '["current", "musl", "gnu"]'
yarn install
- name: Download artifacts
uses: actions/download-artifact@v8
with:
name: bindings-${{ matrix.target }}
path: .
- name: List packages
run: ls -R .
shell: bash
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
if: ${{ !contains(matrix.target, 'aarch64') }}
with:
platforms: all
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
if: ${{ !contains(matrix.target, 'aarch64') }}
- name: Test bindings
uses: addnab/docker-run-action@v3
# s390x runs under QEMU user-mode emulation, which can flakily fail
# independently of our code; keep coverage when green without failing CI.
continue-on-error: ${{ contains(matrix.target, 's390x') }}
with:
image: ${{ steps.docker.outputs.IMAGE }}
options: -v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} --platform ${{ steps.docker.outputs.PLATFORM }}
run: yarn test
test-wasi:
name: Test WASI target
needs:
- build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Setup node
uses: actions/setup-node@v7
with:
node-version: 24
cache: yarn
- name: Install dependencies
run: |
# Host arch for ava/@oxc-node; wasm32 so optional wasm tooling stays available
yarn config set --json supportedArchitectures.cpu '["current", "wasm32"]'
yarn install
- name: Download artifacts
uses: actions/download-artifact@v8
with:
name: bindings-wasm32-wasip1-threads
path: .
- name: List packages
run: ls -R .
shell: bash
- name: Test bindings
run: yarn test
env:
# index.js only treats 'true' / 'error' as force (not bare '1')
NAPI_RS_FORCE_WASI: 'true'
publish:
name: Publish
runs-on: ubuntu-latest
needs:
- lint
- memory-leak-detect
- build-freebsd
- test-macOS-windows-binding
- test-linux-binding
- test-wasi
steps:
- uses: actions/checkout@v7
- name: Setup node
uses: actions/setup-node@v7
with:
node-version: 24
cache: yarn
- name: Install latest npm cli
run: npm install -g npm@latest
- name: Install dependencies
run: yarn install
- name: create npm dirs
run: yarn napi create-npm-dirs
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
- name: Move artifacts
run: yarn artifacts
# `napi artifacts` deletes the committed index.js: the wasi loader metadata in
# snappy.wasi.cjs lists it as a managed root entry, and since package.json's
# main is main.js, artifacts treats index.js as stale. Restore it from git.
- name: Restore index.js
run: git checkout -- index.js
- name: List packages
run: ls -R ./npm
shell: bash
# npm pack silently skips missing entries of the `files` array; fail loudly instead
- name: Verify package files exist
run: |
node -e "
const fs = require('fs')
const missing = require('./package.json').files.filter((f) => !fs.existsSync(f))
if (missing.length) {
console.error('Files declared in package.json but missing on disk: ' + missing.join(', '))
process.exit(1)
}
"
- name: Publish
run: |
if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --access public
elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+";
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --tag next --access public
else
echo "Not a release, skipping publish"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}