Skip to content

Commit f015f8f

Browse files
authored
ci: improve signature verification (#977)
* ci: also pass the version when verifying signatures * Continue on failures, report all failed kernels * Move signature verification to a shell script
1 parent 19fc30f commit f015f8f

2 files changed

Lines changed: 42 additions & 16 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
KERNELS=$(find . -maxdepth 2 -name "build.toml" -exec dirname {} \; | sed 's|^\./||' | sort)
6+
7+
FAILED_LIST=/tmp/verify-failed
8+
: > "$FAILED_LIST"
9+
10+
{
11+
for kernel in $KERNELS; do
12+
echo "::group::$kernel"
13+
14+
VERSION=$(awk -F'[[:space:]]*=[[:space:]]*' '/^version/ {print $2; exit}' "$kernel/build.toml")
15+
16+
# Continue on failure to verify all kernels before reporting.
17+
if ! nix run -L github:huggingface/kernels#kernels -- \
18+
verify-signature --all-variants "kernels-community/$kernel" "$VERSION"; then
19+
echo "::warning::$kernel verification FAILED"
20+
echo "$kernel" >> "$FAILED_LIST"
21+
fi
22+
23+
# Remove the HF cache to reclaim disk space before the next kernel.
24+
rm -rf ~/.cache/huggingface/hub
25+
26+
echo "::endgroup::"
27+
done
28+
29+
FAILURES=$(wc -l < "$FAILED_LIST" | tr -d '[:space:]')
30+
echo ""
31+
if [ "$FAILURES" -ne 0 ]; then
32+
echo "❌ Verification failed for $FAILURES kernel(s):"
33+
sed 's/^/ - /' "$FAILED_LIST"
34+
echo ""
35+
echo "See the corresponding groups above for details."
36+
else
37+
echo "✅ All kernels verified successfully."
38+
fi
39+
} 2>&1 | tee /tmp/verify-output.log
40+
41+
[ -s "$FAILED_LIST" ] && exit 1 || exit 0

.github/workflows/verify-signatures.yaml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,7 @@ jobs:
3434
- name: Verify all kernels
3535
env:
3636
HF_TOKEN: ${{ secrets.HF_TOKEN }}
37-
run: |
38-
KERNELS=$(find . -maxdepth 2 -name "build.toml" -exec dirname {} \; | sed 's|^\./||' | sort)
39-
40-
{
41-
for kernel in $KERNELS; do
42-
echo "::group::$kernel"
43-
44-
nix run -L github:huggingface/kernels#kernels -- \
45-
verify-signature --all-variants "kernels-community/$kernel"
46-
47-
# Remove the HF cache to reclaim disk space before the next kernel.
48-
rm -rf ~/.cache/huggingface/hub
49-
50-
echo "::endgroup::"
51-
done
52-
} 2>&1 | tee /tmp/verify-output.log
37+
run: .github/scripts/verify-signatures.sh
5338

5439
- name: Post results to Slack
5540
if: always()

0 commit comments

Comments
 (0)