211 lines (200 loc) 路 6.94 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
name: Rust
on:
pull_request:
push:
branches:
- master
jobs:
# fmt:
# runs-on: ubuntu-latest
# steps:
# - uses: hecrj/setup-rust-action@v1
# with:
# rust-version: stable
# - uses: actions/checkout@v2
# - name: cargo fmt
# run: cargo fmt -- --check
# 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: stable
# - uses: actions/checkout@v2
# - name: Run tests
# run: cargo test -- --skip=feature_tests
# e2e_tests:
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os: [ubuntu-latest, macOS-latest, windows-latest]
# steps:
# - name: Install Fish and Zsh using brew
# if: "startsWith(matrix.os, 'macOS')"
# run: brew install fish zsh
# - name: Install Fish and Zsh using apt
# if: "startsWith(matrix.os, 'ubuntu')"
# run: sudo apt-get install -y fish zsh
# - uses: hecrj/setup-rust-action@v1
# with:
# rust-version: stable
# - uses: actions/checkout@v2
# - name: Run tests
# run: cargo test -- feature_tests
# build_release:
# runs-on: windows-latest
# name: "Release build for Windows"
# steps:
# - uses: hecrj/setup-rust-action@v1
# with:
# rust-version: stable
# - uses: actions/checkout@v2
# - name: Build release binary
# run: cargo build --release
# env:
# RUSTFLAGS: "-C target-feature=+crt-static"
# - uses: actions/upload-artifact@v2
# 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: stable
# - uses: actions/checkout@v2
# - name: Build release binary
# run: cargo build --release
# 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@v2
# with:
# name: fnm-macos
# path: target/release/fnm
# build_static_linux_binary:
# name: "Build static Linux binary"
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Build static binary
# run: |
# sudo chown -R 1000:1000 .
# docker run --rm -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder:stable \
# cargo build --target x86_64-unknown-linux-gnu --release
# sudo chown -R $(whoami):$(whoami) .
# - uses: actions/upload-artifact@v2
# with:
# name: fnm-linux
# path: target/x86_64-unknown-linux-gnu/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
- arch: arm32
rust_target: armv7-unknown-linux-gnueabihf
docker_image: arm32v7/ubuntu
runs-on: ubuntu-latest
env:
RUST_TARGET: ${{ matrix.rust_target }}
steps:
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
- uses: hecrj/setup-rust-action@v1
with:
rust-version: stable
- name: 'Download `cross` crate'
run: cargo install cross
- uses: actions/checkout@v2
- name: "Build release"
run: cross build --target $RUST_TARGET --release
- name: Compress binary using UPX
run: |
sudo apt-get install -y upx
upx target/$RUST_TARGET/release/fnm
- name: "Sanity test"
run: |
docker run --rm -v $(pwd):$(pwd) -e "RUST_LOG=fnm=debug" --workdir $(pwd) ${{matrix.docker_image}} bash -c '
$(pwd)/target/${{ env.RUST_TARGET }}/release/fnm --version
echo "fnm install 12.0.0"
$(pwd)/target/${{ env.RUST_TARGET }}/release/fnm install 12.0.0
echo "fnm exec --using=12 -- node --version"
$(pwd)/target/${{ env.RUST_TARGET }}/release/fnm exec --using=12 -- node --version
'
- uses: actions/upload-artifact@v2
with:
name: fnm-${{ matrix.arch }}
path: target/${{ env.RUST_TARGET }}/release/fnm
# benchmark_on_linux:
# name: Performance Benchmarks (Linux)
# needs: [build_static_linux_binary]
# runs-on: ubuntu-latest
# steps:
# - uses: octokit/request-action@v2.x
# id: get_master_workflows
# with:
# route: GET /repos/:repository/actions/runs
# repository: ${{ github.repository }}
# branch: master
# status: completed
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - uses: octokit/request-action@v2.x
# id: get_latest_artifacts
# with:
# route: GET /repos/:repository/actions/runs/:workflow_id/artifacts
# repository: ${{ github.repository }}
# workflow_id: ${{ fromJson(steps.get_master_workflows.outputs.data).workflow_runs[0].id }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: "Take the output"
# run: |
# URL=$(echo '${{ steps.get_latest_artifacts.outputs.data }}' | jq -r '.artifacts | map(select(.name == "fnm-linux")) | .[0].archive_download_url')
# curl -L $URL -H 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' > /tmp/fnm-latest.zip
# mkdir ~/.fnm-latest
# unzip -d ~/.fnm-latest /tmp/fnm-latest.zip
# ls -lah ~/.fnm-latest
# - uses: actions/checkout@v2
# - name: Install Hyperfine
# run: |
# wget https://github.com/sharkdp/hyperfine/releases/download/v1.10.0/hyperfine_1.10.0_amd64.deb
# sudo dpkg -i hyperfine_1.10.0_amd64.deb
# - name: Install fnm-reason for Linux
# run: curl -fsSL https://github.com/Schniz/fnm/raw/master/.ci/install.sh | bash -s -- --skip-shell
# - name: Install nvm
# run: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
# - uses: actions/download-artifact@v2
# with:
# name: fnm-linux
# path: target/release/
# - name: "Run benchmarks"
# run: bash benchmarks/run
# - name: Read basic.md for the generated report
# id: basic_result
# uses: juliangruber/read-file-action@v1
# with:
# path: benchmarks/results/basic.md
# - uses: octokit/request-action@v2.x
# id: get_latest_release
# with:
# route: POST /repos/:repository/commits/:commit_sha/comments
# repository: ${{ github.repository }}
# commit_sha: ${{ github.sha }}
# body: |
# |
# ${{ steps.basic_result.outputs.content }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}