Skip to content

Commit c81c1fb

Browse files
committed
ci: restructure CI workflows (#208)
1 parent 19b27bb commit c81c1fb

5 files changed

Lines changed: 300 additions & 254 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Debug action
2+
3+
description: Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)
4+
5+
runs:
6+
using: composite
7+
steps:
8+
- name: Debug
9+
uses: mxschmitt/action-tmate@c0afd6f790e3a5564914980036ebf83216678101 # v3.23
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Setup target CI
2+
description: Prepare toolchains and dependencies for target-specific CI jobs
3+
4+
inputs:
5+
target:
6+
description: Target identifier for cache keys and logging
7+
required: true
8+
node-version:
9+
description: Node.js version
10+
required: false
11+
default: '24.11.1'
12+
em-version:
13+
description: Emscripten version
14+
required: false
15+
default: '5.0.3'
16+
em-cache-folder:
17+
description: Emscripten cache folder
18+
required: false
19+
default: 'emsdk-cache'
20+
wasi-version:
21+
description: WASI SDK version
22+
required: false
23+
default: '29'
24+
wasi-version-full:
25+
description: Full WASI SDK version
26+
required: false
27+
default: '29.0'
28+
wasi-sdk-path:
29+
description: WASI SDK install path
30+
required: false
31+
default: './wasi-sdk-29.0'
32+
needs-emscripten:
33+
description: Whether Emscripten is needed
34+
required: false
35+
default: 'false'
36+
needs-wasi-sdk:
37+
description: Whether WASI SDK is needed
38+
required: false
39+
default: 'false'
40+
41+
runs:
42+
using: composite
43+
steps:
44+
- name: Export CI environment
45+
shell: bash
46+
run: |
47+
echo "WASI_VERSION=${{ inputs.wasi-version }}" >> "$GITHUB_ENV"
48+
echo "WASI_VERSION_FULL=${{ inputs.wasi-version-full }}" >> "$GITHUB_ENV"
49+
echo "WASI_SDK_PATH=${{ inputs.wasi-sdk-path }}" >> "$GITHUB_ENV"
50+
echo "EM_CACHE_FOLDER=${{ inputs.em-cache-folder }}" >> "$GITHUB_ENV"
51+
echo "EM_VERSION=${{ inputs.em-version }}" >> "$GITHUB_ENV"
52+
echo "CI_TARGET=${{ inputs.target }}" >> "$GITHUB_ENV"
53+
- name: Install Ninja
54+
shell: bash
55+
run: |
56+
sudo apt-get update
57+
sudo apt-get install ninja-build
58+
- name: Setup Emscripten cache
59+
if: ${{ inputs.needs-emscripten == 'true' }}
60+
uses: actions/cache@v5
61+
with:
62+
path: ${{ inputs.em-cache-folder }}
63+
key: ${{ inputs.em-version }}-${{ runner.os }}-${{ inputs.target }}
64+
- name: Setup Emscripten
65+
if: ${{ inputs.needs-emscripten == 'true' }}
66+
uses: emscripten-core/setup-emsdk@v16
67+
with:
68+
version: ${{ inputs.em-version }}
69+
actions-cache-folder: ${{ inputs.em-cache-folder }}
70+
- name: Install wasi-sdk
71+
if: ${{ inputs.needs-wasi-sdk == 'true' }}
72+
shell: bash
73+
run: |
74+
wget -q https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${{ inputs.wasi-version }}/wasi-sdk-${{ inputs.wasi-version-full }}-x86_64-linux.tar.gz
75+
mkdir -p ${{ inputs.wasi-sdk-path }}
76+
tar zxvf wasi-sdk-${{ inputs.wasi-version-full }}-x86_64-linux.tar.gz -C ${{ inputs.wasi-sdk-path }} --strip 1
77+
- name: Setup Node.js
78+
uses: actions/setup-node@v6
79+
with:
80+
node-version: ${{ inputs.node-version }}
81+
registry-url: 'https://registry.npmjs.org'
82+
- name: NPM Install
83+
shell: bash
84+
run: |
85+
npm install -g node-gyp
86+
npm install --ignore-scripts

