Commit b4e5a1e858
Unsigned
Layout: unified · split
.githooks/pre-push +13 −13
| @@ -6,15 +6,15 @@ | |||
| 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 ~85s. At pre-commit that | 9 | # Why pre-push and not pre-commit: the suite takes around ten minutes per |
| 10 | # blocks every commit, and a hook you routinely bypass with --no-verify is worse | 10 | # runtime. At pre-commit that blocks every commit, and a hook you routinely |
| 11 | # than no hook, because it trains you to ignore it. Pushes are far less frequent | 11 | # bypass with --no-verify is worse than no hook, because it trains you to ignore |
| 12 | # and map to the unit of work that actually reaches CI. | 12 | # it. Pushes are far less frequent and map to the unit of work. |
| 13 | # | 13 | # |
| 14 | # Why only the floor tier: CI already audits the newest runtime on a clean | 14 | # Why both tiers: audit coverage is not nested across OS versions — each runtime |
| 15 | # checkout. The GitHub image has no old runtimes, so the floor is the one thing | 15 | # reports findings the others miss, in both directions, which |
| 16 | # CI structurally cannot cover — and it is the one this machine can. Running | 16 | # Docs/ACCESSIBILITY.txt records per screen. There is no CI, so a tier this does |
| 17 | # both here would just double the wait to re-check what CI already does. | 17 | # not run is not run at all, and an enforced failure on it reaches main. |
| 18 | # | 18 | # |
| 19 | # Why the hook runs qlty at all: nothing else does. This repository's origin is | 19 | # 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 | 20 | # gitbay, which has no build configured, so the smell gates in .qlty/qlty.toml |
| @@ -101,14 +101,14 @@ print(sum( | |||
| 101 | fi | 101 | fi |
| 102 | fi | 102 | fi |
| 103 | 103 | ||
| 104 | echo "pre-push: running accessibility audit on the floor runtime (~85s)" | 104 | echo "pre-push: running accessibility audit on both runtimes (~20 min)" |
| 105 | echo " skip with 'git push --no-verify'" | 105 | echo " skip with 'git push --no-verify'" |
| 106 | 106 | ||
| 107 | if ! ./Scripts/audit-a11y.sh floor; then | 107 | if ! ./Scripts/audit-a11y.sh; then |
| 108 | echo | 108 | echo |
| 109 | echo "pre-push: audit could not run. Push aborted." >&2 | 109 | echo "pre-push: accessibility audit failed. Push aborted." >&2 |
| 110 | echo " Re-run with './Scripts/audit-a11y.sh floor' to see why," >&2 | 110 | echo " Re-run with './Scripts/audit-a11y.sh' to see which tier and" >&2 |
| 111 | echo " or bypass with 'git push --no-verify'." >&2 | 111 | echo " which screen, or bypass with 'git push --no-verify'." >&2 |
| 112 | exit 1 | 112 | exit 1 |
| 113 | fi | 113 | fi |
| 114 | 114 | ||
Docs/ACCESSIBILITY.txt +20 −9
| @@ -410,7 +410,7 @@ no single number is correct on both. | |||
| 410 | 410 | ||
| 411 | The audit therefore runs locally, across both ends, via | 411 | The audit therefore runs locally, across both ends, via |
| 412 | `Scripts/audit-a11y.sh` — on a machine that actually has an 18.x runtime | 412 | `Scripts/audit-a11y.sh` — on a machine that actually has an 18.x runtime |
| 413 | installed. It is wired to the pre-push hook in `.githooks/`. | 413 | installed. The pre-push hook in `.githooks/` runs both of them. |
| 414 | 414 | ||
| 415 | There is no CI job. The GitHub Actions workflow that used to run this suite on | 415 | There is no CI job. The GitHub Actions workflow that used to run this suite on |
| 416 | the newest runtime has been removed, and with it the one check that no local run | 416 | the newest runtime has been removed, and with it the one check that no local run |
| @@ -424,11 +424,15 @@ by hand before a release. | |||
| 424 | ## Running it | 424 | ## Running it |
| 425 | 425 | ||
| 426 | ```sh | 426 | ```sh |
| 427 | ./Scripts/audit-a11y.sh # floor + current | 427 | ./Scripts/audit-a11y.sh # floor + current (~20 min) |
| 428 | ./Scripts/audit-a11y.sh floor # oldest supported only (~85s) | 428 | ./Scripts/audit-a11y.sh floor # oldest supported only (~8 min) |
| 429 | ./Scripts/audit-a11y.sh current # newest installed only | 429 | ./Scripts/audit-a11y.sh current # newest installed only (~10 min) |
| 430 | ``` | 430 | ``` |
| 431 | 431 | ||
| 432 | It exits non-zero when a tier fails — an enforced category reporting a named | ||
| 433 | finding, or the suite not running at all — so it can be used as a gate. Findings | ||
| 434 | in unenforced categories are printed and do not affect the exit code. | ||
| 435 | |||
| 432 | The script reads the deployment target from the project rather than hard-coding | 436 | The script reads the deployment target from the project rather than hard-coding |
| 433 | it, and selects the oldest installed runtime **at or above** it — a runtime | 437 | it, and selects the oldest installed runtime **at or above** it — a runtime |
| 434 | below the deployment target is useless, because the app cannot install there. | 438 | below the deployment target is useless, because the app cannot install there. |
| @@ -441,12 +445,19 @@ so rather than implying floor coverage it does not have. | |||
| 441 | git config core.hooksPath .githooks | 445 | git config core.hooksPath .githooks |
| 442 | ``` | 446 | ``` |
| 443 | 447 | ||
| 444 | Runs the floor audit before a push, and only when Swift, asset, or project files | 448 | Runs the complexity ratchet, then the audit on **both** runtimes, before a push, |
| 445 | changed. Bypass with `git push --no-verify`. | 449 | and only when Swift, asset, or project files changed. Bypass with |
| 450 | `git push --no-verify`. | ||
| 451 | |||
| 452 | Both tiers rather than the floor alone because coverage is not nested across OS | ||
| 453 | versions (below) and there is no CI, so a tier the hook does not run is not run | ||
| 454 | at all. The cost is real: about twenty minutes, against roughly eight for the | ||
| 455 | floor alone. | ||
| 446 | 456 | ||
| 447 | Pre-push rather than pre-commit deliberately: the suite takes ~85s, and at | 457 | Pre-push rather than pre-commit deliberately: at pre-commit that blocks every |
| 448 | pre-commit that blocks every commit. A hook routinely bypassed with | 458 | commit. A hook routinely bypassed with `--no-verify` is worse than no hook, |
| 449 | `--no-verify` is worse than no hook, because it trains you to ignore it. | 459 | because it trains you to ignore it — which is the standing argument against |
| 460 | letting this get any slower. | ||
| 450 | 461 | ||
| 451 | ## Layout gotchas found the hard way | 462 | ## Layout gotchas found the hard way |
| 452 | 463 | ||
Scripts/audit-a11y.sh +12 −3
| @@ -69,16 +69,22 @@ run_tier() { | |||
| 69 | fi | 69 | fi |
| 70 | 70 | ||
| 71 | # Findings are printed by the suite itself; surface them plus the verdict. | 71 | # Findings are printed by the suite itself; surface them plus the verdict. |
| 72 | # | ||
| 73 | # 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 | ||
| 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 | local code=0 | ||
| 72 | set -o pipefail | 78 | set -o pipefail |
| 73 | xcodebuild test \ | 79 | xcodebuild test \ |
| 74 | -project "$PROJECT" \ | 80 | -project "$PROJECT" \ |
| 75 | -scheme "$SCHEME" \ | 81 | -scheme "$SCHEME" \ |
| 76 | -destination "id=$udid" \ | 82 | -destination "id=$udid" \ |
| 77 | CODE_SIGNING_ALLOWED=NO 2>&1 \ | 83 | CODE_SIGNING_ALLOWED=NO 2>&1 \ |
| 78 | | grep -E 'finding\(s\)|no accessibility findings|^ • |did not complete in time|Executed [0-9]+ test|\*\* TEST (SUCCEEDED|FAILED)' \ | 84 | | { grep -E 'finding\(s\)|no accessibility findings|^ • |did not complete in time|Executed [0-9]+ test|\*\* TEST (SUCCEEDED|FAILED)' || true; } \ |
| 79 | || true | 85 | || code=$? |
| 80 | 86 | ||
| 81 | return 0 | 87 | return "$code" |
| 82 | } | 88 | } |
| 83 | 89 | ||
| 84 | status=0 | 90 | status=0 |
| @@ -94,5 +100,8 @@ if [[ "$status" -eq 0 ]]; then | |||
| 94 | echo "==> Done. Findings above are the burndown list for issue #21." | 100 | echo "==> Done. Findings above are the burndown list for issue #21." |
| 95 | echo " They are reported, not enforced — widen" | 101 | echo " They are reported, not enforced — widen" |
| 96 | echo " AccessibilityAuditHarness.enforcedAuditTypes as each phase lands." | 102 | echo " AccessibilityAuditHarness.enforcedAuditTypes as each phase lands." |
| 103 | else | ||
| 104 | 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 | ||
| 97 | fi | 106 | fi |
| 98 | exit "$status" | 107 | exit "$status" |