-
Notifications
You must be signed in to change notification settings - Fork 44
197 lines (164 loc) · 6.99 KB
/
rust.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
name: Rust
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install specified rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: '1.82.0'
target: x86_64-unknown-none
profile: minimal
override: true
components: rustfmt, rust-src, clippy
- name: Install TPM 2.0 Reference Implementation build dependencies
run: sudo apt install -y autoconf autoconf-archive pkg-config build-essential automake
- name: Check that Cargo.lock is up to date
uses: actions-rs/cargo@v1
with:
command: update
args: --workspace --locked
# ubuntu-latest does not have binutils 2.39, which we need for
# ld to work, so build all the objects without performing the
# final linking step.
- name: Build
run: make FEATURES="default,enable-gdb" STAGE1_RUSTC_ARGS="--emit=obj -C linker=/usr/bin/true" stage1_elf_full stage1_elf_trampoline
- name: Run tests
run: make test
- name: Format
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Clippy on no_std x86_64-unknown-none
uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --exclude igvmbuilder --exclude igvmmeasure --exclude svsm-fuzz --exclude packit --exclude stage1 --all-features -- -D warnings
- name: Clippy on std x86_64-unknown-linux-gnu
uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --all-features --exclude svsm --exclude svsm-fuzz --exclude packit --exclude stage1 --target=x86_64-unknown-linux-gnu -- -D warnings
- name: Clippy on stage1
uses: actions-rs/cargo@v1
with:
command: clippy
args: --package stage1 --all-features --target=x86_64-unknown-linux-gnu -- -D warnings -C panic=abort
- name: Clippy on svsm-fuzz
uses: actions-rs/cargo@v1
with:
command: clippy
args: --package svsm-fuzz --all-features --target=x86_64-unknown-linux-gnu -- -D warnings
env:
RUSTFLAGS: --cfg fuzzing
- name: Clippy on tests
uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --exclude packit --exclude user* --all-features --tests --target=x86_64-unknown-linux-gnu -- -D warnings
- name: Check documentation
run: make doc
env:
RUSTDOCFLAGS: -D warnings
nightly-check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: x86_64-unknown-none
profile: minimal
override: true
components: rustfmt
# The bindings.rs is auto-generated during make, but we are not
# building the code with nightly. So we initialize bindings.rs here
# for cargo-fmt in the next workflow, otherwise it will fail reporting
# that bindings.rs does not exist.
- name: Touch libtcgtpm bindings
run: echo "" > libtcgtpm/src/bindings.rs
- name: Format doctests
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check --config "format_code_in_doc_comments=true"
# Check for new undocumented unsafe blocks. This is to prevent them from
# growing before we add comments for all of them and manage to enable
# `clippy::undocumented_unsafe_blocks` lint.
#
# Progress documented at https://github.com/coconut-svsm/svsm/issues/228.
# When we fix that issue, we may remove this pipeline.
unsafe-check:
name: Check unsafe blocks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install specified rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: '1.82.0'
target: x86_64-unknown-none
profile: minimal
override: true
components: rustfmt, rust-src, clippy
- name: Install TPM 2.0 Reference Implementation build dependencies
run: sudo apt install -y autoconf autoconf-archive pkg-config build-essential automake
- name: Build
run: make FEATURES="default,enable-gdb" STAGE1_RUSTC_ARGS="--emit=obj -C linker=/usr/bin/true" stage1_elf_full stage1_elf_trampoline
- name: Clippy with undocumented_unsafe_blocks for PR branch
run: |
cargo clippy --workspace --all-features --exclude packit --exclude stage1 --exclude svsm-fuzz --exclude igvmbuilder --exclude igvmmeasure --quiet -- -W clippy::undocumented_unsafe_blocks 2> clippy_warnings_pr.txt
# Required because after the next checkout everything is removed.
- name: Upload PR warnings artifact
uses: actions/upload-artifact@v3
with:
name: clippy-warnings-pr
path: clippy_warnings_pr.txt
- name: Checkout base branch
uses: actions/checkout@v3
with:
submodules: recursive
ref: ${{ github.event.pull_request.base.sha }}
- name: Build base branch
run: make FEATURES="default,enable-gdb" STAGE1_RUSTC_ARGS="--emit=obj -C linker=/usr/bin/true" stage1_elf_full stage1_elf_trampoline
- name: Clippy with undocumented_unsafe_blocks for base branch
run: |
cargo clippy --workspace --all-features --exclude packit --exclude stage1 --exclude svsm-fuzz --exclude igvmbuilder --exclude igvmmeasure --quiet -- -W clippy::undocumented_unsafe_blocks 2> clippy_warnings_base.txt
- name: Download PR warnings artifact
uses: actions/download-artifact@v3
with:
name: clippy-warnings-pr
- name: Check new undocumented unsafe blocks
run: |
PR_WARNINGS=$(grep 'missing a safety comment' clippy_warnings_pr.txt | wc -l)
BASE_WARNINGS=$(grep 'missing a safety comment' clippy_warnings_base.txt | wc -l)
echo "Undocumented unsafe code blocks [PR: $PR_WARNINGS base: $BASE_WARNINGS]"
if [ "$PR_WARNINGS" -gt "$BASE_WARNINGS" ]; then
echo "ERROR: $(($PR_WARNINGS - $BASE_WARNINGS)) new undocumented unsafe code blocks detected in this PR"
echo "enabling the clippy::undocumented_unsafe_blocks lint in this way:"
echo "$ cargo clippy --workspace --all-features --exclude packit --exclude stage1 --exclude svsm-fuzz \\"
echo " --exclude igvmbuilder --exclude igvmmeasure -- -W clippy::undocumented_unsafe_blocks"
echo ""
diff --color -u clippy_warnings_base.txt clippy_warnings_pr.txt
exit 1
fi