-
-
Notifications
You must be signed in to change notification settings - Fork 6
227 lines (199 loc) · 6.27 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
name: Build
on:
push:
paths-ignore:
- '**/*.md'
- '**/docs/**'
branches:
- main
- test-*
tags:
- v*
- wasi-threads-v*
pull_request:
paths-ignore:
- '**/*.md'
- '**/docs/**'
workflow_dispatch:
env:
WASI_VERSION: '22'
WASI_VERSION_FULL: '22.0'
WASI_SDK_PATH: './wasi-sdk-22.0'
EM_VERSION: '3.1.52'
EM_CACHE_FOLDER: 'emsdk-cache'
jobs:
build:
timeout-minutes: 15
name: Build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- 'wasm32-unknown-emscripten'
- 'wasm64-unknown-emscripten'
- 'wasm32-unknown-unknown'
- 'wasm32-wasi'
- 'wasm32-wasi-threads'
steps:
- uses: actions/checkout@v4
- name: Install Ninja
run: |
sudo apt-get update
sudo apt-get install ninja-build
- name: Setup Emscripten cache
if: ${{ contains(matrix.target, 'emscripten') }}
id: cache-system-libraries
uses: actions/cache@v3
with:
path: ${{env.EM_CACHE_FOLDER}}
key: ${{env.EM_VERSION}}-${{ runner.os }}-${{ matrix.target }}
- uses: mymindstorm/setup-emsdk@v14
if: ${{ contains(matrix.target, 'emscripten') }}
with:
version: ${{ env.EM_VERSION }}
# no-cache: true
actions-cache-folder: ${{ env.EM_CACHE_FOLDER }}
# - uses: actions-rs/toolchain@v1
# if: ${{ matrix.target == 'wasm32-unknown-unknown' || matrix.target == 'wasm32-wasi' }}
# with:
# toolchain: nightly
# default: true
# target: ${{ matrix.target }}
- name: Install wasi-sdk
if: ${{ matrix.target == 'wasm32-unknown-unknown' || matrix.target == 'wasm32-wasi' || matrix.target == 'wasm32-wasi-threads' }}
shell: bash
run: |
wget -q https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz
mkdir -p $WASI_SDK_PATH
tar zxvf wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz -C $WASI_SDK_PATH --strip 1
- uses: actions/setup-node@v3
with:
node-version: '20.9.0'
registry-url: 'https://registry.npmjs.org'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: NPM Install
shell: bash
run: |
npm install -g node-gyp
npm install --ignore-scripts
- name: NPM Build
shell: bash
run: npm run build --workspaces --if-present
- name: Test Emscripten ESM library
shell: bash
run: npm run test -w packages/ts-transform-emscripten-esm-library
- name: Test @emnapi/wasi-threads
if: ${{ matrix.target == 'wasm32-wasi-threads' }}
shell: bash
run: |
node ./packages/wasi-threads/test/build.js
npm run test -w packages/wasi-threads
timeout-minutes: 1
# - name: Lint
# run: npm run lint
- name: Test wasm32-wasi-threads
if: ${{ matrix.target == 'wasm32-wasi-threads' }}
run: |
npm run rebuild:wt -w packages/test
npm run test:wt -w packages/test
- name: Test wasm32-unknown-emscripten
if: ${{ matrix.target == 'wasm32-unknown-emscripten' }}
run: |
npm run test:version
npm run rebuild -w packages/test
npm run test -w packages/test
- name: Test wasm64-unknown-emscripten
if: ${{ matrix.target == 'wasm64-unknown-emscripten' }}
env:
MEMORY64: '1'
UV_THREADPOOL_SIZE: '2'
NODE_TEST_KNOWN_GLOBALS: '0'
run: |
node ./packages/test/script/build-emscripten.js Debug
node ./packages/test/script/test.js
- name: Test wasm32-wasi
if: ${{ matrix.target == 'wasm32-wasi' }}
run: |
npm run rebuild:w -w packages/test
npm run test:w -w packages/test
- name: Test wasm32-unknown-unknown
if: ${{ matrix.target == 'wasm32-unknown-unknown' }}
run: |
npm run rebuild:wasm32 -w packages/test
npm run test:wasm32 -w packages/test
release:
name: Release
if: ${{ startsWith(github.event.ref, 'refs/tags/v') }}
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Ninja
run: |
sudo apt-get update
sudo apt-get install ninja-build
- uses: mymindstorm/setup-emsdk@v14
with:
version: ${{ env.EM_VERSION }}
# no-cache: true
actions-cache-folder: ${{ env.EM_CACHE_FOLDER }}
- name: Install wasi-sdk
shell: bash
run: |
wget -q https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz
mkdir -p $WASI_SDK_PATH
tar zxvf wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz -C $WASI_SDK_PATH --strip 1
- uses: actions/setup-node@v3
with:
node-version: '20.9.0'
registry-url: 'https://registry.npmjs.org'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: NPM Install
shell: bash
run: |
npm install -g node-gyp
npm install --ignore-scripts
- name: NPM Build
shell: bash
run: npm run build --workspaces --if-present
- name: Publish
run: |
node ./script/release.js
npm publish --ignore-scripts -w packages/runtime -w packages/node -w packages/emnapi -w packages/core
- name: Create release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
draft: true
prerelease: false
generate_release_notes: true
files: ./script/emnapi.zip
release-wasi-threads:
name: Release
if: ${{ startsWith(github.event.ref, 'refs/tags/wasi-threads-v') }}
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '20.9.0'
registry-url: 'https://registry.npmjs.org'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: NPM Install
shell: bash
run: |
npm install -g node-gyp
npm install --ignore-scripts
- name: NPM Build
shell: bash
run: npm run build -w packages/wasi-threads
- name: Publish
run: npm publish --ignore-scripts -w packages/wasi-threads