Skip to content

ci(a11y): add PR checks with a shrink-only axe baseline - #38

Merged
BrianGenisio merged 2 commits into
mainfrom
feature/a11y-pr-ci-axe-baseline
Aug 6, 2026
Merged

ci(a11y): add PR checks with a shrink-only axe baseline#38
BrianGenisio merged 2 commits into
mainfrom
feature/a11y-pr-ci-axe-baseline

Conversation

@BrianGenisio

Copy link
Copy Markdown
Contributor

Closes #36. Second Wave 0 foundation item from the accessibility remediation plan.

Why

There is currently no CI on pull requests. release.yml only fires on release:created, so nothing runs npm test when a PR opens, and nothing checks accessibility at all. Without a gate, the 16 accessibility fixes will erode.

What's here

.github/workflows/pr.yml on pull_request:

  • submodule init, Node 20, npm ci
  • npm test + npm run build
  • axe scan in both color schemes against a checked-in shrink-only baseline

a11y-audits/tools/ adaptations for CI:

  • A11Y_CI=1 stubs /api/* (no Octavus credentials in Actions), skips the live-agent send flow, and scans empty / settings / settings-with-dropdown in light and dark
  • baseline.json + baseline.mjs — fail on new rules or higher node counts; counts may only shrink
  • npm run audit:ci / audit:update-baseline / test for the compare helper

The baseline matches the issue's known table (contrast, nested-interactive, landmark, region, aria-input-field-name). Streaming/with-messages are skipped in CI — those states matched the empty-state shell in the original audit; re-run the full local audit when a fix needs them.

Important limitation

axe cannot detect A1. Stated in the workflow file and in the baseline $comment. A green badge is a floor, not conformance.

Test plan

  • npm test (app) — 173 passed | 2 expected fail
  • a11y-audits/tools baseline helper tests — 5 passed
  • Local A11Y_CI=1 audit against a running server — gate passes
  • Synthetic regression (raised contrast count / new rule) — gate fails
  • GitHub Actions run on this PR goes green
  • After merge, open a throwaway PR that introduces a known axe regression and confirm it fails

Reference

a11y-audits/8-5-26/resolution-plan.md → Wave 0 → P0-2

Made with Cursor

There was no CI on pull requests. Gate unit tests, the build, and an axe
scan in both color schemes on today's known violations so the remediation
wave cannot silently regress. axe still cannot see A1.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a pull-request workflow that installs dependencies, runs tests, builds the frontend, starts the application, and executes light and dark accessibility scans. Adds deterministic CI API stubs and limits CI audits to supported states. Adds a checked-in axe baseline with shrink-only comparison logic, regression detection, missing-scan checks, update support, and unit tests. Documents CI limitations, including live-region behavior not detected by axe.

Possibly related issues

  • CodeSignal/learn#4297 — The pull-request adds automated accessibility scans for light and dark themes with a tracked baseline.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding pull-request accessibility checks with a shrink-only axe baseline.
Description check ✅ Passed The description explains the pull-request CI, accessibility audit, baseline gate, limitations, and test plan.
Linked Issues check ✅ Passed The changes satisfy issue #36 by adding PR CI, tests, builds, dual-theme axe scans, API stubs, a shrink-only baseline, and limitation documentation.
Out of Scope Changes check ✅ Passed The workflow, audit adaptations, baseline helpers, tests, and documentation are within the scope of issue #36.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/pr.yml:
- Around line 17-23: Update the check job in the workflow to grant only contents
read permission, and configure the actions/checkout@v4 step with
persist-credentials set to false. Keep the existing checkout behavior unchanged
otherwise.

In `@a11y-audits/tools/README.md`:
- Around line 49-53: Update the workflow command documentation in the README to
state that .github/workflows/pr.yml runs npm run audit, matching the workflow’s
explicit CI variable configuration; alternatively, change the workflow command
to npm run audit:ci and keep the documentation consistent.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9d841ef2-e47c-4529-894b-61482119485a

📥 Commits

Reviewing files that changed from the base of the PR and between 1678b6f and ac3956d.

📒 Files selected for processing (8)
  • .github/workflows/pr.yml
  • a11y-audits/tools/.gitignore
  • a11y-audits/tools/README.md
  • a11y-audits/tools/audit.mjs
  • a11y-audits/tools/baseline.json
  • a11y-audits/tools/baseline.mjs
  • a11y-audits/tools/baseline.test.mjs
  • a11y-audits/tools/package.json

Comment thread .github/workflows/pr.yml
Comment on lines +17 to +23
jobs:
check:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Workflow token defaults:"
gh api "repos/${GITHUB_REPOSITORY}/actions/permissions/workflow" \
  | jq '{default_workflow_permissions, can_approve_pull_request_reviews}'

echo "Checkout and permissions configuration:"
sed -n '12,35p' .github/workflows/pr.yml

Repository: CodeSignal/learn_cosmo-chat

Length of output: 240


🏁 Script executed:

set -euo pipefail

echo '--- workflow ---'
cat -n .github/workflows/pr.yml

echo '--- package manifests ---'
for f in package.json npm-shrinkwrap.json package-lock.json; do
  if [ -f "$f" ]; then
    echo "--- $f ---"
    cat -n "$f" | sed -n '1,180p'
  fi
done

echo '--- workflow references ---'
rg -n 'npm (ci|test|run|install)|yarn|pnpm|checkout|permissions|pull_request|persist-credentials' .github/workflows/pr.yml

Repository: CodeSignal/learn_cosmo-chat

Length of output: 12994


Restrict the workflow token and disable checkout credential persistence.

The workflow runs pull-request-controlled scripts after checkout. Set permissions: contents: read and persist-credentials: false for actions/checkout@v4.

🧰 Tools
🪛 zizmor (1.29.0)

[warning] 22-23: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/pr.yml around lines 17 - 23, Update the check job in the
workflow to grant only contents read permission, and configure the
actions/checkout@v4 step with persist-credentials set to false. Keep the
existing checkout behavior unchanged otherwise.

Source: Linters/SAST tools

Comment on lines +49 to +53
`.github/workflows/pr.yml` runs:

```bash
npm run audit:ci
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Correct the documented workflow command.

This section states that .github/workflows/pr.yml runs npm run audit:ci. The workflow runs npm run audit and sets the CI variables explicitly at .github/workflows/pr.yml Line 76 through Line 82. State the actual command, or change the workflow to call npm run audit:ci.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@a11y-audits/tools/README.md` around lines 49 - 53, Update the workflow
command documentation in the README to state that .github/workflows/pr.yml runs
npm run audit, matching the workflow’s explicit CI variable configuration;
alternatively, change the workflow command to npm run audit:ci and keep the
documentation consistent.

Co-authored-by: Cursor <cursoragent@cursor.com>
@BrianGenisio
BrianGenisio merged commit 6bca6c6 into main Aug 6, 2026
1 of 3 checks passed
@BrianGenisio
BrianGenisio deleted the feature/a11y-pr-ci-axe-baseline branch August 6, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[a11y][P0-2] Add PR CI with unit tests and an axe baseline gate

1 participant