Commit 2ad10db8d2

2ad10db8d218a3cd7ced619f8031528fb94192e3

parent: 3ab7f2067d

Unsigned

cmc <hello@cleberg.net> · 2026-11-04 01:20 UTC

Run the accessibility audit before the push, not inside it (!72)

git opens the connection before running pre-push, and gitbay kills a push that moves no data for a minute (`DefaultPushIdle`) or has not reached pre-receive fifteen minutes after taking its slot (`DefaultPushReceiveTimeout`). The audit takes about twenty minutes, so every push it gated failed after the suite passed.

- `Scripts/audit-a11y.sh` (both tiers, clean tree) records `HEAD^{tree}` in `a11y-audit-passed` under the common git dir.
- `.githooks/pre-push` keeps the qlty ratchet and refuses a push of Swift or project changes whose tree has no recorded pass.
- `Scripts/lib/audit-pass.sh` holds the path regex and file location for both.
- README and `Docs/ACCESSIBILITY.txt` updated.

Exercised in a scratch clone: docs-only push skips; Swift push without a pass is refused, with one is allowed; with a stubbed `xcodebuild`, a clean both-tier pass records, an untracked Swift file or a tracked change does not, an untracked doc does not block it, and floor-only or failing runs record nothing.

Layout: unified · split

