Skip to content

Commit ace3043

Browse files
ci: optimize workflow\n\n- Combine all test jobs into single matrix\n- Better caching strategy for npm and cargo\n- Conditional steps based on platform\n- Ensure publish has all required artifacts
1 parent 551ce35 commit ace3043

File tree

1 file changed

+68
-84
lines changed

1 file changed

+68
-84
lines changed

.github/workflows/CI.yml

Lines changed: 68 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -167,129 +167,113 @@ jobs:
167167
if-no-files-found: error
168168
retention-days: 1
169169

170-
test-macOS-windows-binding:
171-
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
170+
test:
171+
name: Test ${{ matrix.platform.name }} - node@${{ matrix.node }}
172172
needs:
173173
- build
174174
strategy:
175175
fail-fast: false
176176
matrix:
177-
settings:
178-
- host: macos-latest
177+
node: ['18', '20']
178+
platform:
179+
# Native platforms (run directly)
180+
- name: macOS x64
181+
runner: macos-latest
179182
target: x86_64-apple-darwin
180-
- host: windows-latest
183+
docker: false
184+
- name: Windows x64
185+
runner: windows-latest
181186
target: x86_64-pc-windows-msvc
182-
node:
183-
- '18'
184-
- '20'
185-
runs-on: ${{ matrix.settings.host }}
187+
docker: false
188+
# Linux platforms (run in Docker)
189+
- name: Linux x64
190+
runner: ubuntu-latest
191+
target: x86_64-unknown-linux-gnu
192+
docker: true
193+
- name: Linux ARM64
194+
runner: ubuntu-latest
195+
target: aarch64-unknown-linux-gnu
196+
docker: true
197+
qemu: arm64
198+
# Android platforms
199+
- name: Android ARM64
200+
runner: ubuntu-latest
201+
target: aarch64-linux-android
202+
android: true
203+
- name: Android ARM v7
204+
runner: ubuntu-latest
205+
target: armv7-linux-androideabi
206+
android: true
207+
runs-on: ${{ matrix.platform.runner }}
186208

187209
steps:
188210
- uses: actions/checkout@v4
189211
with:
190212
submodules: recursive
191213
fetch-depth: 0
192214

193-
- name: Debug - List submodules
194-
run: |
195-
git submodule status
196-
ls -la
197-
ls -la cel-rust/
198-
ls -la cel-rust/interpreter/
199-
shell: bash
200-
201215
- name: Setup node
202216
uses: actions/setup-node@v4
203217
with:
204218
node-version: ${{ matrix.node }}
205219
check-latest: true
206220
cache: npm
207221

208-
- name: Cache NPM dependencies
222+
- name: Cache dependencies
209223
uses: actions/cache@v4
210224
with:
211-
path: node_modules
212-
key: npm-cache-test-${{ matrix.settings.target }}-${{ hashFiles('package-lock.json') }}
225+
path: |
226+
node_modules
227+
~/.cargo/registry/index/
228+
~/.cargo/registry/cache/
229+
~/.cargo/git/db/
230+
.cargo-cache
231+
target/
232+
key: deps-${{ matrix.platform.target }}-${{ matrix.node }}-${{ hashFiles('package-lock.json', '**/Cargo.lock') }}
213233

214234
- name: Install dependencies
215235
run: npm ci
216236

217-
- name: Download artifacts
218-
uses: actions/download-artifact@v4
237+
- name: Setup QEMU
238+
if: matrix.platform.qemu
239+
uses: docker/setup-qemu-action@v3
219240
with:
220-
name: bindings-${{ matrix.settings.target }}
221-
path: .
241+
platforms: ${{ matrix.platform.qemu }}
222242

223-
- name: List packages
224-
run: ls -R .
225-
shell: bash
226-
227-
- name: Test bindings
228-
run: npm test
229-
230-
test-linux-x64-gnu-binding:
231-
name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }}
232-
needs:
233-
- build
234-
strategy:
235-
fail-fast: false
236-
matrix:
237-
node:
238-
- '18'
239-
- '20'
240-
runs-on: ubuntu-latest
241-
242-
steps:
243-
- uses: actions/checkout@v4
244-
with:
245-
submodules: recursive
246-
fetch-depth: 0
247-
248-
- name: Debug - List submodules
243+
- name: Install Android NDK
244+
if: matrix.platform.android
249245
run: |
250-
git submodule status
251-
ls -la
252-
ls -la cel-rust/
253-
ls -la cel-rust/interpreter/
254-
shell: bash
255-
256-
- name: Setup node
257-
uses: actions/setup-node@v4
258-
with:
259-
node-version: ${{ matrix.node }}
260-
check-latest: true
261-
cache: npm
262-
263-
- name: Cache NPM dependencies
264-
uses: actions/cache@v4
265-
with:
266-
path: node_modules
267-
key: npm-cache-test-linux-x64-gnu-${{ hashFiles('package-lock.json') }}
268-
269-
- name: Install dependencies
270-
run: npm ci
246+
wget https://dl.google.com/android/repository/android-ndk-r25c-linux.zip
247+
unzip android-ndk-r25c-linux.zip
248+
echo "ANDROID_NDK_HOME=$PWD/android-ndk-r25c" >> $GITHUB_ENV
271249
272250
- name: Download artifacts
273251
uses: actions/download-artifact@v4
274252
with:
275-
name: bindings-x86_64-unknown-linux-gnu
253+
name: bindings-${{ matrix.platform.target }}
276254
path: .
277255

278-
- name: List packages
256+
- name: List files
279257
run: ls -R .
280258
shell: bash
281259

282-
- name: Test bindings
260+
- name: Test bindings (native)
261+
if: "!matrix.platform.docker"
262+
run: npm test
263+
264+
- name: Test bindings (Docker)
265+
if: matrix.platform.docker
283266
run: |
284-
docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-slim bash -c '
285-
# Install Rust
286-
apt-get update && apt-get install -y curl build-essential
287-
curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
288-
export PATH="/root/.cargo/bin:$PATH"
267+
docker run --rm ${{ matrix.platform.qemu && format('--platform linux/{0}', matrix.platform.qemu) || '' }} \
268+
-v $(pwd):/build -w /build node:${{ matrix.node }}-slim bash -c '
269+
# Install Rust
270+
apt-get update && apt-get install -y curl build-essential
271+
curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
272+
export PATH="/root/.cargo/bin:$PATH"
289273
290-
# Run tests
291-
npm test
292-
'
274+
# Run tests
275+
npm test
276+
'
293277
294278
publish:
295279
name: Publish
@@ -299,8 +283,8 @@ jobs:
299283
id-token: write
300284
if: startsWith(github.ref, 'refs/tags/v')
301285
needs:
302-
- test-macOS-windows-binding
303-
- test-linux-x64-gnu-binding
286+
- build
287+
- test
304288

305289
steps:
306290
- uses: actions/checkout@v4

0 commit comments

Comments
 (0)