@@ -95,10 +95,11 @@ jobs:
9595 name : Check unsafe blocks
9696 runs-on : ubuntu-latest
9797 steps :
98- - name : Checkout
98+ - name : Checkout base branch
9999 uses : actions/checkout@v3
100100 with :
101101 submodules : recursive
102+ ref : ${{ github.event.pull_request.base.sha }}
102103
103104 - name : Install specified rust toolchain
104105 run : rustup toolchain install --profile minimal
@@ -112,28 +113,27 @@ jobs:
112113 - name : Build
113114 run : make FEATURES="default,enable-gdb" STAGE1_RUSTC_ARGS="--emit=obj -C linker=/usr/bin/true" stage1_elf_full stage1_elf_trampoline
114115
115- - name : Clippy with undocumented_unsafe_blocks for PR branch
116+ - name : Clippy with undocumented_unsafe_blocks for base branch
116117 run : |
117- cargo clippy --all-features --package svsm --target=x86_64-unknown-none -- quiet -- -W clippy::undocumented_unsafe_blocks 2> clippy_warnings_pr .txt || ( cat clippy_warnings_pr .txt; exit 1 )
118+ make clippy CLIPPY_OPTIONS=-- quiet UNSAFE_BLOCKS=1 2> clippy_warnings_base .txt || ( cat clippy_warnings_base .txt; exit 1 )
118119
119120 # Required because after the next checkout everything is removed.
120- - name : Upload PR warnings artifact
121+ - name : Upload base warnings artifact
121122 uses : actions/upload-artifact@v4
122123 with :
123- name : clippy-warnings-pr
124- path : clippy_warnings_pr .txt
124+ name : clippy-warnings-base
125+ path : clippy_warnings_base .txt
125126
126127 # Ensure submodules are rebuilt correctly
127128 - name : Clean workspace
128129 run : |
129130 git clean -xdf
130131 git submodule foreach git clean -xdf
131132
132- - name : Checkout base branch
133+ - name : Checkout
133134 uses : actions/checkout@v3
134135 with :
135136 submodules : recursive
136- ref : ${{ github.event.pull_request.base.sha }}
137137
138138 - name : Install specified rust toolchain for the base branch
139139 run : rustup toolchain install --profile minimal
@@ -144,26 +144,26 @@ jobs:
144144 - name : Build base branch
145145 run : make FEATURES="default,enable-gdb" STAGE1_RUSTC_ARGS="--emit=obj -C linker=/usr/bin/true" stage1_elf_full stage1_elf_trampoline
146146
147- - name : Clippy with undocumented_unsafe_blocks for base branch
147+ - name : Clippy with undocumented_unsafe_blocks for PR branch
148148 run : |
149- cargo clippy --all-features --package svsm --target=x86_64-unknown-none -- quiet -- -W clippy::undocumented_unsafe_blocks 2> clippy_warnings_base .txt || ( cat clippy_warnings_base .txt; exit 1 )
149+ make clippy CLIPPY_OPTIONS=-- quiet UNSAFE_BLOCKS=1 2> clippy_warnings_pr .txt || ( cat clippy_warnings_pr .txt; exit 1 )
150150
151- - name : Download PR warnings artifact
151+ - name : Download base warnings artifact
152152 uses : actions/download-artifact@v4
153153 with :
154- name : clippy-warnings-pr
154+ name : clippy-warnings-base
155155
156156 - name : Check new undocumented unsafe blocks
157157 run : |
158- PR_WARNINGS=$(grep 'missing a safety comment' clippy_warnings_pr.txt | wc -l )
159- BASE_WARNINGS=$(grep 'missing a safety comment' clippy_warnings_base.txt | wc -l )
158+ PR_WARNINGS=$(${GITHUB_WORKSPACE}/scripts/unsafe_blocks_report.sh -q -m -f clippy_warnings_pr.txt)
159+ BASE_WARNINGS=$(${GITHUB_WORKSPACE}/scripts/unsafe_blocks_report.sh -q -m -f clippy_warnings_base.txt)
160160
161161 echo "Undocumented unsafe code blocks [PR: $PR_WARNINGS base: $BASE_WARNINGS]"
162162
163163 if [ "$PR_WARNINGS" -gt "$BASE_WARNINGS" ]; then
164164 echo "ERROR: $(($PR_WARNINGS - $BASE_WARNINGS)) new undocumented unsafe code blocks detected in this PR"
165165 echo "enabling the clippy::undocumented_unsafe_blocks lint in this way:"
166- echo "$ cargo clippy --all-features --package svsm --target=x86_64-unknown-none -- -W clippy::undocumented_unsafe-blocks "
166+ echo "$ make clippy UNSAFE_BLOCKS=1 "
167167 echo ""
168168 diff --color -u clippy_warnings_base.txt clippy_warnings_pr.txt
169169 exit 1
0 commit comments