forked from logos-blockchain/logos-blockchain
-
Notifications
You must be signed in to change notification settings - Fork 0
209 lines (199 loc) · 7.68 KB
/
code-check.yml
File metadata and controls
209 lines (199 loc) · 7.68 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
on:
pull_request:
push:
branches: [ master ]
name: Code checks
concurrency:
group: ${{ github.workflow }}@${{ github.ref }}
cancel-in-progress: true
jobs:
check-dependencies-graph:
name: Check dependencies graph
strategy:
fail-fast: false
matrix:
os: [ self-hosted, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # Version 4.2.2
- name: Install cargo-depgraph
run: cargo install cargo-depgraph@1.6.0
- name: Generate new graph
run: cargo depgraph --all-deps --dedup-transitive-deps --workspace-only --all-features > ${{ runner.temp }}/dependencies_graph.dot
- name: Compare dependency graphs
run: |
diff dependencies_graph.dot ${{ runner.temp }}/dependencies_graph.dot || exit 1
formatting:
name: Check formatting
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # Version 4.2.2
- name: Install nightly toolchain
uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # Version 1.0.6
with:
# The same version must be used in the `.pre-commit-config.yaml` file
toolchain: nightly-2025-02-16
profile: minimal
components: rustfmt
override: true
- name: Run cargo fmt
uses: actions-rs/cargo@9e120dd99b0fbad1c065f686657e914e76bd7b72 # Version 1.0.1
with:
command: fmt
args: --all --check
cargo-deny:
name: Check cargo-deny rules
# `cargo-deny` action is only supported on Linux
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # Version 4.2.2
- name: Run `cargo deny`
uses: EmbarkStudios/cargo-deny-action@34899fc7ba81ca6268d5947a7a16b4649013fea1 # Version 2.0.11
with:
# All is set in the config file
arguments:
command-arguments: "--hide-inclusion-graph -c .cargo-deny.toml --show-stats -D warnings"
features:
name: Check packages feature combinations
strategy:
fail-fast: false
matrix:
os: [ self-hosted, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # Version 4.2.2
- name: Install cargo-hack
uses: taiki-e/install-action@5651179950649c44da31d346537e20c0534f0f25 # Version 2.49.35
with:
tool: cargo-hack
- name: Set up Cargo cache
uses: ./.github/actions/setup-cargo-cache
with:
key: ${{ github.ref }}->${{ github.workflow }}->${{ github.job }}->${{ matrix.os }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run cargo-hack
env:
RISC0_SKIP_BUILD: true
RUSTFLAGS: -D warnings
run: cargo hack --feature-powerset --no-dev-deps check
- name: Update Cargo cache
if: success() || failure()
uses: ./.github/actions/update-cargo-cache
with:
key: ${{ github.ref }}->${{ github.workflow }}->${{ github.job }}->${{ matrix.os }}
unused-deps:
name: Check for unused dependencies
strategy:
fail-fast: false
matrix:
os: [ self-hosted, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # Version 4.2.2
- name: Install cargo-machete
uses: bnjbvr/cargo-machete@9f0895d780783da0089162cae9668f6ec6e896c4 # Version 0.8.0
# This step also runs `cargo-machete` without the `--with-metadata` flag, which can trigger more false positives.
# We ignore errors and run `cargo-machete` with the `--with-metadata` flag for the actual result.
continue-on-error: true
- name: Run cargo-machete
run: cargo machete --with-metadata
lints:
name: Check Rust lints
strategy:
fail-fast: false
matrix:
os: [ self-hosted, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # Version 4.2.2
- name: Set up Cargo cache
uses: ./.github/actions/setup-cargo-cache
with:
key: ${{ github.ref }}->${{ github.workflow }}->${{ github.job }}->${{ matrix.os }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run cargo clippy
uses: actions-rs/cargo@9e120dd99b0fbad1c065f686657e914e76bd7b72 # Version 1.0.1
env:
RISC0_SKIP_BUILD: true
with:
command: clippy
args: --all --all-targets --all-features -- -D warnings
- name: Update Cargo cache
if: success() || failure()
uses: ./.github/actions/update-cargo-cache
with:
key: ${{ github.ref }}->${{ github.workflow }}->${{ github.job }}->${{ matrix.os }}
tests:
name: Run test suite
if: ${{ !startsWith(github.event.pull_request.title, '[WIP]') && !contains(github.event.label.name, 'DO NOT MERGE') }}
strategy:
fail-fast: false # all OSes should be tested even if one fails (default: true)
matrix:
os: [ self-hosted, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # Version 4.2.2
- name: Install risc0 dependencies
uses: ./.github/actions/install-risc0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Cargo cache
uses: ./.github/actions/setup-cargo-cache
with:
key: ${{ github.ref }}->${{ github.workflow }}->${{ github.job }}->${{ matrix.os }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build required binaries
uses: actions-rs/cargo@9e120dd99b0fbad1c065f686657e914e76bd7b72 # Version 1.0.1
with:
command: build
args: --all-features -p nomos-node -p nomos-executor
- name: Cargo test
uses: actions-rs/cargo@9e120dd99b0fbad1c065f686657e914e76bd7b72 # Version 1.0.1
env:
RISC0_DEV_MODE: true
CONSENSUS_SLOT_TIME: 5
with:
command: test
# We don't test benches as they take 6h+, leading to a timeout
args: --all --lib --bins --tests --examples --all-features
- name: Update Cargo cache
if: success() || failure()
uses: ./.github/actions/update-cargo-cache
with:
key: ${{ github.ref }}->${{ github.workflow }}->${{ github.job }}->${{ matrix.os }}
- name: Upload integration tests results
uses: actions/upload-artifact@6027e3dd177782cd8ab9af838c04fd81a07f1d47 # Version 4.6.2
if: failure()
with:
name: integration-test-artifacts
path: tests/.tmp*
build-docker:
name: Trigger Docker build
runs-on: ubuntu-latest
needs:
- formatting
- cargo-deny
- features
- unused-deps
- lints
- tests
env:
DOCKER_BUILD_WORKFLOW_FILE: build-docker.yml # Change this in case of file renamings
steps:
- name: Trigger "Docker build" workflow
uses: actions/github-script@3908079ba1e7bce10117ad701c321d07e89017a9 # Version 7.0.1
with:
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: '${{ env.DOCKER_BUILD_WORKFLOW_FILE }}',
ref: '${{ github.head_ref || github.ref }}',
})