-
Notifications
You must be signed in to change notification settings - Fork 5
311 lines (260 loc) · 9.34 KB
/
ci.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
name: CI
on:
push:
branches: [main]
paths-ignore:
- ".github/**"
- "!.github/workflows/ci.yml"
- ".gitignore"
- "codecov.yml"
- "grcov.yml"
- "LICENSE*"
- "README.md"
pull_request:
branches: [main]
paths-ignore:
- ".github/**"
- "!.github/workflows/ci.yml"
- ".gitignore"
- "codecov.yml"
- "grcov.yml"
- "LICENSE*"
- "README.md"
env:
RUST_BACKTRACE: 1
jobs:
fmt:
name: Format
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Stable toolchain with rustfmt
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt
- uses: swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Check coding style
run: cargo fmt --check --all
clippy:
name: Clippy
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Stable toolchain with clippy
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
with:
profile: minimal
toolchain: stable
override: true
components: clippy
- uses: swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Lint
run: cargo clippy --all-targets --all-features -- -D warnings
docs:
name: Docs
runs-on: ubuntu-latest
timeout-minutes: 30
env:
RUSTDOCFLAGS: "-Dwarnings"
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Stable toolchain
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
with:
profile: minimal
toolchain: stable
override: true
- uses: swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- run: cargo doc --no-deps
tests:
name: Tests
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Stable toolchain
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
with:
profile: minimal
toolchain: stable
override: true
- uses: swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- uses: taiki-e/install-action@ef7090108a583d4124f188b4958359153b2d19e1 # nextest
- name: Test
run: cargo nextest run --all-features --lib --bins --test keys
ctf-challenges:
name: CTF challenges
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Stable toolchain
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
with:
profile: minimal
toolchain: stable
override: true
- uses: swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- uses: taiki-e/install-action@ef7090108a583d4124f188b4958359153b2d19e1 # nextest
- name: Test
run: cargo nextest run --release --all-features --test "*ctf*" --test crypton
coverage:
name: Coverage
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Stable toolchain
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
with:
profile: minimal
toolchain: nightly
override: true
- uses: swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- uses: taiki-e/install-action@ef7090108a583d4124f188b4958359153b2d19e1 # nextest
- name: Tests
run: cargo nextest run --all-features --lib --bins --test keys
env:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests"
RUSTDOCFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests"
- name: Grcov
id: coverage
uses: actions-rs/grcov@770fa904bcbfc50da498080d1511da7388e6ddc6 # v0.1.6
with:
config: grcov.yml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
with:
files: ${{ steps.coverage.outputs.report }}
flags: rust
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
build:
name: Build
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
with:
profile: minimal
toolchain: stable
override: true
- uses: swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
# msys2 required by rug on windows
- name: Setup msys2 (windows)
uses: msys2/setup-msys2@d0e80f58dffbc64f6a3a1f43527d469b4fc7b6c8 # v2.23.0
if: matrix.os == 'windows-latest'
with:
install: base-devel pacman-mirrors diffutils m4 make openssl openssl-devel
pacboy: gcc:p rust:p
# Only for windows
- name: Msys2 build (windows)
if: matrix.os == 'windows-latest'
shell: msys2 {0}
run: |
cargo build
- name: Build
if: matrix.os != 'windows-latest'
run: cargo build
docker-build:
name: Docker build
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
arch: [amd64, arm64]
env:
CACHE_VERSION: v1
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@4fd812986e6c8c2a69e18311145f9371337f27d4 # v3.4.0
- name: Setup multi-platform
uses: docker/setup-qemu-action@v3
- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
id: cache
with:
path: |
target
/usr/local/cargo/registry
key: ${{ runner.os }}-rust-${{ env.CACHE_VERSION }}-${{ github.job }}-${{ matrix.arch }}-${{ hashFiles('**/Cargo.toml', '**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-rust-${{ env.CACHE_VERSION }}-${{ github.job }}-${{ matrix.arch }}-
- name: Inject cache into docker
uses: reproducible-containers/buildkit-cache-dance@5b6db76d1da5c8b307d5d2e0706d266521b710de # v3.1.2
with:
cache-map: |
{
"target": "/usr/src/rsacracker/target",
"/usr/local/cargo/registry": "/usr/local/cargo/registry"
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
- name: Build
uses: docker/build-push-action@1a162644f9a7e87d8f4b053101d1d9a712edc18c # v6.3.0
with:
tags: rsacracker:test
platforms: linux/${{ matrix.arch }}
build-args: ARCH=${{ matrix.arch }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test the Docker image
run: docker run --rm --platform=linux/${{ matrix.arch }} -v $PWD:/data rsacracker:test -n 323 --attack small_prime --factors
publish-crates_io:
name: Publish to crates.io
runs-on: ubuntu-latest
timeout-minutes: 30
needs: [fmt, clippy, docs, tests, ctf-challenges, coverage, build, docker-build]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Install stable toolchain
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
with:
profile: minimal
toolchain: stable
override: true
- run: cargo publish --token ${CRATES_TOKEN}
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
publish-docker_hub:
name: Publish to hub.docker.com
runs-on: ubuntu-latest
timeout-minutes: 30
needs: [fmt, clippy, docs, tests, ctf-challenges, coverage, build, docker-build]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
env:
IMAGE_NAME: skyf0l/rsacracker
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Install yq
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY} -O /usr/bin/yq
sudo chmod +x /usr/bin/yq
env:
VERSION: v4.40.5
BINARY: yq_linux_amd64
- name: Get package version
id: get_version
run: echo VERSION=$(yq ".package.version" Cargo.toml) >> $GITHUB_OUTPUT
- name: Login to Docker Hub
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@1a162644f9a7e87d8f4b053101d1d9a712edc18c # v6.3.0
with:
push: true
tags: ${{ env.IMAGE_NAME }}:${{ steps.get_version.outputs.VERSION }},${{ env.IMAGE_NAME }}:latest