-
Notifications
You must be signed in to change notification settings - Fork 0
268 lines (221 loc) · 8.24 KB
/
Copy pathrust.yml
File metadata and controls
268 lines (221 loc) · 8.24 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
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
---
name: Rust
"on":
push:
branches: ["main"]
pull_request:
branches: ["main"]
env:
CARGO_TERM_COLOR: always
# Disable incremental compilation for CI (not reused).
CARGO_INCREMENTAL: 0
# Disable debug info in dev builds (faster compile).
CARGO_PROFILE_DEV_DEBUG: 0
PAR2_TURBO_VERSION: "1.4.0"
PAR2_TURBO_CACHE_KEY: par2cmdline-turbo-1.4.0
PAR2_TURBO_SHA256: >-
0be495172b4b8aeabda39c493e47de652813fab88ae745c8633e901c05494281
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "test"
cache-on-failure: true
- name: Cache par2cmdline
id: cache-par2
uses: actions/cache@v4
with:
path: ~/bin/par2
key: ${{ runner.os }}-${{ env.PAR2_TURBO_CACHE_KEY }}
- name: Install par2cmdline-turbo
if: steps.cache-par2.outputs.cache-hit != 'true'
run: |
archive="par2cmdline-turbo-${PAR2_TURBO_VERSION}-linux-amd64.zip"
release_url="https://github.com/animetosho/par2cmdline-turbo"
curl -fsSLO \
"${release_url}/releases/download/v${PAR2_TURBO_VERSION}/${archive}"
echo "${PAR2_TURBO_SHA256} ${archive}" | sha256sum -c -
python3 -m zipfile -e "${archive}" par2cmdline-turbo
par2_bin="$(find par2cmdline-turbo -type f -name par2 -print -quit)"
test -n "${par2_bin}"
mkdir -p ~/bin
install -m 0755 "${par2_bin}" ~/bin/par2
- name: Add par2 to PATH
run: echo "$HOME/bin" >> $GITHUB_PATH
- name: Check PAR2 reference tool
run: par2 --version
- name: Run tests
run: cargo test --all-features --workspace
cross-compile-aarch64:
runs-on: ubuntu-latest
name: Cross-compile for aarch64
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
with:
targets: aarch64-unknown-linux-gnu
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "cross-compile-aarch64"
cache-on-failure: true
- name: Install cross
run: cargo install cross --locked
- name: Build library for aarch64
run: cross build --lib --target aarch64-unknown-linux-gnu
- name: Build tests for aarch64
run: cross build --tests --target aarch64-unknown-linux-gnu
- name: Verify aarch64 build
run: |
echo "✓ aarch64-unknown-linux-gnu build succeeded"
echo " - Architecture separation validated"
echo " - x86_64 backends: hasher_input, md5x2_scalar, md5x2_sse2,"
echo " md5x2_bmi1, md5x2_avx512"
echo " - aarch64 backends: md5x2_scalar, md5x2_neon, crc_armcrc"
echo " - Shared: md5x2 trait"
build-windows-binaries:
runs-on: windows-latest
name: Build Windows binaries
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
with:
targets: x86_64-pc-windows-msvc
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "build-windows-binaries"
cache-on-failure: true
- name: Build release binaries
run: cargo build --release --bins --target x86_64-pc-windows-msvc
- name: Package Windows binaries
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist | Out-Null
Compress-Archive `
-Path `
target/x86_64-pc-windows-msvc/release/par2.exe, `
target/x86_64-pc-windows-msvc/release/par2create.exe, `
target/x86_64-pc-windows-msvc/release/par2repair.exe, `
target/x86_64-pc-windows-msvc/release/par2verify.exe `
-DestinationPath dist/par2rs-windows-x86_64.zip
- name: Upload Windows binaries
uses: actions/upload-artifact@v4
with:
name: par2rs-windows-x86_64
path: |
dist/par2rs-windows-x86_64.zip
target/x86_64-pc-windows-msvc/release/par2.exe
target/x86_64-pc-windows-msvc/release/par2create.exe
target/x86_64-pc-windows-msvc/release/par2repair.exe
target/x86_64-pc-windows-msvc/release/par2verify.exe
build-linux-x86_64-binaries:
runs-on: ubuntu-latest
name: Build Linux x86_64 binaries
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
with:
targets: x86_64-unknown-linux-gnu
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "build-linux-x86_64-binaries"
cache-on-failure: true
- name: Build release binaries
run: cargo build --release --bins --target x86_64-unknown-linux-gnu
- name: Package Linux x86_64 binaries
run: |
mkdir -p dist
tar -C target/x86_64-unknown-linux-gnu/release -czf \
dist/par2rs-linux-x86_64-nightly.tar.gz \
par2 par2create par2repair par2verify
- name: Upload Linux x86_64 binaries
uses: actions/upload-artifact@v4
with:
name: par2rs-linux-x86_64-nightly
path: |
dist/par2rs-linux-x86_64-nightly.tar.gz
target/x86_64-unknown-linux-gnu/release/par2
target/x86_64-unknown-linux-gnu/release/par2create
target/x86_64-unknown-linux-gnu/release/par2repair
target/x86_64-unknown-linux-gnu/release/par2verify
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
with:
components: llvm-tools-preview
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "coverage"
cache-on-failure: true
- name: Cache par2cmdline
id: cache-par2-coverage
uses: actions/cache@v4
with:
path: ~/bin/par2
key: ${{ runner.os }}-${{ env.PAR2_TURBO_CACHE_KEY }}
- name: Install par2cmdline-turbo
if: steps.cache-par2-coverage.outputs.cache-hit != 'true'
run: |
archive="par2cmdline-turbo-${PAR2_TURBO_VERSION}-linux-amd64.zip"
release_url="https://github.com/animetosho/par2cmdline-turbo"
curl -fsSLO \
"${release_url}/releases/download/v${PAR2_TURBO_VERSION}/${archive}"
echo "${PAR2_TURBO_SHA256} ${archive}" | sha256sum -c -
python3 -m zipfile -e "${archive}" par2cmdline-turbo
par2_bin="$(find par2cmdline-turbo -type f -name par2 -print -quit)"
test -n "${par2_bin}"
mkdir -p ~/bin
install -m 0755 "${par2_bin}" ~/bin/par2
- name: Add par2 to PATH
run: echo "$HOME/bin" >> $GITHUB_PATH
- name: Check PAR2 reference tool
run: par2 --version
- name: Cache cargo-llvm-cov binary
uses: actions/cache@v4
with:
path: ~/.cargo/bin/cargo-llvm-cov
key: ${{ runner.os }}-cargo-llvm-cov-0.6.14
- name: Install cargo-llvm-cov
run: |
if ! command -v cargo-llvm-cov &> /dev/null; then
cargo install cargo-llvm-cov --version 0.6.14 --locked
fi
- name: Generate coverage report
run: ./scripts/coverage.sh ci
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
file: target/coverage/lcov.info
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Archive coverage results
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: target/coverage