Skip to content

Commit 17da107

Browse files
committed
chore: add public history hygiene gate
1 parent 8a1b607 commit 17da107

3 files changed

Lines changed: 88 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,29 @@ name: CI
22

33
on:
44
workflow_dispatch:
5+
push:
6+
branches: [master]
7+
pull_request:
8+
branches: [master]
59

610
env:
711
CARGO_TERM_COLOR: always
812

913
jobs:
14+
hygiene:
15+
name: Hygiene
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Check public tree contains no dev-meta paths
22+
shell: bash
23+
run: ./scripts/check_tree_clean.sh
24+
1025
test:
1126
name: Test
27+
needs: hygiene
1228
runs-on: ${{ matrix.os }}
1329
strategy:
1430
matrix:
@@ -70,6 +86,7 @@ jobs:
7086

7187
build:
7288
name: Build Release
89+
needs: hygiene
7390
runs-on: ${{ matrix.os }}
7491
strategy:
7592
matrix:
@@ -121,6 +138,7 @@ jobs:
121138

122139
gui-build:
123140
name: GUI Build
141+
needs: hygiene
124142
runs-on: ${{ matrix.os }}
125143
strategy:
126144
matrix:
@@ -184,6 +202,7 @@ jobs:
184202

185203
benchmarks:
186204
name: Benchmarks
205+
needs: hygiene
187206
runs-on: ubuntu-latest
188207
steps:
189208
- name: Checkout code

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,11 @@ repos:
44
hooks:
55
- id: clippy
66
args: [--all-targets, --all-features, --, "-D", "warnings"]
7+
- repo: local
8+
hooks:
9+
- id: tree-clean
10+
name: no dev-meta paths tracked
11+
entry: scripts/check_tree_clean.sh
12+
language: system
13+
pass_filenames: false
14+
always_run: true

scripts/check_tree_clean.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
DENYLIST_HASHES=(
5+
"bccc86317c281a19e56f3f941077ea61b3fb37d5bd527c518b92b188c4461251"
6+
"b951327c37d8a1ed4d5ed18908681f6aca718ecdfe174aa39cf2237547f92fe7"
7+
"0bbe5bc4573bcf1caa8ba13b58efe7c468bb397ddfe2f5a83f9c76ba92cec5b4"
8+
"4242c7f6d3a7e888936effebac1bf59c25837e071968fddfd885dbd6feaba149"
9+
"8f460fc4d894021da121ecbf60c078b0a1cea232a2044fb2baa81d1af3e12337"
10+
"6f3dfaf03456fbf15f47e5374445a2709ab8149a40458d63842437838cc0d03b"
11+
"e026f56c08dcdea441a2aa620ab410ce91162062609b2430f5a13bc9b7cf93f1"
12+
"2b6873defee36f1396d6a35f01c1e229cddc1db58fb19aea9bd3f7912eac5b9d"
13+
"9ddde294843122274ad7332e61e57115775231c42d62e0fa4cca1dd30b90a34c"
14+
"3672100d780398d595025e75fc0fa20be4d7656c674b9900ce60959bf1c3a28b"
15+
"9bcb07239d88ef7c87f733534fdf5fee50fb213e115cebb1cd8f4b519c2186f1"
16+
"359cec2f69d14ac180b92598e4463e10c2d8f22ff5388bcf19b0411f86fbedae"
17+
"24f818c99965183008b728f1585e20a3923e08ebd68dc577245b10d01752499f"
18+
"7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519"
19+
"053150b640a7ce75eff69d1a22cae7f0f94ad64ce9a855db544dda0929316519"
20+
"32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bb"
21+
"385bfa2b4522184962dd7592b5877648b51c6c0c0975d8ff0b388f552702fb29"
22+
"ac7148ee4d01e3aed55f1fe8177f2ac48494689fa83a15a74dfa03243799921c"
23+
)
24+
25+
if [ "${#DENYLIST_HASHES[@]}" -eq 0 ]; then
26+
echo "No denylist hashes configured" >&2
27+
exit 2
28+
fi
29+
30+
fail=0
31+
32+
hash_norm() {
33+
printf '%s' "$1" | shasum -a 256 | awk '{print $1}'
34+
}
35+
36+
is_denied_hash() {
37+
local hash="$1"
38+
local denied
39+
for denied in "${DENYLIST_HASHES[@]}"; do
40+
[ "$hash" = "$denied" ] && return 0
41+
done
42+
return 1
43+
}
44+
45+
while IFS= read -r tracked || [ -n "$tracked" ]; do
46+
norm="$(printf '%s' "$tracked" | tr '[:upper:]' '[:lower:]' | sed 's:/*$::')"
47+
probe="$norm"
48+
while [ -n "$probe" ] && [ "$probe" != "." ]; do
49+
if is_denied_hash "$(hash_norm "$probe")"; then
50+
echo "DENYLISTED PATH TRACKED: $tracked" >&2
51+
fail=1
52+
break
53+
fi
54+
case "$probe" in
55+
*/*) probe="${probe%/*}" ;;
56+
*) break ;;
57+
esac
58+
done
59+
done < <(git ls-files)
60+
61+
exit "$fail"

0 commit comments

Comments
 (0)