-
Notifications
You must be signed in to change notification settings - Fork 16
182 lines (162 loc) · 5.39 KB
/
Copy pathci.yml
File metadata and controls
182 lines (162 loc) · 5.39 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
name: Format and Verify VOSTD (Main)
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
inputs:
branch:
description: "Branch to run the workflow on"
required: true
default: "main"
jobs:
format-and-verify:
runs-on: ubuntu-24.04
env:
CARGO_TERM_COLOR: always
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
submodules: recursive
- name: Install dependencies
run: |
sudo apt update -qq
sudo apt install -y build-essential unzip pkg-config libssl-dev llvm
- name: Get Rust toolchain version
id: rust-toolchain
run: |
RUST_VERSION=$(grep 'channel' rust-toolchain.toml | sed -E 's/.*= *"(.*)"/\1/')
if [ -z "$RUST_VERSION" ]; then
echo "Failed to extract Rust version from rust-toolchain.toml"
exit 1
fi
echo "RUST_VERSION=$RUST_VERSION" >> "$GITHUB_ENV"
echo "Rust version: $RUST_VERSION"
- name: Cache Rust toolchain
uses: actions/cache@v6
with:
path: |
~/.rustup/toolchains
~/.rustup/update-hashes
~/.rustup/tmp
key: ${{ runner.os }}-rust-toolchain-${{ env.RUST_VERSION }}
- name: Cache Cargo dependencies
uses: actions/cache@v6
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Get Verus commit
id: verus
run: |
VERUS_COMMIT=$(git ls-remote https://github.com/asterinas/verus HEAD | cut -f1)
echo "VERUS_COMMIT=$VERUS_COMMIT" >> "$GITHUB_ENV"
echo "Using Verus commit: $VERUS_COMMIT"
DV_COMMIT=$(git rev-parse HEAD:dv)
echo "DV_COMMIT=$DV_COMMIT" >> "$GITHUB_ENV"
echo "Using dv commit: $DV_COMMIT"
- name: Cache dv build artifacts
uses: actions/cache@v6
with:
path: dv/target
key: ${{ runner.os }}-dv-${{ env.DV_COMMIT }}
- name: Cache Verus
id: cache-verus
uses: actions/cache@v6
with:
path: tools/verus
key: ${{ runner.os }}-verus-${{ env.VERUS_COMMIT }}
- name: Cache verusfmt
id: cache-verusfmt
uses: actions/cache@v6
with:
path: ~/.cargo/bin/verusfmt
key: ${{ runner.os }}-verusfmt-${{ env.VERUS_COMMIT }}
- name: Bootstrap Verus (if needed)
run: |
if [ "${{ steps.cache-verus.outputs.cache-hit }}" = "true" ]; then
echo "Using cached Verus"
else
echo "Cache miss, bootstrapping Verus..."
rm -rf tools/verus
cargo dv bootstrap
fi
if ! command -v verusfmt >/dev/null 2>&1; then
echo "verusfmt not found, installing via cargo dv bootstrap..."
cargo dv bootstrap
fi
verusfmt --version
- name: Run verification
run: |
set -o pipefail
if ! make 2>&1 | tee verify_output.txt; then
echo "❌ Verification failed"
echo "VERIFY_FAILED=1" >> "$GITHUB_ENV"
exit 1
else
echo "✅ Verification passed!"
fi
- name: Check for verification warnings
if: always()
run: |
WARNINGS=(
"note: automatically chose triggers for this expression:|auto-trigger notes"
"warning: use of deprecated method \`vstd::set::Set::<A>::finite\`|deprecated Set::finite()"
"warning: use of deprecated associated function \`vstd::set::Set::<A>::new_assuming_finite\`|deprecated Set::new_assuming_finite()"
)
FAILED=0
for ITEM in "${WARNINGS[@]}"; do
PATTERN="${ITEM%%|*}"
LABEL="${ITEM##*|}"
if grep -q "$PATTERN" verify_output.txt 2>/dev/null; then
echo "❌ Found $LABEL"
grep -n "$PATTERN" verify_output.txt
FAILED=1
else
echo "✅ No $LABEL found"
fi
done
if [[ "$FAILED" == "1" ]]; then
echo "VERIFY_WARNINGS_FOUND=1" >> "$GITHUB_ENV"
exit 1
fi
- name: Run format
if: always()
run: make fmt
- name: Check for formatting changes
if: always()
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "Code is not properly formatted. Run 'make fmt'."
git diff
echo "FMT_FAILED=1" >> "$GITHUB_ENV"
exit 1
fi
- name: Publish summary
if: always()
run: |
{
echo "# CI Summary"
if [[ "${FMT_FAILED:-0}" == "1" ]]; then
echo "- Formatting: ❌ failed"
else
echo "- Formatting: ✅ passed"
fi
if [[ "${VERIFY_FAILED:-0}" == "1" ]]; then
echo "- Verification: ❌ failed"
else
echo "- Verification: ✅ passed"
fi
if [[ "${VERIFY_WARNINGS_FOUND:-0}" == "1" ]]; then
echo "- Verification warnings: ❌ found"
else
echo "- Verification warnings: ✅ none"
fi
} >> "$GITHUB_STEP_SUMMARY"