Scripts/audit-a11y.sh

98 lines · 3100 bytes · executable

 1#!/usr/bin/env bash
 2#
 3# Run the accessibility audit suite against real simulator runtimes.
 4#
 5#   ./Scripts/audit-a11y.sh            # floor + current
 6#   ./Scripts/audit-a11y.sh floor      # oldest supported runtime only
 7#   ./Scripts/audit-a11y.sh current    # newest installed runtime only
 8#
 9# Why this exists rather than living entirely in CI: audit coverage is NOT
10# nested across OS versions — each runtime reports findings the others miss, in
11# both directions. Measured on Tracked Domains, iOS 18.6 reported 2 findings and
12# iOS 27.0 reported 6; at accessibility text sizes the Dashboard produced a
13# hit-region finding on 18.6 that 27.0 did not. The GitHub macos-26 image ships
14# only iOS 26.x runtimes, so it structurally cannot cover the floor. This machine
15# can.
16#
17# Scripts/test.sh does the same for the unit suite, for its own reasons.
18#
19# CI covers "current" on a clean checkout (which a local run cannot, since it
20# would miss an uncommitted file). This script covers "floor" (which CI cannot).
21# Together they cover both; neither duplicates the other.
22#
23# The deployment target is read from the project rather than hard-coded, so it
24# cannot drift out of sync.
25
26set -euo pipefail
27
28cd "$(dirname "$0")/.."
29
30PROJECT="DomainDig.xcodeproj"
31SCHEME="DomainDig"
32TIER="${1:-both}"
33
34# shellcheck source=lib/simulators.sh
35source "$(dirname "$0")/lib/simulators.sh"
36
37case "$TIER" in
38  floor | current | both) ;;
39  *)
40    echo "usage: $0 [floor|current|both]" >&2
41    exit 2
42    ;;
43esac
44
45echo "==> Reading deployment target from $PROJECT"
46read_deployment_target
47echo "    deployment target: $DEPLOYMENT_TARGET (rank $FLOOR_RANK)"
48
49run_tier() {
50  local which="$1"
51  local sim udid label
52
53  sim=$(select_sim "$which")
54  if [[ -z "$sim" ]]; then
55    echo "error: no iPhone simulator at or above iOS $DEPLOYMENT_TARGET installed" >&2
56    echo "hint: install one with 'xcodebuild -downloadPlatform iOS'" >&2
57    return 1
58  fi
59
60  udid=$(echo "$sim" | jq -r .udid)
61  label=$(echo "$sim" | jq -r '"\(.name) (iOS \(.os))"')
62
63  echo
64  echo "==> $which: $label"
65
66  if [[ "$which" = "floor" ]] && floor_is_approximate "$sim"; then
67    echo "    NOTE: nearest installed runtime is a major version above the $DEPLOYMENT_TARGET"
68    echo "          deployment target, so this is not true floor coverage."
69  fi
70
71  # Findings are printed by the suite itself; surface them plus the verdict.
72  set -o pipefail
73  xcodebuild test \
74    -project "$PROJECT" \
75    -scheme "$SCHEME" \
76    -destination "id=$udid" \
77    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)' \
79    || true
80
81  return 0
82}
83
84status=0
85if [[ "$TIER" = "both" ]]; then
86  run_tier floor || status=1
87  run_tier current || status=1
88else
89  run_tier "$TIER" || status=1
90fi
91
92echo
93if [[ "$status" -eq 0 ]]; then
94  echo "==> Done. Findings above are the burndown list for issue #21."
95  echo "    They are reported, not enforced — widen"
96  echo "    AccessibilityAuditHarness.enforcedAuditTypes as each phase lands."
97fi
98exit "$status"