Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,40 @@ jobs:
rustup target add wasm32-unknown-unknown
cargo check --target wasm32-unknown-unknown

wasi:
name: Test wasi target
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust Toolchain
uses: ./.github/actions/rustup
with:
shared-key: 'wasi'
save-cache: ${{ github.ref_name == 'main' }}

- name: corepack
run: corepack enable

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: |
rustup target add wasm32-wasi-preview1-threads
pnpm build --target wasm32-wasi-preview1-threads

- name: Test
run: pnpm test
env:
WASI_TEST: 1

typos:
name: Spell Check
runs-on: ubuntu-latest
Expand Down
178 changes: 102 additions & 76 deletions .github/workflows/release_napi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
paths:
- npm/package.json # Please only commit this file, so we don't need to wait for test CI to pass.

env:
DEBUG: 'napi:*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand Down Expand Up @@ -48,79 +51,121 @@ jobs:
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
code-target: win32-x64-msvc

- os: windows-latest
target: aarch64-pc-windows-msvc
code-target: win32-arm64-msvc

- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
code-target: linux-x64-gnu

- os: ubuntu-latest
target: x86_64-unknown-linux-musl

- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
code-target: linux-arm64-gnu

- os: ubuntu-latest
target: aarch64-unknown-linux-musl

- os: ubuntu-latest
target: armv7-unknown-linux-gnueabihf

- os: macos-latest
target: x86_64-apple-darwin
code-target: darwin-x64

- os: macos-latest
target: aarch64-apple-darwin
code-target: darwin-arm64

- os: ubuntu-latest
target: wasm32-wasi-preview1-threads

name: Package ${{ matrix.target }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Install cross
uses: taiki-e/install-action@cross
- name: corepack
run: corepack enable

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Add Rust Target
run: rustup target add ${{ matrix.target }}

- name: Build with cross
working-directory: napi
run: cross build --release --target=${{ matrix.target }}
- uses: goto-bus-stop/setup-zig@v2
if: ${{ contains(matrix.target, 'musl') }}
with:
version: 0.11.0

- name: Move file on ${{ matrix.os }}
shell: bash
run: |
shopt -s extglob
ls napi/target/${{ matrix.target }}/release/*.@(so|dll|dylib)
mv napi/target/${{ matrix.target }}/release/*.@(so|dll|dylib) napi/resolver.${{ matrix.code-target }}.node
ls napi
- name: Build with zig cross
if: ${{ contains(matrix.target, 'musl') }}
run: pnpm build -x --target ${{ matrix.target }}

- name: Test
working-directory: napi
if: ${{ contains(matrix.target, 'x86') }} # Need docker for aarch64
run: |
ls
node test.mjs
- name: Build with napi cross
if: ${{ contains(matrix.target, 'gnu') }}
run: pnpm build --use-napi-cross --target ${{ matrix.target }}

# The binary is zipped to fix permission loss https://github.com/actions/upload-artifact#permission-loss
- name: Archive Binary
if: runner.os == 'Windows'
shell: bash
run: 7z a ${{ matrix.code-target }}.zip napi/resolver.${{ matrix.code-target }}.node
- name: Build
if: ${{ !contains(matrix.target, 'gnu') && !contains(matrix.target, 'musl') }}
run: pnpm build --target ${{ matrix.target }}

# The binary is zipped to fix permission loss https://github.com/actions/upload-artifact#permission-loss
- name: Archive Binary
if: runner.os != 'Windows'
shell: bash
run: tar czf ${{ matrix.code-target }}.tar.gz napi/resolver.${{ matrix.code-target }}.node
- name: Test
if: matrix.target == 'x86_64-pc-windows-msvc' || matrix.target == 'x86_64-apple-darwin' || matrix.target == 'wasm32-wasi-preview1-threads'
run: pnpm test

- name: Upload artifact
- name: Output docker params
if: ${{ contains(matrix.target, 'linux') }}
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:lts-alpine')
} else {
console.log('IMAGE=node:lts-slim')
}
" >> $GITHUB_OUTPUT
echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
if: ${{ contains(matrix.target, 'linux') }}
with:
platforms: all
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
if: ${{ contains(matrix.target, 'linux') }}
- name: Run linux test
uses: addnab/docker-run-action@v3
if: ${{ contains(matrix.target, 'linux') }}
with:
image: ${{ steps.docker.outputs.IMAGE }}
options: -v ${{ steps.docker.outputs.PNPM_STORE_PATH }}:${{ steps.docker.outputs.PNPM_STORE_PATH }} -v ${{ github.workspace }}:/oxc_resolver -w /oxc_resolver --platform ${{ steps.docker.outputs.PLATFORM }}
run: |
corepack enable
pnpm test

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: binaries-${{ matrix.code-target }}
name: bindings-${{ matrix.target }}
path: |
*.zip
*.tar.gz

napi/*.node
napi/*.wasm
publish:
name: Publish NAPI
runs-on: ubuntu-latest
Expand All @@ -132,54 +177,35 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install Node.js
- name: corepack
run: corepack enable

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
node-version: 20
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Download Artifacts
uses: actions/download-artifact@v4

- name: Move download artifacts from directories to root
shell: bash
run: |
mv binaries-*/*.zip .
mv binaries-*/*.gz .

- name: Unzip
uses: montudor/action-zip@v1
with:
args: unzip -qq *.zip -d .

- name: Untar
shell: bash
run: ls *.gz | xargs -i tar xvf {}
path: artifacts

- name: Generate npm packages
shell: bash
- name: Prepare dirs and artifacts
run: |
ls
ls napi
node npm/scripts/generate-packages.mjs
cat npm/package.json
for package in npm/oxc-resolver*
do
ls $package
cat $package/package.json
echo '----'
done
pnpm napi create-npm-dirs --package-json-path npm/package.json
pnpm napi artifacts --package-json-path npm/package.json --build-output-dir napi

- name: Publish npm packages as latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
shell: bash
# NOTE: The trailing slash on $package/ changes it to publishing the directory
run: |
# publish subpackages first
for package in npm/oxc-resolver-*
do
npm publish $package/ --tag latest --provenance --access public
done
# publish root package last
cp napi/index.js npm/index.js
cp napi/index.d.ts npm/index.d.ts
cp napi/browser.js npm/browser.js
pnpm napi pre-publish -t npm --package-json-path npm/package.json
npm publish npm/ --tag latest --provenance --access public
Loading