-
Notifications
You must be signed in to change notification settings - Fork 61
363 lines (357 loc) · 13.5 KB
/
ci.yaml
File metadata and controls
363 lines (357 loc) · 13.5 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
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
---
name: CI
on:
pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
- ready_for_review
paths-ignore:
- docs/**
- '**.md'
- .github/**
- .gitignore
push:
branches:
- main
paths-ignore:
- docs/**
- '**.md'
- .github/**
# run concurrency group for the workflow
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
changed_files:
if: ${{ github.event.pull_request.draft == false }}
runs-on: ubuntu-latest
name: Test changed-files
outputs:
changed-rust-files: ${{ steps.changed-files-yaml.outputs.code_any_changed }}
changed-lockfile-files: ${{ steps.changed-files-yaml.outputs.lockfile_any_changed }}
changed-docker-files: ${{ steps.changed-files-yaml.outputs.docker_any_changed }}
changed-tests-files: ${{ steps.changed-files-yaml.outputs.tests_any_changed }}
steps:
# Checkout the repository
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Get changed files
id: changed-files-yaml
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
with:
files_yaml: |
code:
- '**/*.rs'
- 'rustfmt.toml'
- 'rust-toolchain.toml'
lockfile:
- 'Cargo.lock'
- 'Cargo.toml'
docker:
- 'Dockerfile.development'
- 'Dockerfile.production'
- 'docker-compose.yml'
- 'Cargo.lock'
- 'Cargo.toml'
tests:
- '**/*.rs'
- tests/**/*.json
ci:
timeout-minutes: 150
if: ${{ github.event.pull_request.draft == false && always() }}
permissions:
contents: none
name: CI
needs:
- msrv
- rustfmt
- clippy
runs-on: ubuntu-22.04-oz-8core
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
with:
egress-policy: audit
- name: Failed
run: exit 1
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
msrv:
if: ${{ github.event.pull_request.draft == false && github.event_name != 'push' && (needs.changed_files.outputs.changed-rust-files == 'true' || needs.changed_files.outputs.changed-lockfile-files == 'true') }}
runs-on: ubuntu-latest
needs: changed_files
steps:
# Checkout the repository
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Prepare
id: init
uses: ./.github/actions/prepare
# Get the output of the prepare composite action
- name: Get cache-hit output
run: 'echo "Cache hit >>>>>: ${{ steps.init.outputs.cache-hit }}"'
- name: Install cargo hack
uses: taiki-e/install-action@cf39a74df4a72510be4e5b63348d61067f11e64a # v2.75.0
with:
tool: cargo-hack
# Check the minimum supported Rust version
- name: Default features
run: cargo hack check --feature-powerset --locked --rust-version --workspace --lib --bins
rustfmt:
if: ${{ github.event.pull_request.draft == false && github.event_name != 'push' && needs.changed_files.outputs.changed-rust-files == 'true' }}
needs: changed_files
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Prepare
id: init
uses: ./.github/actions/prepare
# Get the output of the prepare composite action
- name: Get cache-hit output
run: 'echo "Cache hit >>>>>: ${{ steps.init.outputs.cache-hit }}"'
# Check the formatting of the code
- name: Check formatting
run: cargo fmt --all -- --check
clippy:
if: ${{ github.event.pull_request.draft == false && github.event_name != 'push' && needs.changed_files.outputs.changed-rust-files == 'true' }}
needs: changed_files
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Prepare
id: init
uses: ./.github/actions/prepare
# Get the output of the prepare composite action
- name: Get cache-hit output
run: 'echo "Cache hit >>>>>: ${{ steps.init.outputs.cache-hit }}"'
- name: Install SARIF tools
run: cargo install clippy-sarif --locked
- name: Install SARIF tools
run: cargo install sarif-fmt --locked
- name: Check
run: >
cargo clippy --all-features --workspace --lib --bins --no-deps --message-format=json
| clippy-sarif
| tee clippy-results.sarif
| sarif-fmt
continue-on-error: true
- name: upload sarif artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: clippy-results.sarif
path: clippy-results.sarif
retention-days: 1
- name: Upload
uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 # v3.29.5
with:
sarif_file: clippy-results.sarif
wait-for-processing: true
- name: Report status
run: cargo clippy --all-features --workspace --lib --bins --no-deps -- -D warnings --allow deprecated
test-unit:
name: Unit Tests
if: ${{ github.event.pull_request.draft == false && needs.changed_files.outputs.changed-tests-files == 'true' }}
permissions:
contents: read
needs:
- changed_files
runs-on: ubuntu-22.04-oz-8core
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: '20'
- name: Install pnpm and plugin dependencies
run: |
npm install -g pnpm
cd plugins
pnpm install
- name: Install TypeScript and ts-node
run: |
npm install -g typescript ts-node
ts-node --version
tsc --version
- name: free disk space
run: |
sudo swapoff -a
sudo rm -f /swapfile
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo apt clean
if [[ $(docker image ls -aq) ]]; then
docker rmi $(docker image ls -aq)
else
echo "No Docker images found to remove"
fi
- name: Prepare
id: init
uses: ./.github/actions/prepare
with:
components: llvm-tools-preview
- name: Get cache-hit output
run: 'echo "Cache hit >>>>>: ${{ steps.init.outputs.cache-hit }}"'
- name: Install cargo hack and cargo-llvm-cov
uses: taiki-e/install-action@cf39a74df4a72510be4e5b63348d61067f11e64a # v2.75.0
with:
tool: cargo-hack,cargo-llvm-cov
- name: Run Developer Tests (excluding AI) and Generate Coverage Report
id: dev_coverage
timeout-minutes: 45
env:
LLVM_PROFILE_FILE: dev-%p-%m.profraw
RUSTFLAGS: -Cinstrument-coverage
RUST_TEST_THREADS: 1
run: |
cargo hack llvm-cov --locked --lib --ignore-filename-regex "(src/api/routes/docs/.*_docs\.rs$|src/repositories/.*/.*_redis\.rs$)" --lcov --output-path dev-lcov.info --tests -- --skip ai_
- name: Run AI Tests and Generate Coverage Report
id: ai_coverage
timeout-minutes: 45
env:
LLVM_PROFILE_FILE: ai-%p-%m.profraw
RUSTFLAGS: -Cinstrument-coverage
RUST_TEST_THREADS: 1
run: |
cargo hack llvm-cov --locked --lib --ignore-filename-regex "(src/api/routes/docs/.*_docs\.rs$|src/repositories/.*/.*_redis\.rs$)" --lcov --output-path ai-lcov.info --tests -- ai_
# Upload coverage reports
- name: Upload AI Coverage to Codecov
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: ai-coverage
files: ai-lcov.info
flags: ai
fail_ci_if_error: true
- name: Upload Developer Coverage to Codecov
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: dev-coverage
files: dev-lcov.info
flags: dev
fail_ci_if_error: true
test-properties:
name: Properties Tests
if: ${{ github.event.pull_request.draft == false && needs.changed_files.outputs.changed-tests-files == 'true' }}
permissions:
contents: read
needs:
- changed_files
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: '20'
- name: Install pnpm and plugin dependencies
run: |
npm install -g pnpm
cd plugins
pnpm install
- name: Install TypeScript and ts-node
run: |
npm install -g typescript ts-node
ts-node --version
tsc --version
- name: free disk space
run: |
sudo swapoff -a
sudo rm -f /swapfile
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo apt clean
if [[ $(docker image ls -aq) ]]; then
docker rmi $(docker image ls -aq)
else
echo "No Docker images found to remove"
fi
- name: Prepare
id: init
uses: ./.github/actions/prepare
with:
components: llvm-tools-preview
- name: Get cache-hit output
run: 'echo "Cache hit >>>>>: ${{ steps.init.outputs.cache-hit }}"'
- name: Install cargo hack and cargo-llvm-cov
uses: taiki-e/install-action@cf39a74df4a72510be4e5b63348d61067f11e64a # v2.75.0
with:
tool: cargo-hack,cargo-llvm-cov
- name: Run Properties Tests and Generate Coverage Report
env:
LLVM_PROFILE_FILE: properties.profraw
RUSTFLAGS: -Cinstrument-coverage
RUST_TEST_THREADS: 1
CARGO_PROFILE_DEV_DEBUG: 1
run: cargo hack llvm-cov --locked --ignore-filename-regex "(src/api/routes/docs/.*_docs\.rs$|src/repositories/.*/.*_redis\.rs$)" --lcov --output-path properties-lcov.info --test properties
- name: Upload Properties Coverage to Codecov
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: properties-coverage
files: properties-lcov.info
flags: properties
fail_ci_if_error: true
docker-scan:
runs-on: ubuntu-latest
needs:
- changed_files
- ci
if: |
${{ github.event.pull_request.draft == false && needs.changed_files.outputs.changed-docker-files == 'true' }}
steps:
# Checkout the repository
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Build local container
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
tags: openzeppelin-relayer-dev:${{ github.sha }}
push: false
load: true
file: Dockerfile.development
platforms: linux/amd64
- name: Scan image
uses: anchore/scan-action@e1165082ffb1fe366ebaf02d8526e7c4989ea9d2 # v7.4.0
with:
image: openzeppelin-relayer-dev:${{ github.sha }}
fail-build: true
severity-cutoff: high
output-format: table