|
| 1 | +name: workstation-doctor-polish |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - 'profiles/linux-dev/workstation-v0/doctor.sh' |
| 7 | + - 'profiles/linux-dev/workstation-v0/bin/check-workstation-polish.sh' |
| 8 | + - '.github/workflows/workstation-doctor-polish.yml' |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + paths: |
| 13 | + - 'profiles/linux-dev/workstation-v0/doctor.sh' |
| 14 | + - 'profiles/linux-dev/workstation-v0/bin/check-workstation-polish.sh' |
| 15 | + - '.github/workflows/workstation-doctor-polish.yml' |
| 16 | + |
| 17 | +jobs: |
| 18 | + doctor-polish-smoke: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Syntax check doctor |
| 25 | + run: | |
| 26 | + set -euo pipefail |
| 27 | + bash -n profiles/linux-dev/workstation-v0/doctor.sh |
| 28 | +
|
| 29 | + - name: Smoke: doctor JSON shape survives valid aggregate polish |
| 30 | + run: | |
| 31 | + set -euo pipefail |
| 32 | + doctor='profiles/linux-dev/workstation-v0/doctor.sh' |
| 33 | + helper='profiles/linux-dev/workstation-v0/bin/check-workstation-polish.sh' |
| 34 | + backup=$(mktemp) |
| 35 | + cp "$helper" "$backup" |
| 36 | + restore(){ cp "$backup" "$helper"; } |
| 37 | + trap restore EXIT |
| 38 | + cat > "$helper" <<'EOF' |
| 39 | + #!/usr/bin/env bash |
| 40 | + set -euo pipefail |
| 41 | + printf 'mac_polish.helper=present\n' |
| 42 | + printf 'keyboard_policy.helper=present\n' |
| 43 | + printf 'keyboard_policy.policy_ok=yes\n' |
| 44 | + EOF |
| 45 | + chmod +x "$helper" |
| 46 | +
|
| 47 | + set +e |
| 48 | + out=$(bash "$doctor" --json) |
| 49 | + rc=$? |
| 50 | + set -e |
| 51 | + if [ "$rc" -ne 0 ] && [ "$rc" -ne 2 ]; then |
| 52 | + echo "Unexpected exit code: $rc" >&2 |
| 53 | + exit 1 |
| 54 | + fi |
| 55 | + python3 -c 'import json,sys |
| 56 | +j=json.loads(sys.stdin.read()) |
| 57 | +assert j["kind"]=="sourceos.doctor" |
| 58 | +assert j["profile"]=="linux-dev/workstation-v0" |
| 59 | +assert set(j)>= {"kind","profile","ok","summary","results"} |
| 60 | +assert isinstance(j["results"], list) |
| 61 | +print("doctor-json-schema: ok")' <<<"$out" |
| 62 | + grep -F '"name":"mac-polish-helper"' <<<"$out" >/dev/null |
| 63 | + grep -F '"name":"keyboard-policy-helper"' <<<"$out" >/dev/null |
| 64 | + grep -F '"name":"keyboard-policy"' <<<"$out" >/dev/null |
| 65 | + |
| 66 | + - name: Smoke: invalid aggregate keyboard policy is warning-only |
| 67 | + run: | |
| 68 | + set -euo pipefail |
| 69 | + doctor='profiles/linux-dev/workstation-v0/doctor.sh' |
| 70 | + helper='profiles/linux-dev/workstation-v0/bin/check-workstation-polish.sh' |
| 71 | + backup=$(mktemp) |
| 72 | + cp "$helper" "$backup" |
| 73 | + restore(){ cp "$backup" "$helper"; } |
| 74 | + trap restore EXIT |
| 75 | + cat > "$helper" <<'EOF' |
| 76 | + #!/usr/bin/env bash |
| 77 | + set -euo pipefail |
| 78 | + printf 'mac_polish.helper=present\n' |
| 79 | + printf 'keyboard_policy.helper=present\n' |
| 80 | + printf 'keyboard_policy.policy_ok=no\n' |
| 81 | + EOF |
| 82 | + chmod +x "$helper" |
| 83 | +
|
| 84 | + set +e |
| 85 | + out=$(bash "$doctor" --json) |
| 86 | + rc=$? |
| 87 | + set -e |
| 88 | + if [ "$rc" -ne 0 ] && [ "$rc" -ne 2 ]; then |
| 89 | + echo "Unexpected exit code: $rc" >&2 |
| 90 | + exit 1 |
| 91 | + fi |
| 92 | + python3 -c 'import json,sys |
| 93 | +j=json.loads(sys.stdin.read()) |
| 94 | +assert j["kind"]=="sourceos.doctor" |
| 95 | +assert j["profile"]=="linux-dev/workstation-v0" |
| 96 | +assert isinstance(j["results"], list) |
| 97 | +assert any(r.get("name")=="keyboard-policy" and r.get("level")=="warn" for r in j["results"]) |
| 98 | +print("doctor-polish-warning: ok")' <<<"$out" |
0 commit comments