-
Notifications
You must be signed in to change notification settings - Fork 22
330 lines (296 loc) · 12.2 KB
/
test-cross-use.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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
name: test-cross-use
on:
workflow_dispatch:
inputs:
version:
description: '核心版本号'
required: true
default: '7.0.2'
dryRun:
description: '测试写这个为 true'
required: true
default: 'false'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
base:
name: Test - ${{ matrix.platform.os-name }}
strategy:
fail-fast: false
matrix:
platform:
- os-name: x86_64-unknown-linux-gnu
runs-on: ubuntu-24.04
target: x86_64-unknown-linux-gnu
- os-name: Windows-x86_64-msvc
runs-on: windows-latest
target: x86_64-pc-windows-msvc
- os-name: macOS-x86_64
runs-on: macos-13
target: x86_64-apple-darwin
- os-name: macOS-aarch64
runs-on: macOS-latest
target: aarch64-apple-darwin
- os-name: wasm32-wasip1
runs-on: macOS-latest
target: wasm32-wasip1
# more targets here ...
env:
TZ: Asia/Shanghai
runs-on: ${{ matrix.platform.runs-on }}
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- name: Create index.mjs file Linux
if: ${{ runner.os != 'Windows' }}
run: |
cat > index.mjs <<EOL
import unzipper from "unzipper";
fetch(
"https://github.com/atelier-anchor/smiley-sans/releases/download/v2.0.1/smiley-sans-v2.0.1.zip"
)
.then((res) => res.arrayBuffer())
.then(async (res) => {
const directory = await unzipper.Open.buffer(Buffer.from(res));
await directory.extract({ path: "./" });
});
EOL
- name: Create index.mjs file Windows
if: ${{ runner.os == 'Windows' }}
run: |
$content = @'
import unzipper from "unzipper";
fetch(
"https://github.com/atelier-anchor/smiley-sans/releases/download/v2.0.1/smiley-sans-v2.0.1.zip"
)
.then((res) => res.arrayBuffer())
.then(async (res) => {
const directory = await unzipper.Open.buffer(Buffer.from(res));
await directory.extract({ path: "./" });
});
'@
Set-Content -Path index.mjs -Value $content
- name: Install unzipper
run: |
npm init -y
npm i pnpm -g
npm i unzipper cn-font-split
pnpm cn-font-split ls
node index.mjs
- name: build
if: ${{ matrix.platform.target != 'wasm32-wasip1' }}
run: |
pnpm cn-font-split -i ./SmileySans-Oblique.otf -o ./dist/
- name: wasm build
if: ${{ matrix.platform.target == 'wasm32-wasip1' }}
run: |
pnpm cn-font-split i wasm32-wasip1
cat > test.mjs <<EOL
import { fontSplit, StaticWasm } from 'cn-font-split/dist/wasm/index.mjs';
import fs from 'fs';
const input = fs.readFileSync('./SmileySans-Oblique.otf');
const wasm = new StaticWasm(
fs.readFileSync(
'./node_modules/cn-font-split/dist/libffi-wasm32-wasip1.wasm',
),
);
const data = await fontSplit(
{
input: new Uint8Array(input.buffer),
outDir: './dist',
},
wasm.WasiHandle,
{
logger(str, type) {
console.log(str);
},
},
);
// console.log(data);
// { name: string, data: Uint8Array }[]
for (const file of data) {
fs.writeFileSync('./dist/' + file.name, file.data);
}
EOL
mkdir dist
node test.mjs
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: test-${{ matrix.platform.target }}-${{hashFiles('dist/**/*.woff2')}}
path: ./dist/**/*
if-no-files-found: error
nodejs:
name: Test - ${{ matrix.platform.name }}
strategy:
fail-fast: false
matrix:
platform:
- name: aarch64-unknown-linux-gnu-ubuntu_latest
arch: aarch64
distro: ubuntu_latest
env:
TZ: Asia/Shanghai
runs-on: ubuntu-24.04
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- name: Create index.mjs file
run: |
cat > index.mjs <<EOL
import unzipper from "unzipper";
fetch(
"https://github.com/atelier-anchor/smiley-sans/releases/download/v2.0.1/smiley-sans-v2.0.1.zip"
)
.then((res) => res.arrayBuffer())
.then(async (res) => {
const directory = await unzipper.Open.buffer(Buffer.from(res));
await directory.extract({ path: "./" });
});
EOL
- name: Install unzipper
run: |
npm init -y
npm install unzipper
node index.mjs
- name: Build artifact
uses: uraimo/run-on-arch-action@v2
with:
arch: ${{ matrix.platform.arch }}
distro: ${{ matrix.platform.distro }}
# Not required, but speeds up builds
githubToken: ${{ github.token }}
dockerRunArgs: |
--volume "${PWD}/:/app"
# The shell to run commands with in the container
shell: /bin/sh
install: |
case "${{ matrix.platform.distro }}" in
ubuntu*|jessie|stretch|buster|bullseye)
apt-get update -q -y
apt-get install -q -y nodejs npm
;;
fedora*)
dnf -y update
dnf -y install nodejs which
;;
alpine*)
apk update
apk add nodejs
;;
esac
# Produce a binary artifact and place it in the mounted volume
run: |
apt install curl -q -y
npm i cn-font-split -g
cn-font-split ls
cn-font-split -i ./SmileySans-Oblique.otf -o ./dist/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: test-${{ matrix.platform.name }}-${{hashFiles('dist/**/*.woff2')}}
path: ./dist/**/*
if-no-files-found: error
python:
name: Test - ${{ matrix.platform.name }}
strategy:
fail-fast: false
matrix:
platform:
- name: aarch64-unknown-linux-gnu-bookworm
arch: aarch64
distro: bookworm
target: aarch64-unknown-linux-gnu
break_python: --break-system-packages
- name: aarch64-unknown-linux-gnu-ubuntu22.04
arch: aarch64
distro: ubuntu22.04
target: aarch64-unknown-linux-gnu
- name: aarch64-unknown-linux-gnu-ubuntu20.04
arch: aarch64
distro: ubuntu20.04
target: aarch64-unknown-linux-gnu
- name: riscv64gc-unknown-linux-gnu
arch: riscv64
distro: ubuntu_latest
target: riscv64gc-unknown-linux-gnu
break_python: --break-system-packages
- name: s390x-unknown-linux-gnu
arch: s390x
distro: ubuntu_latest
target: s390x-unknown-linux-gnu
break_python: --break-system-packages
# more targets here ...
env:
TZ: Asia/Shanghai
runs-on: ubuntu-24.04
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- name: Create index.mjs file
run: |
cat > index.mjs <<EOL
import unzipper from "unzipper";
fetch(
"https://github.com/atelier-anchor/smiley-sans/releases/download/v2.0.1/smiley-sans-v2.0.1.zip"
)
.then((res) => res.arrayBuffer())
.then(async (res) => {
const directory = await unzipper.Open.buffer(Buffer.from(res));
await directory.extract({ path: "./" });
});
EOL
- name: Install unzipper
run: |
npm init -y
npm install unzipper
node index.mjs
- name: Build artifact
uses: uraimo/run-on-arch-action@v2
with:
arch: ${{ matrix.platform.arch }}
distro: ${{ matrix.platform.distro }}
# Not required, but speeds up builds
githubToken: ${{ github.token }}
dockerRunArgs: |
--volume "${PWD}/:/app"
# The shell to run commands with in the container
shell: /bin/sh
install: |
case "${{ matrix.platform.distro }}" in
ubuntu*|jessie|stretch|buster|bullseye)
apt-get update -q -y
apt-get install -q -y nodejs npm
;;
fedora*)
dnf -y update
dnf -y install nodejs which
;;
alpine*)
apk update
apk add nodejs
;;
esac
# Produce a binary artifact and place it in the mounted volume
run: |
apt update -y -q
apt install curl python3 python3-pip -y -q
pip3 install cn-font-split ${{ matrix.platform.break_python }}
cn-font-split-py i ${{ matrix.platform.target }}@${{inputs.version}}
cn-font-split-py -i ./SmileySans-Oblique.otf -o ./dist/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: test-${{ matrix.platform.name }}-${{hashFiles('dist/**/*.woff2')}}
path: ./dist/**/*
if-no-files-found: error