-
Notifications
You must be signed in to change notification settings - Fork 470
437 lines (416 loc) · 13.7 KB
/
rust.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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
name: Rust
on:
pull_request:
push:
branches:
- master
concurrency:
group: ci-${{ github.head_ref }}
cancel-in-progress: true
env:
RUST_VERSION: "1.81"
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{env.RUST_VERSION}}
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v4
- name: cargo fmt
run: cargo fmt -- --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{env.RUST_VERSION}}
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v4
- name: cargo clippy
run: cargo clippy -- -D warnings
unit_tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{env.RUST_VERSION}}
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v4
- name: Run tests
run: cargo test
build_release:
runs-on: windows-latest
name: "Release build for Windows"
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{env.RUST_VERSION}}
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v4
- name: Build release binary
run: cargo build --release
env:
RUSTFLAGS: "-C target-feature=+crt-static"
- uses: actions/upload-artifact@v4
with:
name: fnm-windows
path: target/release/fnm.exe
build_macos_release:
runs-on: macos-latest
name: "Release build for macOS"
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{env.RUST_VERSION}}
targets: x86_64-apple-darwin,aarch64-apple-darwin
- uses: Swatinem/rust-cache@v2
- uses: mlugg/setup-zig@v1
- run: cargo install --locked cargo-zigbuild
- uses: actions/checkout@v4
- name: Build release binary
run: |
cargo zigbuild --release --target=universal2-apple-darwin
mkdir -p target/release
cp target/universal2-apple-darwin/release/fnm target/release/fnm
env:
LZMA_API_STATIC: "true"
- name: Strip binary from debug symbols
run: strip target/release/fnm
- name: List dynamically linked libraries
run: otool -L target/release/fnm
- uses: actions/upload-artifact@v4
with:
name: fnm-macos
path: target/release/fnm
e2e_macos:
runs-on: macos-latest
needs: [build_macos_release]
name: "e2e/macos"
steps:
- name: install necessary shells
run: brew install fish zsh bash
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: fnm-macos
path: target/release
- name: mark binary as executable
run: chmod +x target/release/fnm
- uses: pnpm/[email protected]
with:
run_install: false
- uses: actions/setup-node@v4
with:
node-version: 18.x
cache: "pnpm"
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm install
- run: pnpm test
env:
FNM_TARGET_NAME: "release"
FORCE_COLOR: "1"
e2e_windows:
runs-on: windows-latest
needs: [build_release]
name: "e2e/windows"
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: fnm-windows
path: target/release
- uses: MinoruSekine/setup-scoop@v4
- uses: pnpm/[email protected]
with:
run_install: false
- uses: actions/setup-node@v4
with:
node-version: 18.x
cache: "pnpm"
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm install
- run: pnpm test
env:
FNM_TARGET_NAME: "release"
FORCE_COLOR: "1"
# e2e_windows_debug:
# runs-on: windows-latest
# name: "e2e/windows/debug"
# environment: Debug
# needs: [e2e_windows]
# if: contains(join(needs.*.result, ','), 'failure')
# steps:
# - uses: actions/checkout@v3
# - uses: actions/download-artifact@v3
# with:
# name: fnm-windows
# path: target/release
# - uses: pnpm/[email protected]
# with:
# run_install: false
# - uses: actions/setup-node@v3
# with:
# node-version: 18.x
# cache: 'pnpm'
# - name: Get pnpm store directory
# id: pnpm-cache
# run: |
# echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
# - uses: actions/cache@v3
# name: Setup pnpm cache
# with:
# path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
# key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
# restore-keys: |
# ${{ runner.os }}-pnpm-store-
# - run: pnpm install
# - name: 🐛 Debug Build
# uses: mxschmitt/action-tmate@v3
e2e_linux:
runs-on: ubuntu-latest
needs: [build_static_linux_binary]
name: "e2e/linux"
steps:
- name: install necessary shells
run: sudo apt-get update && sudo apt-get install -y fish zsh bash
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: fnm-linux
path: target/release
- name: mark binary as executable
run: chmod +x target/release/fnm
- uses: pnpm/[email protected]
with:
run_install: false
- uses: actions/setup-node@v4
with:
node-version: 18.x
cache: "pnpm"
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm install
- run: pnpm test
env:
FNM_TARGET_NAME: "release"
FORCE_COLOR: "1"
build_static_linux_binary:
name: "Build static Linux binary"
runs-on: ubuntu-latest
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{env.RUST_VERSION}}
targets: x86_64-unknown-linux-musl
- uses: Swatinem/rust-cache@v2
with:
key: static-linux-binary
- name: Install musl tools
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends musl-tools
- uses: actions/checkout@v4
- name: Build release binary
run: cargo build --release --target x86_64-unknown-linux-musl
- name: Strip binary from debug symbols
run: strip target/x86_64-unknown-linux-musl/release/fnm
- uses: actions/upload-artifact@v4
with:
name: fnm-linux
path: target/x86_64-unknown-linux-musl/release/fnm
build_static_arm_binary:
name: "Build ARM binary"
strategy:
matrix:
include:
- arch: arm64
rust_target: aarch64-unknown-linux-musl
docker_image: arm64v8/ubuntu
docker_platform: aarch64
- arch: arm32
rust_target: armv7-unknown-linux-gnueabihf
docker_image: arm32v7/ubuntu
docker_platform: armv7
runs-on: ubuntu-latest
env:
RUST_TARGET: ${{ matrix.rust_target }}
steps:
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{env.RUST_VERSION}}
- uses: Swatinem/rust-cache@v2
with:
key: arm-binary-${{ matrix.arch }}
- name: "Download `cross` crate"
run: cargo install cross
- uses: actions/checkout@v4
- name: "Build release"
run: cross build --target $RUST_TARGET --release
- uses: uraimo/[email protected]
name: Sanity test
with:
arch: ${{matrix.docker_platform}}
distro: ubuntu18.04
# Not required, but speeds up builds by storing container images in
# a GitHub package registry.
githubToken: ${{ github.token }}
env: |
RUST_LOG: fnm=debug
dockerRunArgs: |
--volume "${PWD}/target/${{matrix.rust_target}}/release:/artifacts"
# Set an output parameter `uname` for use in subsequent steps
run: |
echo "Hello from $(uname -a)"
/artifacts/fnm --version
echo "fnm install 12.0.0"
/artifacts/fnm install 12.0.0
echo "fnm exec --using=12 -- node --version"
/artifacts/fnm exec --using=12 -- node --version
- uses: actions/upload-artifact@v4
with:
name: fnm-${{ matrix.arch }}
path: target/${{ env.RUST_TARGET }}/release/fnm
ensure_commands_markdown_is_up_to_date:
runs-on: ubuntu-latest
name: Ensure command docs are up-to-date
needs: [build_static_linux_binary]
steps:
- name: install necessary shells
run: sudo apt-get update && sudo apt-get install -y fish zsh bash
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: fnm-linux
path: target/release
- name: mark binary as executable
run: chmod +x target/release/fnm
- name: install fnm as binary
run: |
sudo install target/release/fnm /bin
fnm --version
- uses: pnpm/[email protected]
with:
run_install: false
- uses: actions/setup-node@v4
with:
node-version: 18.x
cache: "pnpm"
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm install
- name: Generate command markdown
run: |
pnpm run generate-command-docs --check --binary-path=$(which fnm)
# TODO: use bnz
# run_e2e_benchmarks:
# runs-on: ubuntu-latest
# name: bench/linux
# needs: [build_static_linux_binary]
# permissions:
# contents: write
# pull-requests: write
# steps:
# - name: install necessary shells
# run: sudo apt-get update && sudo apt-get install -y fish zsh bash hyperfine
# - uses: actions/checkout@v3
# - uses: actions/download-artifact@v3
# with:
# name: fnm-linux
# path: target/release
# - name: mark binary as executable
# run: chmod +x target/release/fnm
# - name: install fnm as binary
# run: |
# sudo install target/release/fnm /bin
# fnm --version
# - uses: pnpm/[email protected]
# with:
# run_install: false
# - uses: actions/setup-node@v3
# with:
# node-version: 18.x
# cache: "pnpm"
# - name: Get pnpm store directory
# id: pnpm-cache
# run: |
# echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
# - uses: actions/cache@v3
# name: Setup pnpm cache
# with:
# path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
# key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
# restore-keys: |
# ${{ runner.os }}-pnpm-store-
# - run: pnpm install
# - name: Run benchmarks
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SHOULD_STORE: ${{ toJson(!github.event.pull_request) }}
# id: benchmark
# run: |
# delimiter="$(openssl rand -hex 8)"
# echo "markdown<<${delimiter}" >> "${GITHUB_OUTPUT}"
# node benchmarks/run.mjs --store=$SHOULD_STORE >> "${GITHUB_OUTPUT}"
# echo "${delimiter}" >> "${GITHUB_OUTPUT}"
# - name: Create a PR comment
# if: ${{ github.event.pull_request }}
# uses: thollander/actions-comment-pull-request@v2
# with:
# message: |
# ## Linux Benchmarks for ${{ github.event.pull_request.head.sha }}
# ${{ steps.benchmark.outputs.markdown }}
# comment_tag: "benchy comment"
#
# - name: Create a commit comment
# if: ${{ !github.event.pull_request }}
# uses: peter-evans/commit-comment@v2
# with:
# body: |
# ## Linux Benchmarks
# ${{ steps.benchmark.outputs.markdown }}