-
Notifications
You must be signed in to change notification settings - Fork 571
250 lines (229 loc) · 8.26 KB
/
rust.yml
File metadata and controls
250 lines (229 loc) · 8.26 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
name: rust
on:
# Triggers the workflow on pushes to main branch
push:
branches: [main]
# Triggers on pull requests
pull_request:
branches:
- '*'
merge_group:
workflow_dispatch:
concurrency:
group: rust-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
MIN_LANDERCOVERAGE_PERCENTAGE: 15
RUSTC_WRAPPER: sccache
jobs:
ts-only:
runs-on: ubuntu-latest
outputs:
skip_rust: ${{ steps.decide.outputs.skip_rust }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check CI context
id: context
uses: ./.github/actions/ci-context-check
- name: Decide whether to skip rust jobs
id: decide
run: |
echo "Context: ${{ steps.context.outputs.reason }}"
if [[ "${{ steps.context.outputs.should_skip }}" == "true" ]]; then
echo "skip_rust=true" >> $GITHUB_OUTPUT
exit 0
fi
if [[ "${{ steps.context.outputs.must_run }}" == "true" ]]; then
echo "skip_rust=false" >> $GITHUB_OUTPUT
exit 0
fi
# Check path changes for PRs
BASE_REF="${{ github.base_ref }}"
if [[ -z "$BASE_REF" ]]; then
BASE_REF="HEAD~1"
else
BASE_REF="origin/$BASE_REF"
fi
if ! CHANGED_FILES=$(git diff --name-only "$BASE_REF"...HEAD); then
echo "::warning::Git diff failed, defaulting to run rust tests"
echo "skip_rust=false" >> $GITHUB_OUTPUT
exit 0
fi
if echo "$CHANGED_FILES" | grep -qE '^(rust/|\.github/workflows/|\.github/actions/)'; then
echo "skip_rust=false" >> $GITHUB_OUTPUT
else
echo "skip_rust=true" >> $GITHUB_OUTPUT
fi
lander-coverage-run:
needs: [ts-only]
if: needs.ts-only.outputs.skip_rust != 'true'
runs-on: depot-ubuntu-24.04-8
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- uses: dtolnay/rust-toolchain@stable
- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Install cargo-llvm-cov
run: |
cargo install [email protected] --locked
rustup component add llvm-tools-preview
- name: Generate coverage for lander package
run: cargo llvm-cov --package lander --features aleo,integration_test --json --output-path coverage.json
working-directory: ./rust/main
- name: Check coverage threshold
run: |
COVERAGE=$(cat coverage.json | jq -r '.data[0].totals.lines.percent')
echo "Coverage: $COVERAGE%"
if (( $(echo "$COVERAGE < $MIN_LANDERCOVERAGE_PERCENTAGE" | bc -l) )); then
echo "Code coverage is below minimum threshold of $MIN_LANDERCOVERAGE_PERCENTAGE percent"
exit 1
fi
working-directory: ./rust/main
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: coverage.json
flags: ./rust/main/lander
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
test-rs-run:
needs: [ts-only]
if: needs.ts-only.outputs.skip_rust != 'true'
runs-on: depot-ubuntu-24.04-8
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- uses: dtolnay/rust-toolchain@stable
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libudev-dev
- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Install mold linker
uses: rui314/setup-mold@v1
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Run tests for main workspace
run: cargo test --all-targets --features aleo,integration_test
working-directory: ./rust/main
- name: Run tests for sealevel workspace
run: cargo test
working-directory: ./rust/sealevel
lint-rs-run:
needs: [ts-only]
if: needs.ts-only.outputs.skip_rust != 'true'
runs-on: depot-ubuntu-24.04-8
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
target: wasm32-unknown-unknown
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libudev-dev
- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Check for main workspace
run: cargo check --release --all-features --all-targets
working-directory: ./rust/main
- name: Check for sealevel workspace
run: cargo check --release --all-features --all-targets
working-directory: ./rust/sealevel
- name: Check Cargo.lock files are up to date
run: |
CHANGES=$(git status -s --ignore-submodules -- rust/main/Cargo.lock rust/sealevel/Cargo.lock)
if [[ ! -z $CHANGES ]]; then
echo "❌ Cargo.lock files are out of sync with Cargo.toml files"
echo ""
echo "$CHANGES" | while read status file; do
echo "::group::$file changes"
git diff "$file"
echo "::endgroup::"
if [[ "$file" == *"main"* ]]; then
echo "- $file needs to be updated"
echo " Run: cd rust/main && cargo build"
elif [[ "$file" == *"sealevel"* ]]; then
echo "- $file needs to be updated"
echo " Run: cd rust/sealevel && cargo build"
fi
done
echo ""
echo "Please commit the updated Cargo.lock file(s)"
exit 1
fi
- name: Rustfmt for main workspace
run: cargo fmt --all -- --check
working-directory: ./rust/main
- name: Rustfmt for sealevel workspace
run: cargo fmt --all --check
working-directory: ./rust/sealevel
- name: Clippy for main workspace
run: cargo clippy --features aleo,integration_test -- -D warnings
working-directory: ./rust/main
- name: Clippy for sealevel workspace
run: cargo clippy -- -D warnings
working-directory: ./rust/sealevel
- name: Setup WASM for main workspace
run: rustup target add wasm32-unknown-unknown
working-directory: ./rust/main
- name: Check WASM for hyperlane-core
run: cargo check --release -p hyperlane-core --features=strum,test-utils --target wasm32-unknown-unknown
working-directory: ./rust/main
# Wrapper jobs for required status checks (report success when skipped)
lander-coverage:
runs-on: ubuntu-latest
needs: [lander-coverage-run]
if: always()
steps:
- uses: actions/checkout@v6
- name: Check lander-coverage status
uses: ./.github/actions/check-job-status
with:
job_name: 'Lander Coverage'
result: ${{ needs.lander-coverage-run.result }}
test-rs:
runs-on: ubuntu-latest
needs: [test-rs-run]
if: always()
steps:
- uses: actions/checkout@v6
- name: Check test-rs status
uses: ./.github/actions/check-job-status
with:
job_name: 'Rust Tests'
result: ${{ needs.test-rs-run.result }}
lint-rs:
runs-on: ubuntu-latest
needs: [lint-rs-run]
if: always()
steps:
- uses: actions/checkout@v6
- name: Check lint-rs status
uses: ./.github/actions/check-job-status
with:
job_name: 'Rust Lint'
result: ${{ needs.lint-rs-run.result }}