Run SEO checks in CI
Run a bounded Sonjoo audit, keep the JSON report as an artifact, and propagate the CLI exit code to the job. Pin the Sonjoo version and commit the configuration used by the job so you can compare runs.
Gate on a minimum score or page coverage
Section titled “Gate on a minimum score or page coverage”Add a score threshold with --fail-under. For crawls, use --min-coverage to require a minimum percentage of measured pages among attempted pages. The gate uses a whole percentage rounded down. At the default threshold of 70, a score of exactly 70 meets the score gate. Coverage is checked when a positive threshold and measured and attempted counts are available.
sonjoo audit https://example.com/ --crawl --max-pages 25 --max-duration 120 \ --fail-under 80 --min-coverage 90 --no-save --format json --output audit.jsonChoose thresholds based on the scope you actually measure. Inspect page and rule coverage before raising a threshold.
The local fixture has a crawl branch with three pages. This example requires Sonjoo to measure every attempted page and writes the coverage evidence to JSON.
target="${SONJOO_DOCS_TARGET:-http://127.0.0.1:18765}"sonjoo audit "$target/crawl-branch/" --crawl --max-pages 3 --categories core \ --fail-under 0 --min-coverage 100 --no-save --format json --output coverage-audit.jsonExpect exit 0 and gate.coverage with measured: 3, attempted: 3, and passed: true.
Require a specific rule
Section titled “Require a specific rule”To reproduce a pass and a failure, start the local fixture. Run the example from an empty directory.
target="${SONJOO_DOCS_TARGET:-http://127.0.0.1:18765}"cat > ci-audit.toml <<'TOML'[rules]enable = ["core-title-present"]
[rules.override]core-title-present = { fail_ci = true }
[ci]fail_under = 0TOML
sonjoo audit "$target/healthy" --config ci-audit.toml --no-save \ --format json --output passing-audit.json
status=0sonjoo audit "$target/healthy?remove-title=1" --config ci-audit.toml --no-save \ --format json --output failing-audit.json || status=$?printf 'Audit exit code: %s\n' "$status"(exit "$status")The first command exits 0. The second exits 1 and keeps failing-audit.json. Inspect gate.failedCiRules to see the failed rule and its URL. Required checks that could not run can also fail the gate. Inspect gate.unevaluated for the reason. Sonjoo rejects configuration that disables a required rule or excludes its category.
Keep the report when the job fails
Section titled “Keep the report when the job fails”Use a fresh output path for each run. Configure your CI system to upload the report after the audit step even when that step fails, then preserve the original exit status. Treat an error envelope as an execution error. Save the diagnostic separately if you also capture standard error. Exit code reference · JSON report shapes