.github/workflows/ci.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '**/*.md'
7+
- '**/docs/**'
8+
branches:
9+
- main
10+
- test-*
11+
pull_request:
12+
paths-ignore:
13+
- '**/*.md'
14+
- '**/docs/**'
15+
16+
permissions:
17+
id-token: write
18+
contents: write
19+
20+
jobs:
21+
wasm32-unknown-emscripten:
22+
timeout-minutes: 15
23+
name: CI wasm32-unknown-emscripten
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- uses: actions/checkout@v6
28+
- uses: ./.github/actions/setup-target-ci
29+
with:
30+
target: 'wasm32-unknown-emscripten'
31+
needs-emscripten: 'true'
32+
- name: NPM Build
33+
run: npm run build --workspaces --if-present
34+
- name: Build target
35+
run: npm run rebuild -w packages/test
36+
- name: Test Emscripten ESM library
37+
run: npm run test -w packages/ts-transform-emscripten-esm-library
38+
- name: Test building Node-API versions
39+
run: npm run test:version
40+
- name: Test target
41+
run: npm run test -w packages/test
42+
timeout-minutes: 3
43+
- name: Test target (4GB)
44+
run: EMNAPI_TEST_4GB=1 npm run test -w packages/test
45+
timeout-minutes: 3
46+
47+
wasm64-unknown-emscripten:
48+
timeout-minutes: 15
49+
name: CI wasm64-unknown-emscripten
50+
runs-on: ubuntu-latest
51+
52+
steps:
53+
- uses: actions/checkout@v6
54+
- uses: ./.github/actions/setup-target-ci
55+
with:
56+
target: 'wasm64-unknown-emscripten'
57+
needs-emscripten: 'true'
58+
- name: NPM Build
59+
run: npm run build --workspaces --if-present
60+
- name: Build target
61+
run: MEMORY64=1 node ./packages/test/script/build-emscripten.js Debug
62+
- name: Test target
63+
run: MEMORY64=1 UV_THREADPOOL_SIZE=2 NODE_TEST_KNOWN_GLOBALS=0 node ./packages/test/script/test.js
64+
timeout-minutes: 3
65+
- name: Test target (4GB)
66+
run: MEMORY64=1 EMNAPI_TEST_4GB=1 UV_THREADPOOL_SIZE=2 NODE_TEST_KNOWN_GLOBALS=0 node ./packages/test/script/test.js
67+
timeout-minutes: 3
68+
69+
wasm32-wasip1-threads:
70+
timeout-minutes: 15
71+
name: CI wasm32-wasip1-threads
72+
runs-on: ubuntu-latest
73+
74+
steps:
75+
- uses: actions/checkout@v6
76+
- uses: ./.github/actions/setup-target-ci
77+
with:
78+
target: 'wasm32-wasip1-threads'
79+
needs-wasi-sdk: 'true'
80+
- name: NPM Build
81+
run: npm run build --workspaces --if-present
82+
- name: Build target
83+
run: npm run rebuild:wt -w packages/test
84+
- name: Test @emnapi/wasi-threads
85+
run: |
86+
node ./packages/wasi-threads/test/build.js
87+
npm run test -w packages/wasi-threads
88+
timeout-minutes: 1
89+
- name: Test target
90+
run: npm run test:wt -w packages/test
91+
timeout-minutes: 3
92+
- name: Test target (4GB)
93+
run: EMNAPI_TEST_4GB=1 npm run test:wt -w packages/test
94+
timeout-minutes: 3
95+
96+
wasm32-wasip1:
97+
timeout-minutes: 15
98+
name: CI wasm32-wasip1
99+
runs-on: ubuntu-latest
100+
101+
steps:
102+
- uses: actions/checkout@v6
103+
- uses: ./.github/actions/setup-target-ci
104+
with:
105+
target: 'wasm32-wasip1'
106+
needs-wasi-sdk: 'true'
107+
- name: NPM Build
108+
run: npm run build --workspaces --if-present
109+
- name: Build target
110+
run: npm run rebuild:w -w packages/test
111+
- name: Test target
112+
run: npm run test:w -w packages/test
113+
- name: Test target (4GB)
114+
run: EMNAPI_TEST_4GB=1 npm run test:w -w packages/test
115+
116+
wasm32-unknown-unknown:
117+
timeout-minutes: 15
118+
name: CI wasm32-unknown-unknown
119+
runs-on: ubuntu-latest
120+
121+
steps:
122+
- uses: actions/checkout@v6
123+
- uses: ./.github/actions/setup-target-ci
124+
with:
125+
target: 'wasm32-unknown-unknown'
126+
needs-wasi-sdk: 'true'
127+
- name: NPM Build
128+
run: npm run build --workspaces --if-present
129+
- name: Build target
130+
run: npm run rebuild:wasm32 -w packages/test
131+
- name: Test target
132+
run: npm run test:wasm32 -w packages/test
133+
- name: Test target (4GB)
134+
run: EMNAPI_TEST_4GB=1 npm run test:wasm32 -w packages/test

.github/workflows/debug.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Debug
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
id-token: write
8+
contents: write
9+
10+
jobs:
11+
debug:
12+
name: Debug with tmate
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v6
17+
- uses: ./.github/actions/setup-target-ci
18+
with:
19+
target: 'debug'
20+
needs-emscripten: 'true'
21+
needs-wasi-sdk: 'true'
22+
- name: NPM Build
23+
run: npm run build --workspaces --if-present
24+
- name: Setup tmate session
25+
uses: ./.github/actions/debugger
26+
if: ${{ github.event_name == 'workflow_dispatch' }}

0 commit comments

Comments
 (0)