Skip to content

Commit

Permalink
Update CI pipeline
Browse files Browse the repository at this point in the history
Update the docker for build ci

Update the docker image

Remove docker from musl build

Remove docker from musl build

Update build command

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Add a package to docker container

Revert CI to use the docker based build

Fix a typo

Fix a typo

Fix cargo config

Enable cross compile build

Update the config

Add debug flag

Add multilib package

Add multilib package

Add multilib package

Refactor CI pipeline

Refactor CI pipeline

Update dependencies

Add rustup support

Add rustup support

Add musl target

Debug stdlib file

Search for multilib packages

Add old multilib packages

Add cargo flag

Add libclang-dev

Add libclang-dev

Update the cargo tasks

Update the build script

Run CI without cache

Use required packages

Use latest napi for cross compile

Use latest napi for cross compile

Update CI pipeline
  • Loading branch information
nazarhussain committed Oct 7, 2024
1 parent b1ff58f commit 428116d
Show file tree
Hide file tree
Showing 6 changed files with 1,218 additions and 379 deletions.
4 changes: 1 addition & 3 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-gcc"
rustflags = ["-C", "target-feature=-crt-static"]

140 changes: 60 additions & 80 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ name: CI
env:
DEBUG: napi:*
APP_NAME: xdelta3-node
MACOSX_DEPLOYMENT_TARGET: '10.13'
RUST_BACKTRACE: full
permissions:
contents: write
id-token: write
'on':
"on":
push:
branches:
- main
tags-ignore:
- '**'
- "**"
paths-ignore:
- '**/*.md'
- "**/*.md"
- LICENSE
- '**/*.gitignore'
- "**/*.gitignore"
- .editorconfig
- docs/**
pull_request: null
Expand All @@ -24,92 +24,72 @@ jobs:
strategy:
fail-fast: false
matrix:
settings:
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: yarn build --target x86_64-unknown-linux-musl
- host: macos-latest
target: aarch64-apple-darwin
build: yarn build --target aarch64-apple-darwin
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
build: yarn build --target aarch64-unknown-linux-gnu
- host: ubuntu-latest
target: aarch64-unknown-linux-musl
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: |-
set -e &&
rustup target add aarch64-unknown-linux-musl &&
yarn build --target aarch64-unknown-linux-musl
- host: windows-latest
target: aarch64-pc-windows-msvc
build: yarn build --target aarch64-pc-windows-msvc
name: stable - ${{ matrix.settings.target }} - node@20
runs-on: ${{ matrix.settings.host }}
targets:
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- x86_64-pc-windows-msvc
- aarch64-pc-windows-msvc
runs-on: ubuntu-latest
name: Build - ${{ matrix.targets }}
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
if: ${{ !matrix.settings.docker }}
- name: Cache cargo registry
uses: actions/cache@v4
with:
node-version: 20
cache: yarn
- name: Install
path: |
~/.cargo
${{ github.workspace }}/.xwin
~/.napi-rs
./target
key: ${{ matrix.targets }}-cargo-cache
- name: Install Rust Tool Chain
uses: dtolnay/rust-toolchain@stable
if: ${{ !matrix.settings.docker }}
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
- name: Cache cargo
uses: actions/cache@v4
targets: ${{ matrix.targets }}
- name: Install NodeJS
uses: actions/setup-node@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
target/
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
- uses: goto-bus-stop/setup-zig@v2
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' || matrix.settings.target == 'armv7-unknown-linux-musleabihf' }}
node-version: "20"
cache: "yarn"
- name: Install ziglang
uses: mlugg/setup-zig@v1
with:
version: 0.13.0
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
shell: bash
- name: Setup node x86
if: matrix.settings.target == 'i686-pc-windows-msvc'
run: yarn config set supportedArchitectures.cpu "ia32"
- name: Install packages
run: sudo apt install libclang-dev llvm
shell: bash
- name: Install dependencies
run: yarn install
- name: Setup node x86
uses: actions/setup-node@v4
if: matrix.settings.target == 'i686-pc-windows-msvc'
- name: Install cargo toolchains for windows
if: ${{ contains(matrix.targets, 'msvc') }}
uses: taiki-e/install-action@v2
env:
GITHUB_TOKEN: ${{ github.token }}
with:
node-version: 20
cache: yarn
architecture: x86
- name: Build in docker
uses: addnab/docker-run-action@v3
if: ${{ matrix.settings.docker }}
tool: cargo-xwin
- name: Install cargo toolchains for linux/unix
if: ${{ !contains(matrix.targets, 'msvc') }}
uses: taiki-e/install-action@v2
env:
GITHUB_TOKEN: ${{ github.token }}
with:
image: ${{ matrix.settings.docker }}
options: '--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build'
run: ${{ matrix.settings.build }}
- name: Build
run: ${{ matrix.settings.build }}
if: ${{ !matrix.settings.docker }}
tool: cargo-zigbuild
- name: Install rupstup target
run: rustup target add ${{ matrix.targets }}
shell: bash
- run: yarn install
- name: Build
run: yarn build --target ${{ matrix.targets }} --cross-compile
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
name: bindings-${{ matrix.targets }}
path: ${{ env.APP_NAME }}.*.node
if-no-files-found: error

test-linux-x64-musl-binding:
name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }}
needs:
Expand All @@ -118,8 +98,8 @@ jobs:
fail-fast: false
matrix:
node:
- '18'
- '20'
- "18"
- "20"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -150,8 +130,8 @@ jobs:
fail-fast: false
matrix:
node:
- '18'
- '20'
- "18"
- "20"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -177,13 +157,13 @@ jobs:
uses: addnab/docker-run-action@v3
with:
image: node:${{ matrix.node }}-slim
options: '--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build'
options: "--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build"
run: |
set -e
yarn test
ls -la
test-linux-aarch64-musl-binding:
name: Test bindings on aarch64-unknown-linux-musl - node@${{ matrix.node }}
name: Test bindings on aarch64-unknown-linux-musl - node@20
needs:
- build
runs-on: ubuntu-latest
Expand Down Expand Up @@ -211,7 +191,7 @@ jobs:
uses: addnab/docker-run-action@v3
with:
image: node:lts-alpine
options: '--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build'
options: "--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build"
run: |
set -e
yarn test
Expand Down
10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ crate-type = ["cdylib"]

[dependencies]
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
napi = { version = "2.12.2", default-features = false, features = ["napi4"] }
napi-derive = "2.12.2"
xdelta3 = { git = "https://github.com:/nazarhussain/xdelta3-rs.git", branch = "nh/update-build-script", default-features = false}
napi = { version = "2", default-features = false, features = ["napi4"] }
napi-derive = "2"
futures-io = "0.3"
futures-util = { version = "0.3", default-features = false, features = ["default", "io"] }
xdelta3 = { git = "https://github.com:/nazarhussain/xdelta3-rs.git", branch = "nh/update-build-script" }

[build-dependencies]
napi-build = "2.0.1"
napi-build = "2"

[profile.release]
lto = true
Expand Down
Loading

0 comments on commit 428116d

Please sign in to comment.