Use the WCAG 2.2 AA profile and WriteSARIF to report findings in CI. A scan can’t prove conformance. SARIF is a JSON format for analysis results that tools like GitHub code scanning can display.
go get recursiveai.org/go/onehtmlRequires Go 1.24 or later.
package main import ( "fmt" "os" "recursiveai.org/go/onehtml" v "recursiveai.org/go/onehtml/accessibility/validation" ) func main() { src, err := os.ReadFile("page.html") if err != nil { panic(err) } doc, err := onehtml.ParseBytes(src) if err != nil { panic(err) } profile := v.WithProfile(v.ProfileWCAG22AA) report, err := v.Check(doc, profile) if err != nil { panic(err) } file, err := os.Create("accessibility.sarif") if err != nil { panic(err) } err = report.WriteSARIF(file, v.WithExportURL("page.html")) closeErr := file.Close() if err != nil { panic(err) } if closeErr != nil { panic(closeErr) } for result := range report.WithOutcome(v.Failed) { fmt.Println(result.RuleID) } fmt.Println("Wrote accessibility.sarif") }
If page.html is missing, the file read fails before any SARIF is written. The program prints confirmed failures; open accessibility.sarif for locations and review items too.
Paste the code above into main.go, run go mod init example and go get recursiveai.org/go/onehtml, then go run .; or unzip the example and go run ..
Save this input as page.html next to main.go if you’re pasting the code. It’s already in the zip.
<!doctype html> <html lang="en"> <title>Shop</title> <main> <h1>Shop</h1> <button></button> </main> </html>
go run . prints:
button-name Wrote accessibility.sarif
Variations
To fail CI on a confirmed accessibility issue, add this at the end of main, after the report is closed. The sample exits with status 1 after printing button-name button. result.Target.Name() gives the element name, button.
for result := range report.WithOutcome(v.Failed) { fmt.Println(result.RuleID, result.Target.Name()) os.Exit(1) }
Related recipes
The short answer
Parse the HTML, call validation.Check with validation.WithProfile(validation.ProfileWCAG22AA), and pass a file to report.WriteSARIF. Upload that file to a SARIF-capable CI viewer or save it as a build artifact. Treat confirmed failures and items that need human review separately.
How do I check a website for WCAG?
Run the checker on the HTML your build actually serves, not just the template that produces it. Template expansion may decide whether a button gets a name or whether a page gets a title. This example reads the generated input from disk, so it checks exactly the bytes in page.html. The WCAG 2.2 standard defines Level AA in terms of all applicable Level A and AA criteria. The profile picks relevant library rules; it does not turn that rule set into exhaustive coverage of the standard.
For example, the checker can report that the sample’s button has no accessible name. It also marks whether the title is descriptive as a review item: seeing the word “Shop” in a title does not establish that it adequately describes the page. To cover the rest of the experience, use W3C’s evaluation guidance and test the rendered page, including keyboard use and the states users encounter after interacting with it. onehtml-go does not run scripts or render the page.
How do I report accessibility failures in CI with SARIF?
Use the checked file’s path as the artifact URI. WithExportURL("page.html") labels the result with that path; for a real build, use a path your viewer can resolve. This report marks button-name as kind: fail and points to page.html, line 6, column 3. It also contains kind: review items at level: none, so a panel that only shows errors can miss work you still need someone to review. Passed and inapplicable items are omitted by default.
Writing the file and enforcing your CI policy are separate steps. Write and close the file first, then use report.WithOutcome(validation.Failed) to decide the job’s exit status, as in the variation. Configure the artifact step to run even after a failed check, so the report is available when the build that produced it goes red. If you review ambiguous cases manually, do not silently treat the absence of Failed outcomes as a clean accessibility evaluation.