Guide

CI and code scanning

odflens is built to run in a pipeline: no network, a documented exit code, and SARIF 2.1.0 for GitHub code scanning.

Add it to a workflow

Run the audit, write a SARIF log, then hand the log to code scanning. The two steps are independent, so the audit still fails the job on its own.

name: ODF accessibility
on: [push, pull_request]

jobs:
  odflens:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: oven-sh/setup-bun@v2
        with:
          bun-version: 1.3.x

      - name: Install odflens
        run: curl -fsSL https://raw.githubusercontent.com/srivtx/odflens/main/install.sh | sh

      - name: Audit ODF documents
        run: odflens --dir public/docs --sarif odflens.sarif

      - name: Upload SARIF
        if: always()
        uses: github/codeql-action/upload-sarif@v3
        with:
          sarif_file: odflens.sarif

What a SARIF result contains

Each issue becomes one SARIF result:

  • ruleId is the rule code, such as ODF-LANG-001.
  • level is mapped from severity: errorerror, warningwarning, infonote.
  • The location is URL-encoded and points at the file, so the annotation lands on the pull request.
  • properties.severity and properties.wcag carry the original values.
  • The rules array always contains the full catalog, and unreadable files are reported too, as ODF-000.

Failing the build

Without --sarif, the exit code is the gate. odflens --dir public/docs exits 1 on any error-severity issue. Add --fail-on warning to fail on warnings too. The flag changes only the exit code; the report is the same either way.

ci
$ odflens fixtures/bad.odt --fail-on warningbad.odt (odt)ERROR   ODF-ALT-003 [WCAG 1.1.1]: Image frame has no alternative text (svg:title or svg:desc). (bad.odt)WARNING ODF-HEAD-004 [WCAG 1.3.1]: Heading outline levels skip a level (e.g. h1 followed by h3). (bad.odt)ERROR   ODF-LANG-001 [WCAG 3.1.1]: Document does not declare a language (dc:language or xml:lang / fo:language). (bad.odt)WARNING ODF-LINK-007 [WCAG 2.4.4]: Link text is a raw URL; use descriptive link text instead. (bad.odt)ERROR   ODF-TBL-006 [WCAG 1.3.1]: Table has rows but no header rows (table:table-header-rows). (bad.odt)ERROR   ODF-TITLE-002: Document metadata has no non-empty dc:title. (bad.odt)Totals: 4 error(s), 2 warning(s), 0 infoexit 1