Skip to content

fix: make set:html always escape HTML properly #50

fix: make set:html always escape HTML properly

fix: make set:html always escape HTML properly #50

Workflow file for this run

name: CI
env:
DEBUG: napi:*
APP_NAME: astro
MACOSX_DEPLOYMENT_TARGET: "10.13"
CARGO_INCREMENTAL: "1"
NAPI_PACKAGE_PATH: crates/astro_napi
permissions:
contents: read
on:
push:
branches: [main, next, feat/rust]
tags-ignore:
- "**"
paths-ignore:
- "**/*.md"
- LICENSE
- "**/*.gitignore"
- .editorconfig
- docs/**
pull_request:
branches: [main, next, feat/rust]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Cargo fmt
run: cargo fmt -- --check
- name: Clippy
run: cargo clippy -- -D warnings
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: latest
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Setup Biome
uses: biomejs/setup-biome@v2
- name: Biome lint
run: biome ci --diagnostic-level=warn
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: actions/cache@v5
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: rust-test-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Rust tests
run: cargo test
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: latest
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Build NAPI binding
run: pnpm run build:napi
- name: Test binding
run: pnpm test
working-directory: crates/astro_napi
build:
if: github.event_name != 'pull_request'
strategy:
fail-fast: false
matrix:
settings:
# -- macOS --
- host: macos-latest
target: x86_64-apple-darwin
build: pnpm run build --target x86_64-apple-darwin
- host: macos-latest
target: aarch64-apple-darwin
build: pnpm run build --target aarch64-apple-darwin
# -- Windows --
- host: windows-latest
target: x86_64-pc-windows-msvc
build: pnpm run build --target x86_64-pc-windows-msvc
- host: windows-latest
target: aarch64-pc-windows-msvc
build: pnpm run build --target aarch64-pc-windows-msvc
# -- Linux GNU --
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
build: pnpm run build --target x86_64-unknown-linux-gnu
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
build: pnpm run build --target aarch64-unknown-linux-gnu -x
# -- Linux musl --
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
build: pnpm run build --target x86_64-unknown-linux-musl -x
- host: ubuntu-latest
target: aarch64-unknown-linux-musl
build: pnpm run build --target aarch64-unknown-linux-musl -x
# -- WASM (fallback for all other platforms) --
- host: ubuntu-latest
target: wasm32-wasip1-threads
build: pnpm run build --target wasm32-wasip1-threads
name: Build - ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
defaults:
run:
working-directory: crates/astro_napi
steps:
- name: Enable long paths on Windows
if: runner.os == 'Windows'
run: git config --system core.longpaths true
working-directory: ${{ runner.temp }}
- uses: actions/checkout@v6
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: latest
cache: pnpm
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
- name: Ensure target is installed
run: rustup target add ${{ matrix.settings.target }}
- name: Cache cargo
uses: actions/cache@v5
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, 'linux') }}
with:
version: 0.15.2
- name: Install cargo-zigbuild
uses: taiki-e/install-action@v2
if: ${{ contains(matrix.settings.target, 'linux') }}
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tool: cargo-zigbuild
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
shell: bash
- name: Install dependencies
run: pnpm install
working-directory: .
- name: Build
run: ${{ matrix.settings.build }}
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v6
if: matrix.settings.target != 'wasm32-wasip1-threads'
with:
name: bindings-${{ matrix.settings.target }}
path: crates/astro_napi/${{ env.APP_NAME }}.*.node
if-no-files-found: error
- name: Upload artifact
uses: actions/upload-artifact@v6
if: matrix.settings.target == 'wasm32-wasip1-threads'
with:
name: bindings-${{ matrix.settings.target }}
path: crates/astro_napi/${{ env.APP_NAME }}.*.wasm
if-no-files-found: error
test-macOS-windows-binding:
name: Test - ${{ 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: macos-latest
target: aarch64-apple-darwin
architecture: arm64
- host: macos-latest
target: x86_64-apple-darwin
architecture: x64
node:
- "22"
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v6
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
cache: pnpm
architecture: ${{ matrix.settings.architecture }}
- name: Install dependencies
run: pnpm install
- name: Download artifacts
uses: actions/download-artifact@v7
with:
name: bindings-${{ matrix.settings.target }}
path: crates/astro_napi
- name: List packages
run: ls -R crates/astro_napi
shell: bash
- name: Test bindings
run: pnpm test
working-directory: crates/astro_napi
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
node:
- "22"
runs-on: ${{ contains(matrix.target, 'aarch64') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v6
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
cache: pnpm
- 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 {
console.log('PLATFORM=linux/amd64')
}
" >> $GITHUB_OUTPUT
node -e "
if ('${{ matrix.target }}'.endsWith('-musl')) {
console.log('IMAGE=node:${{ matrix.node }}-alpine')
} else {
console.log('IMAGE=node:${{ matrix.node }}-slim')
}
" >> $GITHUB_OUTPUT
echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
# use --force to download the all platform/arch dependencies
- name: Install dependencies
run: pnpm install --force
- name: Download artifacts
uses: actions/download-artifact@v7
with:
name: bindings-${{ matrix.target }}
path: crates/astro_napi
- name: List packages
run: ls -R crates/astro_napi
shell: bash
- name: Test bindings
run: |
docker run --rm \
--platform ${{ steps.docker.outputs.PLATFORM }} \
-v ${{ steps.docker.outputs.PNPM_STORE_PATH }}:${{ steps.docker.outputs.PNPM_STORE_PATH }} \
-v ${{ github.workspace }}:${{ github.workspace }} \
-w ${{ github.workspace }}/crates/astro_napi \
${{ steps.docker.outputs.IMAGE }} \
npm run test
test-wasi:
name: Test WASI target
needs:
- build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Download artifacts
uses: actions/download-artifact@v7
with:
name: bindings-wasm32-wasip1-threads
path: crates/astro_napi
- name: List packages
run: ls -R crates/astro_napi
shell: bash
- name: Test bindings
run: pnpm test
working-directory: crates/astro_napi
env:
NAPI_RS_FORCE_WASI: 1