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 @@
11#!/usr/bin/env bash
22#
3# Run the complexity ratchet and the accessibility audit against the oldest
4# supported simulator runtime before pushing.
3# Run the complexity ratchet, and refuse a push whose tree has no recorded
4# accessibility audit pass.
55#
66# Enable once per clone:
77# git config core.hooksPath .githooks
88#
9# Why pre-push and not pre-commit: the suite takes around ten minutes per
10# runtime. At pre-commit that blocks every commit, and a hook you routinely
11# bypass with --no-verify is worse than no hook, because it trains you to ignore
12# it. Pushes are far less frequent and map to the unit of work.
9# The audit runs before the push, not here: `./Scripts/audit-a11y.sh` on a
10# clean tree records the tree it passed on, and this hook looks it up. git opens
11# the connection before running pre-push, and gitbay kills a push that moves no
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.
1315#
1416# Why both tiers: audit coverage is not nested across OS versions — each runtime
1517# 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
17# not run is not run at all, and an enforced failure on it reaches main.
18# Docs/ACCESSIBILITY.txt records per screen. There is no CI, so a tier that is
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.
1821#
1922# Why the hook runs qlty at all: nothing else does. This repository's origin is
2023# gitbay, which has no build configured, so the smell gates in .qlty/qlty.toml
@@ -28,8 +31,11 @@ set -euo pipefail
2831repo_root=$(git rev-parse --show-toplevel)
2932cd "$repo_root"
3033
34# shellcheck source=../Scripts/lib/audit-pass.sh
35source Scripts/lib/audit-pass.sh
36
3137zero='0000000000000000000000000000000000000000'
32changed=''
38needs_audit=''
3339
3440# stdin: <local ref> <local sha> <remote ref> <remote sha>, one line per ref.
3541while 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
4349 range="$remote_sha..$local_sha"
4450 fi
4551
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
4755done
4856
49if [ -z "$(printf '%s' "$changed" | tr -d '[:space:]')" ]; 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
57if [ -z "$needs_audit" ]; then
5558 echo "pre-push: no Swift/project changes, skipping accessibility audit"
5659 exit 0
5760fi
@@ -101,18 +104,21 @@ print(sum(
101104 fi
102105fi
103106
104echo "pre-push: running accessibility audit on both runtimes (~20 min)"
105echo " skip with 'git push --no-verify'"
107passes=$(audit_pass_file)
108missing=''
109for sha in $needs_audit; do
110 grep -qxF "$(git rev-parse "$sha^{tree}")" "$passes" 2>/dev/null || missing="$missing $sha"
111done
106112
107if ! ./Scripts/audit-a11y.sh; then
108 echo
109 echo "pre-push: accessibility audit failed. Push aborted." >&2
110 echo " Re-run with './Scripts/audit-a11y.sh' to see which tier and" >&2
111 echo " which screen, or bypass with 'git push --no-verify'." >&2
113if [ -n "$missing" ]; then
114 echo "pre-push: no recorded accessibility audit pass for:" >&2
115 for sha in $missing; do
116 echo " $(git log -1 --format='%h %s' "$sha")" >&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
112120 exit 1
113121fi
114122
115# Note: findings are reported, not enforced, so a clean exit here does not mean
116# zero findings — read the list above. Enforcement is controlled by
117# AccessibilityAuditHarness.enforcedAuditTypes.
123echo "pre-push: accessibility audit passed on this tree"
118124exit 0
Docs/ACCESSIBILITY.txt +19 −13
@@ -538,7 +538,7 @@ target had left in the app's container was still there.
538538That made the result depend on what ran before it. `testTrackedDomainsScreen`
539539passed with one finding in isolation, and reported six — including an enforced
540540`[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.
542542
543543**A correction to what this file said first.** The initial note blamed the
544544seeded fixtures. That was wrong: `seedAuditFixturesIfRequested` writes only to
@@ -583,7 +583,8 @@ no single number is correct on both.
583583
584584The audit therefore runs locally, across both ends, via
585585`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.
587588
588589There is no CI job. The GitHub Actions workflow that used to run this suite on
589590the 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.
618619git config core.hooksPath .githooks
619620```
620621
621Runs the complexity ratchet, then the audit on **both** runtimes, before a push,
622and only when Swift, asset, or project files changed. Bypass with
623`git push --no-verify`.
622Runs the complexity ratchet, then refuses the push unless the tree being pushed
623has a recorded audit pass, when Swift, asset, or project files changed. Bypass
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.
624635
625636Both 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
627at all. The cost is real: about twenty minutes, against roughly eight for the
628floor alone.
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.
637versions (below) and there is no CI, so a tier that is not run is not run at
638all. The cost is real: about twenty minutes, against roughly eight for the floor
639alone.
634640
635641## Layout gotchas found the hard way
636642
README.org +3 −1
@@ -70,7 +70,9 @@ accessibility audit.
7070./Scripts/audit-a11y.sh floor # oldest only (~85s)
7171#+end_src
7272
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:
7476
7577#+begin_src sh
7678git config core.hooksPath .githooks
Scripts/audit-a11y.sh +20 −2
@@ -33,6 +33,8 @@ TIER="${1:-both}"
3333
3434# shellcheck source=lib/simulators.sh
3535source "$(dirname "$0")/lib/simulators.sh"
36# shellcheck source=lib/audit-pass.sh
37source "$(dirname "$0")/lib/audit-pass.sh"
3638
3739case "$TIER" in
3840 floor | current | both) ;;
@@ -72,8 +74,8 @@ run_tier() {
7274 #
7375 # The grep is wrapped in a brace group so that matching nothing does not read
7476 # 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
76 # gate can act on it — rather than being reported and exited 0.
77 # status, so an enforced audit failure reaches the caller — and is never
78 # recorded as a pass — rather than being reported and exited 0.
7779 local code=0
7880 set -o pipefail
7981 xcodebuild test \
@@ -95,11 +97,27 @@ else
9597 run_tier "$TIER" || status=1
9698fi
9799
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
98113echo
99114if [[ "$status" -eq 0 ]]; then
100115 echo "==> Done. Findings above are the burndown list for issue #21."
101116 echo " They are reported, not enforced — widen"
102117 echo " AccessibilityAuditHarness.enforcedAuditTypes as each phase lands."
118 if [[ "$TIER" = "both" ]]; then
119 record_pass
120 fi
103121else
104122 echo "==> A tier failed. An enforced category reported a named finding, or the" >&2
105123 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}