-
Notifications
You must be signed in to change notification settings - Fork 76
218 lines (209 loc) · 7.61 KB
/
ci.yml
File metadata and controls
218 lines (209 loc) · 7.61 KB
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
name: CI
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
check-test-coverage:
name: Check, Test & Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: cargo-ubuntu-check-${{ hashFiles('**/Cargo.lock') }}
restore-keys: cargo-ubuntu-
- name: Cache cargo-llvm-cov
id: cache-llvm-cov
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.cargo/bin/cargo-llvm-cov
key: cargo-llvm-cov-${{ runner.os }}
- name: Install Rust
run: |
rustup toolchain install stable --profile minimal --component clippy,rustfmt,llvm-tools-preview
rustup default stable
- name: Format check
run: cargo fmt --check
- name: Clippy
run: cargo clippy --all-targets -- -D warnings
- name: Install cargo-llvm-cov
if: steps.cache-llvm-cov.outputs.cache-hit != 'true'
run: cargo install cargo-llvm-cov
- name: Test with coverage
run: cargo llvm-cov --lcov --output-path lcov.info --ignore-filename-regex 'main\.rs|auth/' -- --test-threads=1
- name: Coverage summary
run: cargo llvm-cov report --ignore-filename-regex 'main\.rs|auth/'
- name: Upload coverage artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: coverage-report
path: lcov.info
cross-compile-linux:
name: Cross Compile (Linux)
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-C target-feature=+crt-static"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust
run: |
rustup toolchain install stable --profile minimal
rustup default stable
rustup target add x86_64-unknown-linux-musl aarch64-unknown-linux-musl
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: cargo-ubuntu-cross-linux-musl-${{ hashFiles('**/Cargo.lock') }}
restore-keys: cargo-ubuntu-
- uses: ./.github/actions/install-musl-toolchain
- name: Build x86_64 musl
run: cargo build --release --target x86_64-unknown-linux-musl --features vendored-openssl
- name: Verify x86_64 static linkage
run: |
file target/x86_64-unknown-linux-musl/release/pup
if readelf -d target/x86_64-unknown-linux-musl/release/pup | grep -q "(NEEDED)"; then
echo "ERROR: binary has dynamic NEEDED entries"
exit 1
fi
- name: Build aarch64 musl
run: cargo build --release --target aarch64-unknown-linux-musl --features vendored-openssl
- name: Verify aarch64 static linkage
run: |
file target/aarch64-unknown-linux-musl/release/pup
if readelf -d target/aarch64-unknown-linux-musl/release/pup | grep -q "(NEEDED)"; then
echo "ERROR: binary has dynamic NEEDED entries"
exit 1
fi
- name: Report sizes
run: |
ls -lh target/x86_64-unknown-linux-musl/release/pup
ls -lh target/aarch64-unknown-linux-musl/release/pup
cross-compile-macos:
name: Cross Compile (macOS)
runs-on: macos-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: cargo-cross-macos-${{ hashFiles('**/Cargo.lock') }}
restore-keys: cargo-cross-macos-
- name: Install Rust
run: |
rustup toolchain install stable --profile minimal
rustup default stable
rustup target add x86_64-apple-darwin aarch64-apple-darwin
- name: Build all targets
run: |
PIDS=()
for target in x86_64-apple-darwin aarch64-apple-darwin; do
(set -o pipefail
echo "==> Starting ${target}"
cargo build --release --target "${target}" 2>&1 \
| tee "/tmp/${target}.log"
) &
PIDS+=($!)
done
status=0
for pid in "${PIDS[@]}"; do
wait "$pid" || status=1
done
exit $status
- name: Report sizes
run: |
for target in x86_64-apple-darwin aarch64-apple-darwin; do
echo "${target}:"
ls -lh "target/${target}/release/pup"
done
cross-compile-windows:
name: Cross Compile (Windows)
runs-on: windows-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: cargo-windows-${{ hashFiles('**/Cargo.lock') }}
restore-keys: cargo-windows-
- name: Enable long paths
run: git config --global core.longpaths true
- name: Install NASM
run: |
choco install nasm -y
echo "C:\Program Files\NASM" >> "$GITHUB_PATH"
- name: Install Rust
run: |
rustup toolchain install stable --profile minimal
rustup default stable
- name: Build
run: cargo build --release
- name: Run tests
run: cargo test --verbose -- --test-threads=1
- name: Report binary size
run: ls -lh target/release/pup.exe
wasm:
name: WASM (WASI + Browser)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: cargo-ubuntu-wasm-${{ hashFiles('**/Cargo.lock') }}
restore-keys: cargo-ubuntu-
- name: Install Rust
run: |
rustup toolchain install stable --profile minimal
rustup default stable
rustup target add wasm32-wasip2 wasm32-unknown-unknown
- name: Cache wasm-pack
id: cache-wasm-pack
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.cargo/bin/wasm-pack
key: wasm-pack-${{ runner.os }}
- name: Build WASI
run: cargo build --target wasm32-wasip2 --no-default-features --features wasi --release
- name: Install wasm-pack
if: steps.cache-wasm-pack.outputs.cache-hit != 'true'
run: cargo install wasm-pack
- name: Build browser WASM
run: wasm-pack build --target web --no-default-features --features browser
- name: Report sizes
run: |
echo "WASI:"
ls -lh target/wasm32-wasip2/release/pup.wasm
echo "Browser WASM:"
ls -lh pkg/pup_wasm_bg.wasm