Skip to content

Commit 235ea18

Browse files
refactor: simplify CI workflow and use NX for native builds
1 parent cd1061f commit 235ea18

File tree

2 files changed

+34
-123
lines changed

2 files changed

+34
-123
lines changed

.github/workflows/CI.yml

Lines changed: 33 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
name: 🚀 CI
1+
name: CI
22
env:
33
DEBUG: napi:*
4-
APP_NAME: cel-typescript
54
MACOSX_DEPLOYMENT_TARGET: '10.13'
5+
RUST_BACKTRACE: 1
66

77
on:
88
push:
@@ -14,120 +14,74 @@ on:
1414

1515
jobs:
1616
build:
17-
name: 🔨 Build - ${{ matrix.settings.target }} - node@18
17+
name: Build - ${{ matrix.target }}
1818
if: "!contains(github.event.head_commit.message, 'skip ci')"
1919
strategy:
2020
fail-fast: false
2121
matrix:
22-
settings:
23-
- host: macos-latest
24-
target: aarch64-apple-darwin
25-
build: |
26-
npm install
27-
npx @napi-rs/cli build --platform aarch64-apple-darwin
28-
echo "Binary after build:"
29-
ls -la *.node
30-
strip -x *.node
31-
echo "Binary after strip:"
32-
ls -la *.node
33-
runs-on: ${{ matrix.settings.host }}
22+
target: [aarch64-apple-darwin, x86_64-unknown-linux-gnu]
23+
include:
24+
- target: aarch64-apple-darwin
25+
os: macos-latest
26+
- target: x86_64-unknown-linux-gnu
27+
os: ubuntu-latest
28+
runs-on: ${{ matrix.os }}
3429

3530
steps:
3631
- uses: actions/checkout@v4
3732
with:
3833
submodules: recursive
3934
fetch-depth: 0
4035

41-
- name: Debug - List submodules
42-
run: |
43-
git submodule status
44-
ls -la
45-
ls -la cel-rust/
46-
ls -la cel-rust/interpreter/
47-
shell: bash
48-
4936
- name: Setup node
5037
uses: actions/setup-node@v4
51-
if: ${{ !matrix.settings.docker }}
5238
with:
5339
node-version: 18
54-
check-latest: true
5540
cache: npm
5641

57-
- name: Install
42+
- name: Install Rust
5843
uses: dtolnay/rust-toolchain@stable
59-
if: ${{ !matrix.settings.docker }}
6044
with:
61-
targets: ${{ matrix.settings.target }}
45+
toolchain: stable
46+
targets: ${{ matrix.target }}
47+
48+
- name: Cache NPM dependencies
49+
uses: actions/cache@v4
50+
with:
51+
path: node_modules
52+
key: npm-cache-${{ matrix.target }}-node@18-${{ hashFiles('package-lock.json') }}
6253

63-
- name: 💾 Cache cargo
54+
- name: Cache Rust dependencies
6455
uses: actions/cache@v4
6556
with:
6657
path: |
6758
~/.cargo/registry/index/
6859
~/.cargo/registry/cache/
6960
~/.cargo/git/db/
70-
.cargo-cache
7161
target/
72-
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
73-
74-
- uses: goto-bus-stop/setup-zig@v2
75-
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }}
76-
with:
77-
version: 0.11.0
78-
79-
- name: 🔧 Setup toolchain
80-
if: ${{ matrix.settings.docker }}
81-
uses: actions-rs/toolchain@v1
82-
with:
83-
toolchain: stable
84-
target: ${{ matrix.settings.target }}
85-
override: true
86-
87-
- name: Cache NPM dependencies
88-
uses: actions/cache@v4
89-
with:
90-
path: node_modules
91-
key: npm-cache-${{ matrix.settings.target }}-${{ hashFiles('package-lock.json') }}
62+
key: rust-cache-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
9263

9364
- name: Install dependencies
94-
run: npm ci
95-
96-
- name: 🐳 Build in docker
97-
uses: addnab/docker-run-action@v3
98-
if: ${{ matrix.settings.docker }}
99-
with:
100-
image: ${{ matrix.settings.docker }}
101-
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
102-
run: ${{ matrix.settings.build }}
103-
104-
- name: Build
105-
if: ${{ !matrix.settings.docker }}
106-
run: ${{ matrix.settings.build }}
65+
run: npm install
10766
shell: bash
10867