.githooks/pre-push +32 −26
@@ -1,20 +1,23 @@
1#!/usr/bin/env bash 1#!/usr/bin/env bash
2# 2#
3# Run the complexity ratchet and the accessibility audit against the oldest 3# Run the complexity ratchet, and refuse a push whose tree has no recorded
4# supported simulator runtime before pushing. 4# accessibility audit pass.
5# 5#
6# Enable once per clone: 6# Enable once per clone:
7# git config core.hooksPath .githooks 7# git config core.hooksPath .githooks
8# 8#
9# Why pre-push and not pre-commit: the suite takes around ten minutes per 9# The audit runs before the push, not here: `./Scripts/audit-a11y.sh` on a
10# runtime. At pre-commit that blocks every commit, and a hook you routinely 10# clean tree records the tree it passed on, and this hook looks it up. git opens
11# bypass with --no-verify is worse than no hook, because it trains you to ignore 11# the connection before running pre-push, and gitbay kills a push that moves no
12# it. Pushes are far less frequent and map to the unit of work. 12# data for a minute or has not reached pre-receive fifteen minutes after taking
13# its slot. The suite takes around twenty minutes, so run inside the hook it
14# failed every push it gated.
13# 15#
14# Why both tiers: audit coverage is not nested across OS versions — each runtime 16# Why both tiers: audit coverage is not nested across OS versions — each runtime
15# reports findings the others miss, in both directions, which 17# reports findings the others miss, in both directions, which
16# Docs/ACCESSIBILITY.txt records per screen. There is no CI, so a tier this does 18# Docs/ACCESSIBILITY.txt records per screen. There is no CI, so a tier that is
17# not run is not run at all, and an enforced failure on it reaches main. 19# not run is not run at all, and an enforced failure on it reaches main. Only a
20# run of both tiers is recorded.
18# 21#
19# Why the hook runs qlty at all: nothing else does. This repository's origin is 22# Why the hook runs qlty at all: nothing else does. This repository's origin is
20# gitbay, which has no build configured, so the smell gates in .qlty/qlty.toml 23# gitbay, which has no build configured, so the smell gates in .qlty/qlty.toml
@@ -28,8 +31,11 @@ set -euo pipefail
28repo_root=$(git rev-parse --show-toplevel) 31repo_root=$(git rev-parse --show-toplevel)
29cd "$repo_root" 32cd "$repo_root"
30 33
34# shellcheck source=../Scripts/lib/audit-pass.sh
35source Scripts/lib/audit-pass.sh
36
31zero='0000000000000000000000000000000000000000' 37zero='0000000000000000000000000000000000000000'
32changed='' 38needs_audit=''
33 39
34# stdin: <local ref> <local sha> <remote ref> <remote sha>, one line per ref. 40# stdin: <local ref> <local sha> <remote ref> <remote sha>, one line per ref.
35while read -r _local_ref local_sha _remote_ref remote_sha; do 41while read -r _local_ref local_sha _remote_ref remote_sha; do
@@ -43,15 +49,12 @@ while read -r _local_ref local_sha _remote_ref remote_sha; do
43 range="$remote_sha..$local_sha" 49 range="$remote_sha..$local_sha"
44 fi 50 fi
45 51
46 changed="$changed$(git diff --name-only "$range" 2>/dev/null || true)"$'\n' 52 if git diff --name-only "$range" 2>/dev/null | grep -qE "$AUDIT_INPUTS"; then
53 needs_audit="$needs_audit $local_sha"
54 fi
47done 55done
48 56
49if [ -z "$(printf '%s' "$changed" | tr -d '[:space:]')" ]; then 57if [ -z "$needs_audit" ]; then
50 exit 0
51fi
52
53# Only pay the ~85s when something could actually change the rendered UI.
54if ! printf '%s' "$changed" | grep -qE '\.(swift|xcassets|xcodeproj)|\.pbxproj|xcscheme'; then
55 echo "pre-push: no Swift/project changes, skipping accessibility audit" 58 echo "pre-push: no Swift/project changes, skipping accessibility audit"
56 exit 0 59 exit 0
57fi 60fi
@@ -101,18 +104,21 @@ print(sum(
101 fi 104 fi
102fi 105fi
103 106
104echo "pre-push: running accessibility audit on both runtimes (~20 min)" 107passes=$(audit_pass_file)
105echo " skip with 'git push --no-verify'" 108missing=''
109for sha in $needs_audit; do
110 grep -qxF "$(git rev-parse "$sha^{tree}")" "$passes" 2>/dev/null || missing="$missing $sha"
111done
106 112
107if ! ./Scripts/audit-a11y.sh; then 113if [ -n "$missing" ]; then
108 echo 114 echo "pre-push: no recorded accessibility audit pass for:" >&2
109 echo "pre-push: accessibility audit failed. Push aborted." >&2 115 for sha in $missing; do
110 echo " Re-run with './Scripts/audit-a11y.sh' to see which tier and" >&2 116 echo " $(git log -1 --format='%h %s' "$sha")" >&2
111 echo " which screen, or bypass with 'git push --no-verify'." >&2 117 done
118 echo " Check it out with a clean tree, run './Scripts/audit-a11y.sh'," >&2
119 echo " then push again. Bypass with 'git push --no-verify'." >&2
112 exit 1 120 exit 1
113fi 121fi
114 122
115# Note: findings are reported, not enforced, so a clean exit here does not mean 123echo "pre-push: accessibility audit passed on this tree"
116# zero findings — read the list above. Enforcement is controlled by
117# AccessibilityAuditHarness.enforcedAuditTypes.
118exit 0 124exit 0
Docs/ACCESSIBILITY.txt +19 −13
@@ -538,7 +538,7 @@ target had left in the app's container was still there.
538That made the result depend on what ran before it. `testTrackedDomainsScreen` 538That made the result depend on what ran before it. `testTrackedDomainsScreen`
539passed with one finding in isolation, and reported six — including an enforced 539passed with one finding in isolation, and reported six — including an enforced
540`[FAIL][dynamicType]` on `EditButton`, which only renders when the watchlist has 540`[FAIL][dynamicType]` on `EditButton`, which only renders when the watchlist has
541rows — during a full `xcodebuild test`, which is what the pre-push hook runs. 541rows — during a full `xcodebuild test`, which is what `Scripts/audit-a11y.sh` runs.
542 542
543**A correction to what this file said first.** The initial note blamed the 543**A correction to what this file said first.** The initial note blamed the
544seeded fixtures. That was wrong: `seedAuditFixturesIfRequested` writes only to 544seeded fixtures. That was wrong: `seedAuditFixturesIfRequested` writes only to
@@ -583,7 +583,8 @@ no single number is correct on both.
583 583
584The audit therefore runs locally, across both ends, via 584The audit therefore runs locally, across both ends, via
585`Scripts/audit-a11y.sh` — on a machine that actually has an 18.x runtime 585`Scripts/audit-a11y.sh` — on a machine that actually has an 18.x runtime
586installed. The pre-push hook in `.githooks/` runs both of them. 586installed. The pre-push hook in `.githooks/` refuses a push without a recorded
587pass of both.
587 588
588There is no CI job. The GitHub Actions workflow that used to run this suite on 589There is no CI job. The GitHub Actions workflow that used to run this suite on
589the newest runtime has been removed, and with it the one check that no local run 590the newest runtime has been removed, and with it the one check that no local run
@@ -618,19 +619,24 @@ so rather than implying floor coverage it does not have.
618git config core.hooksPath .githooks 619git config core.hooksPath .githooks
619``` 620```
620 621
621Runs the complexity ratchet, then the audit on **both** runtimes, before a push, 622Runs the complexity ratchet, then refuses the push unless the tree being pushed
622and only when Swift, asset, or project files changed. Bypass with 623has a recorded audit pass, when Swift, asset, or project files changed. Bypass
623`git push --no-verify`. 624with `git push --no-verify`.
625
626Run the audit before pushing. `./Scripts/audit-a11y.sh` with no argument, on a
627tree with no tracked changes and no untracked Swift, asset or project files,
628appends `HEAD^{tree}` to `a11y-audit-passed` in the common git dir when both
629tiers pass. A squash or rebase that keeps the tree keeps the pass.
630
631The hook does not run the suite itself because git opens the connection before
632pre-push runs, and gitbay kills a push that moves no data for a minute or has
633not reached pre-receive fifteen minutes after taking its slot. The suite takes
634about twenty minutes, so every push it gated failed.
624 635
625Both tiers rather than the floor alone because coverage is not nested across OS 636Both tiers rather than the floor alone because coverage is not nested across OS
626versions (below) and there is no CI, so a tier the hook does not run is not run 637versions (below) and there is no CI, so a tier that is not run is not run at
627at all. The cost is real: about twenty minutes, against roughly eight for the 638all. The cost is real: about twenty minutes, against roughly eight for the floor
628floor alone. 639alone.
629
630Pre-push rather than pre-commit deliberately: at pre-commit that blocks every
631commit. A hook routinely bypassed with `--no-verify` is worse than no hook,
632because it trains you to ignore it — which is the standing argument against
633letting this get any slower.
634 640
635## Layout gotchas found the hard way 641## Layout gotchas found the hard way
636 642
README.org +3 −1
@@ -70,7 +70,9 @@ accessibility audit.
70./Scripts/audit-a11y.sh floor # oldest only (~85s) 70./Scripts/audit-a11y.sh floor # oldest only (~85s)
71#+end_src 71#+end_src
72 72
73findings are reported, not enforced. optional pre-push hook: 73findings are reported, not enforced. a passing run of both tiers on a
74clean tree is recorded, and the optional pre-push hook refuses a push of
75Swift or project changes without one:
74 76
75#+begin_src sh 77#+begin_src sh
76git config core.hooksPath .githooks 78git config core.hooksPath .githooks
Scripts/audit-a11y.sh +20 −2
@@ -33,6 +33,8 @@ TIER="${1:-both}"
33 33
34# shellcheck source=lib/simulators.sh 34# shellcheck source=lib/simulators.sh
35source "$(dirname "$0")/lib/simulators.sh" 35source "$(dirname "$0")/lib/simulators.sh"
36# shellcheck source=lib/audit-pass.sh
37source "$(dirname "$0")/lib/audit-pass.sh"
36 38
37case "$TIER" in 39case "$TIER" in
38 floor | current | both) ;; 40 floor | current | both) ;;
@@ -72,8 +74,8 @@ run_tier() {
72 # 74 #
73 # The grep is wrapped in a brace group so that matching nothing does not read 75 # The grep is wrapped in a brace group so that matching nothing does not read
74 # as a failure. With pipefail the pipeline then carries xcodebuild's own 76 # as a failure. With pipefail the pipeline then carries xcodebuild's own
75 # status, so an enforced audit failure reaches the caller — and the pre-push 77 # status, so an enforced audit failure reaches the caller — and is never
76 # gate can act on it — rather than being reported and exited 0. 78 # recorded as a pass — rather than being reported and exited 0.
77 local code=0 79 local code=0
78 set -o pipefail 80 set -o pipefail
79 xcodebuild test \ 81 xcodebuild test \
@@ -95,11 +97,27 @@ else
95 run_tier "$TIER" || status=1 97 run_tier "$TIER" || status=1
96fi 98fi
97 99
100# A pass on both tiers is recorded against the tree it ran on, for the pre-push
101# hook to check. Only a tree the build saw exactly counts: no tracked changes,
102# and no untracked file the build would pick up.
103record_pass() {
104 if [[ -n "$(git status --porcelain --untracked-files=no)" ]] \
105 || git status --porcelain --untracked-files=all | grep -qE "$AUDIT_INPUTS"; then
106 echo " Not recorded for the pre-push hook: the working tree differs from HEAD."
107 return
108 fi
109 git rev-parse 'HEAD^{tree}' >> "$(audit_pass_file)"
110 echo " Recorded for the pre-push hook: $(git log -1 --format='%h %s')"
111}
112
98echo 113echo
99if [[ "$status" -eq 0 ]]; then 114if [[ "$status" -eq 0 ]]; then
100 echo "==> Done. Findings above are the burndown list for issue #21." 115 echo "==> Done. Findings above are the burndown list for issue #21."
101 echo " They are reported, not enforced — widen" 116 echo " They are reported, not enforced — widen"
102 echo " AccessibilityAuditHarness.enforcedAuditTypes as each phase lands." 117 echo " AccessibilityAuditHarness.enforcedAuditTypes as each phase lands."
118 if [[ "$TIER" = "both" ]]; then
119 record_pass
120 fi
103else 121else
104 echo "==> A tier failed. An enforced category reported a named finding, or the" >&2 122 echo "==> A tier failed. An enforced category reported a named finding, or the" >&2
105 echo " suite could not run. Read the verdict line for each tier above." >&2 123 echo " suite could not run. Read the verdict line for each tier above." >&2
Scripts/lib/audit-pass.sh added +13
@@ -0,0 +1,13 @@
1# shellcheck shell=bash
2#
3# Where accessibility audit passes are recorded, and which changes need one.
4# Sourced by Scripts/audit-a11y.sh, which records a pass, and
5# .githooks/pre-push, which checks for it.
6
7# Paths whose changes can alter the rendered UI.
8AUDIT_INPUTS='\.(swift|xcassets|xcodeproj)|\.pbxproj|xcscheme'
9
10# One tree hash per line. Under the common git dir, so worktrees share it.
11audit_pass_file() {
12 echo "$(git rev-parse --git-common-dir)/a11y-audit-passed"
13}