109-
- name: 🔍 Debug - List files after build
110-
run: |
111-
echo "Current directory:"
112-
pwd
113-
echo "\nFiles in current directory:"
114-
ls -la
115-
echo "\nNode files:"
116-
find . -name "*.node"
68+
- name: Build
69+
run: npx nx build:native -- --platform ${{ matrix.target }}
11770
shell: bash
11871

119-
- name: 📤 Upload artifact
72+
- name: Upload artifact
12073
uses: actions/upload-artifact@v4
12174
with:
122-
name: bindings-${{ matrix.settings.target }}
75+
name: bindings-${{ matrix.target }}
12376
path: |
124-
*.node
77+
**/*.node
78+
!node_modules/**/*.node
12579
!target/**/*.node
12680
if-no-files-found: error
12781
retention-days: 1
12882

12983
test:
130-
name: 🧪 Test ${{ matrix.platform.name }} - node@${{ matrix.node }}
84+
name: Test ${{ matrix.platform.name }} - node@${{ matrix.node }}
13185
needs:
13286
- build
13387
strategy:
@@ -171,59 +125,16 @@ jobs:
171125
${{ hashFiles('package-lock.json', '**/Cargo.lock') }}
172126
173127
- name: Install dependencies
174-
run: npm ci
175-
176-
- name: 🖥️ Setup QEMU
177-
if: matrix.platform.qemu
178-
uses: docker/setup-qemu-action@v3
179-
with:
180-
platforms: ${{ matrix.platform.qemu }}
181-
182-
- name: 📱 Install Android NDK
183-
if: matrix.platform.android
184-
run: |
185-
wget https://dl.google.com/android/repository/android-ndk-r25c-linux.zip
186-
unzip android-ndk-r25c-linux.zip
187-
echo "ANDROID_NDK_HOME=$PWD/android-ndk-r25c" >> $GITHUB_ENV
188-
189-
- name: 📥 Download artifacts
190128
uses: actions/download-artifact@v4
191129
with:
192-
name: bindings-${{ matrix.platform.target }}
193-
path: .
130+
name: bindings-${{ matrix.target }}
194131

195-
- name: List files
196-
run: ls -R .
197-
shell: bash
132+
- name: Install dependencies
133+
run: npm install
198134

199-
- name: Test bindings (native)
200-
if: "!matrix.platform.docker"
135+
- name: Test
201136
run: npm test
202137

203-
- name: Test bindings (Docker)
204-
if: matrix.platform.docker
205-
run: |
206-
docker run --rm ${{ matrix.platform.qemu && format('--platform linux/{0}', matrix.platform.qemu) || '' }} \
207-
-v $(pwd):/build -w /build node:${{ matrix.node }}-slim bash -c '
208-
# Install Rust
209-
apt-get update && apt-get install -y curl build-essential
210-
curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
211-
export PATH="/root/.cargo/bin:$PATH"
212-
213-
# Fix npm optional dependencies on ARM64
214-
if [[ "${{ matrix.platform.target }}" == *"aarch64"* ]]; then
215-
# Ensure clean state
216-
rm -rf node_modules
217-
# Install dependencies with --no-optional to skip problematic deps
218-
npm install --no-optional
219-
# Now install only the required optional deps
220-
npm install @rollup/rollup-linux-arm64-gnu
221-
fi
222-
223-
# Run tests
224-
npm test
225-
'
226-
227138
dry-run-publish:
228139
name: Dry Run Publish
229140
runs-on: ubuntu-latest

project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"build:native": {
66
"executor": "nx:run-commands",
77
"options": {
8-
"command": "npx @napi-rs/cli build --platform"
8+
"command": "npx @napi-rs/cli build --platform --release"
99
},
1010
"outputs": [
1111
"{workspaceRoot}/cel-typescript.darwin-arm64.node",

0 commit comments

Comments
 (0)