AI CodeOps

Quality gates in GitHub Actions: configs for 10 stacks

Matt · · Last updated · 11 min read · Guides

Copy-paste GitHub Actions quality gates for 10 stacks: tests, coverage floor, SBOM, license policy and secrets scan, plus the matching AI CodeOps setting.

A quality gate in GitHub Actions is a job that fails the pull request when a rule isn't met, made a required check so the merge button stays locked until it passes. The recipes below give ten stacks the same five gates: tests, a coverage floor, a CycloneDX SBOM, a license policy and a secrets scan, each with the matching AI CodeOps setting. Copy the shared jobs once, add your stack's test job, and require the checks.

What a merge gate needs

When AI agents open pull requests, review stops being the bottleneck and starts being the weak point. A team that reviewed five changes a day can now get fifty. People get tired. A gate doesn't. Each recipe here blocks a pull request on five things:

  1. Tests. The suite must pass.
  2. A coverage floor. Line coverage under the floor fails. Every recipe uses 80%; pick your own.
  3. An SBOM. A CycloneDX SBOM is built for every change and kept as an artifact. An empty one fails.
  4. A license policy. A pull request that adds a dependency under a license you haven't allowed fails.
  5. A secrets scan. A commit in the change that contains a secret fails.

High-severity findings block too: the license job fails on known vulnerabilities in new dependencies, and for AI CodeOps changes the release gate blocks on open findings.

They are plain workflows. They work without any product, ours included. Every action version and input below was checked against that action's own README on 24 October 2026, and the Node and Go floors were run locally above and below the line. Still, run each one on a branch before you make it a required check. The quality gates guide explains what a gate is and how to design one; this post is the configs.

Two rules behind every recipe

Fail closed. A gate that can't run must fail, not pass. There's no continue-on-error and no || true anywhere in these files. If the SBOM tool finds nothing, the job fails. If the coverage number can't be read, the job fails.

Keep the floor in the workflow. Most tools let you set a coverage threshold in a config file: vitest.config.ts, pyproject.toml, .coveragerc. That file sits next to the code, so the change that drops coverage can drop the floor in the same diff. An AI agent asked to "make CI pass" will sometimes do exactly that. Where a tool has a command-line flag or an environment variable, these recipes set the floor there, in .github/workflows/. Then add .github/ to CODEOWNERS, so changing a gate needs an owner's review.

The three shared jobs

Secrets, SBOM and licenses are the same for every stack. Here they are once. Each recipe ends with these three jobs, unchanged.

secrets:
  name: Secrets scan
  runs-on: ubuntu-latest
  steps:
    - uses: actions/checkout@v7
      with:
        fetch-depth: 0
        persist-credentials: false
    - name: gitleaks
      env:
        RANGE: ${{ github.event_name == 'pull_request' && format('{0}..{1}', github.event.pull_request.base.sha, github.event.pull_request.head.sha) || format('{0}..{1}', github.event.before, github.sha) }}
      run: >-
        docker run --rm -v "$PWD:/repo" ghcr.io/gitleaks/gitleaks:v8.30.1
        git /repo --redact --verbose --log-opts="$RANGE"

sbom:
  name: SBOM (CycloneDX)
  runs-on: ubuntu-latest
  steps:
    - uses: actions/checkout@v7
      with:
        persist-credentials: false
    - uses: anchore/sbom-action@v0
      with:
        path: .
        format: cyclonedx-json
        output-file: sbom.cdx.json
        upload-artifact: false
    - name: The SBOM lists components
      run: jq -e '(.components // []) | length > 0' sbom.cdx.json
    - uses: actions/upload-artifact@v7
      with:
        name: sbom-cyclonedx
        path: sbom.cdx.json

licenses:
  name: License policy
  if: github.event_name == 'pull_request'
  runs-on: ubuntu-latest
  steps:
    - uses: actions/checkout@v7
      with:
        persist-credentials: false
    - uses: actions/dependency-review-action@v5
      with:
        config-file: ./.github/dependency-review-config.yml

A few choices in there are worth explaining.

Gitleaks from its image, not its action. The gitleaks binary is MIT and needs no key. The gitleaks GitHub Action asks organisations for a license key. Running the official image, pinned to a version, avoids the key and keeps the version under your control. The scan covers only the commits the change adds, from the pull request's base to its head, so an old leak elsewhere in history doesn't block today's change. Put a .gitleaks.toml at the repository root to tune rules; the image picks it up.

Syft for every SBOM. anchore/sbom-action runs Syft over the checkout and writes CycloneDX JSON. Syft reads the lockfiles of every stack here: package-lock.json, requirements.txt, go.sum, Gemfile.lock, pom.xml, packages.lock.json and Cargo.lock. The jq -e step fails the job when the SBOM has no components, which means no lockfile was found. An empty SBOM that passes is worse than none.

Dependency review for licenses. compares the pull request with its base and fails on any new dependency whose license isn't on your list. Three things to know. It needs GitHub's dependency graph, which is on for public repositories and needs GitHub Advanced Security for private ones. It checks dependencies the pull request adds or changes, not the ones already there. And if it can't detect a license, it reports it but doesn't fail.

The license list lives in .github/dependency-review-config.yml:

allow-licenses:
  - MIT
  - Apache-2.0
  - BSD-2-Clause
  - BSD-3-Clause
  - ISC
  - 0BSD
  - Zlib
  - Unlicense
  - CC0-1.0
  - BlueOak-1.0.0
  - Python-2.0
  - MPL-2.0
fail-on-severity: high

It's an allowlist on purpose. The action's deny-licenses option is deprecated, and a denylist lets through every license you didn't think of. The list above is an example of a permissive policy, not legal advice. The same action also fails on known vulnerabilities in new dependencies; fail-on-severity: high sets that bar.

Every workflow starts the same way: it runs on pull_request and on pushes to main, with permissions: contents: read and nothing more.

The ten stacks

Each stack below shows only its tests job steps. Put them under jobs.tests.steps, give the job name: Tests and coverage floor, add the three shared jobs, and you have the whole workflow. Every tests job starts with the same checkout step; it's shown once, in the first recipe.

Each stack also has an AI CodeOps setting. An AI CodeOps session runs your project's Test command (set on the project under Plan → Projects) on its change in a sandbox and records the result, and the release gate in your CI can then require minCoveragePct: 80. The session only records coverage when the command prints a summary AI CodeOps reads: a TOTAL line from pytest-cov or coverage.py, an All files table from Vitest, Jest or Node's test runner, or a Coverage: 85% line. It is stored as a whole number, rounded down, so 79.6% fails a floor of 80. A run with no coverage summary can't be checked against a floor, so the release gate denies it when minCoveragePct is set. Check that the run page shows a coverage figure before you add the floor.

Next.js

- uses: actions/checkout@v7
  with:
    persist-credentials: false
- uses: actions/setup-node@v7
  with:
    node-version: 24
    cache: npm
- run: npm ci
- run: npx vitest run --coverage.enabled --coverage.thresholds.lines=80
- run: npm run build

Vitest is the unit test runner the Next.js docs set up. Add @vitest/coverage-v8 to the dev dependencies the guide lists. next build also type-checks. Vitest doesn't run async Server Components, so those need end-to-end tests and won't count toward this floor.

AI CodeOps setting: Test command npx vitest run --coverage.enabled --coverage.thresholds.lines=80. Vitest's text reporter prints the All files table, and AI CodeOps takes its first column, which is statements, not lines.

Node.js

- run: npm ci
- run: node --test --experimental-test-coverage --test-coverage-lines=80

Node's built-in test runner has a floor flag since Node 22.8. Below it, the run exits 1 with a line like Error: 53.85% line coverage does not meet threshold of 80%. Coverage in the runner is still marked experimental. Checkout and setup-node are as for Next.js.

AI CodeOps setting: Test command node --test --experimental-test-coverage --test-coverage-lines=80. The runner's report ends with an all files row, which AI CodeOps reads.

Python / Django

- uses: actions/setup-python@v7
  with:
    python-version: "3.13"
    cache: pip
- run: pip install -r requirements.txt coverage
- run: python manage.py makemigrations --check --dry-run
- run: coverage run --source=. manage.py test
- run: coverage report --fail-under=80

The migrations check fails when a model changed without a migration. That's an easy step for an agent to forget. Put omit rules for migrations and settings in .coveragerc, but keep --fail-under on the command line.

AI CodeOps setting: Test command coverage run --source=. manage.py test && coverage report --fail-under=80. The report's TOTAL line carries the percentage.

FastAPI

- run: pip install -r requirements.txt -r requirements-dev.txt
- run: pytest --cov=app --cov-report=term-missing --cov-fail-under=80

Set up Python as for Django. requirements-dev.txt holds pytest, pytest-cov and httpx, which FastAPI's TestClient needs. Change --cov=app to your package.

AI CodeOps setting: Test command pytest --cov=app --cov-fail-under=80. pytest-cov's TOTAL line carries the percentage.

Go

- uses: actions/setup-go@v7
  with:
    go-version-file: go.mod
- run: go vet ./...
- run: go test -race -coverprofile=coverage.out ./...
- name: 80% statement coverage floor
  run: |
    total=$(go tool cover -func=coverage.out | awk '/^total:/ { sub("%", "", $3); print $3 }')
    echo "Total coverage: ${total:-none}%"
    awk -v t="$total" 'BEGIN { exit !(t != "" && t + 0 >= 80) }' || { echo "::error::Coverage ${total:-none}% is below the 80% floor"; exit 1; }

go test has no floor flag, so the step reads the total: line and compares it. On a small test module at 33.3% it fails at 80 and passes at 30. An empty total fails too, so a test step that wrote no profile can't slip through.

AI CodeOps setting: Test command go test -coverprofile=coverage.out ./... && go tool cover -func=coverage.out. go tool cover -func ends with a total: line, which AI CodeOps reads like a TOTAL line.

Ruby on Rails

- uses: ruby/setup-ruby@v1
  with:
    bundler-cache: true
- run: bin/rails db:prepare
  env:
    RAILS_ENV: test
- run: bin/rails test
  env:
    RAILS_ENV: test
    PARALLEL_WORKERS: "1"
    COVERAGE_MIN: "80"

At the very top of test/test_helper.rb:

require "simplecov"
SimpleCov.start "rails" do
  minimum_coverage Integer(ENV.fetch("COVERAGE_MIN", "80"))
end

SimpleCov has no command-line floor, so the workflow passes it in an environment variable. One worker keeps the suite in one process, so SimpleCov sees all of it.

AI CodeOps setting: Test command bin/rails test, with COVERAGE_MIN set as above. SimpleCov prints a Line Coverage: 85.0% style line at the end of the run.

Java / Spring Boot (Maven)

- uses: actions/setup-java@v6
  with:
    distribution: temurin
    java-version: "21"
    cache: maven
- run: ./mvnw -B verify -Dcoverage.minimum=0.80

Add jacoco-maven-plugin 0.8.15 to pom.xml with the prepare-agent, report and check goals, and a BUNDLE rule on LINE COVEREDRATIO with <minimum>${coverage.minimum}</minimum>. check binds to verify, so the build fails below the floor. For Gradle, GitHub's dependency graph only sees the build through dependency submission, so set that up before you rely on the license check.

AI CodeOps setting: JaCoCo writes its report to files, not the console, so a session's run records pass or fail but no coverage. Keep the floor in the Maven build, and the build fails below it either way. Leave minCoveragePct out of the release gate call for this stack: with no coverage recorded, the gate would deny every change.

.NET

- uses: actions/setup-dotnet@v6
  with:
    dotnet-version: "10.0.x"
- run: dotnet restore --locked-mode
- run: dotnet test --no-restore /p:CollectCoverage=true /p:Threshold=80 /p:ThresholdType=line /p:ThresholdStat=total

Add coverlet.msbuild to each test project and set RestorePackagesWithLockFile to true, so there are packages.lock.json files for --locked-mode and for Syft. ThresholdStat=total checks the whole solution instead of each module. One catch: coverlet.msbuild works with VSTest, the default, and collects nothing under Microsoft.Testing.Platform. If your global.json opts into that platform, use its own coverage extension.

AI CodeOps setting: as with JaCoCo, rely on the build's own Threshold to fail the run; check the session's run page before you also set minCoveragePct.

Rust

- run: rustup update stable
- uses: taiki-e/install-action@cargo-llvm-cov
- run: cargo clippy --all-targets --all-features -- -D warnings
- run: cargo llvm-cov --all-features --workspace --fail-under-lines 80

This is the setup cargo-llvm-cov's own CI example uses, plus the floor flag. Commit Cargo.lock, for libraries too, so the SBOM and the license check see exact versions.

AI CodeOps setting: Test command cargo llvm-cov --workspace --fail-under-lines 80. The flag fails the run below the floor; check the run page for which percentage the session recorded before you also set minCoveragePct.

Monorepo

A monorepo needs one more idea. You don't want to run every package's tests on every change, so you filter by path. But GitHub reports a job skipped by its if as successful, even when it's a required check. If web is required and the job that decides whether to run it fails, web is skipped, and the pull request passes.

The fix is one final job that runs every time and reads every result:

changes:
  runs-on: ubuntu-latest
  permissions:
    contents: read
    pull-requests: read
  outputs:
    web: ${{ steps.filter.outputs.web }}
    api: ${{ steps.filter.outputs.api }}
  steps:
    - uses: actions/checkout@v7
      with:
        persist-credentials: false
    - uses: dorny/paths-filter@v4
      id: filter
      with:
        filters: |
          web:
            - 'apps/web/**'
            - 'package-lock.json'
          api:
            - 'services/api/**'

# web and api: the Next.js and FastAPI test steps above, each with
# needs: changes and if: needs.changes.outputs.<name> == 'true'

gate:
  name: Quality gates
  if: always()
  needs: [changes, web, api, secrets, sbom, licenses]
  runs-on: ubuntu-latest
  steps:
    - env:
        RESULTS: ${{ toJSON(needs.*.result) }}
      run: |
        echo "$RESULTS"
        if echo "$RESULTS" | grep -Eq '"(failure|cancelled)"'; then exit 1; fi

Require only Quality gates. A skip now passes only when the filter said that package didn't change. Secrets, SBOM and licenses still run on every change, across the whole repository, and Syft finds every package's lockfile.

AI CodeOps setting: a monorepo usually needs a Test command of its own, such as a script that runs the packages a change touches. Set it on the project; inference only looks for one package.json test script, pytest or Go at the root.

Making them required checks

A workflow that fails doesn't stop a merge by itself. GitHub only blocks the merge button on checks you mark as required: in branch protection, "all required status checks must pass before collaborators can merge changes into the protected branch" (About protected branches, checked on 24 October 2026). The same page lists skipped among the states that satisfy a required check, which is why the monorepo recipe ends in one job that always runs.

  • Require the checks. In branch protection or a ruleset on the default branch, require Tests and coverage floor, Secrets scan, SBOM (CycloneDX) and License policy, or Quality gates for the monorepo. A check only appears in the picker after it has run once, so open a test pull request first. GitHub rulesets for AI agents walks through the ruleset itself.
  • Protect the gates. CODEOWNERS on .github/, with code-owner review required. A change to a gate is a change to your policy.
  • Pin harder if you need to. These recipes pin each action to its current major version. For stricter supply-chain hygiene, pin each to a full commit SHA and let Dependabot bump them.
  • Break each gate once. Delete a test, add a GPL dependency, commit a fake key. Watch each job go red before you trust it green.

The AI CodeOps variant

AI CodeOps has its own release gate. It doesn't read a config file in your repository. Your CI asks it one question over the API, and it answers from every AI CodeOps session that touched the change: open findings, the session's own test run and coverage, licenses in the project's SBOM, and any required workflows or promotions.

release-gate:
  if: startsWith(github.head_ref, 'codeops/run-')
  runs-on: ubuntu-latest
  steps:
    - env:
        AICODEOPS_API_KEY: ${{ secrets.AICODEOPS_API_KEY }}
        PR_URL: ${{ github.event.pull_request.html_url }}
        HEAD_SHA: ${{ github.event.pull_request.head.sha }}
      run: |
        body=$(jq -n --arg pr "$PR_URL" --arg sha "$HEAD_SHA" \
          '{pullRequestURL: $pr, commitSHA: $sha, blockingSeverity: "high", minCoveragePct: 80}')
        response=$(curl -sS --fail --retry 3 --max-time 30 -X POST \
          "https://console.aicodeops.dev/api/release/check" \
          -H "Authorization: Bearer $AICODEOPS_API_KEY" \
          -H "Content-Type: application/json" -d "$body") \
          || { echo "Release check unavailable: failing closed"; exit 1; }
        [ "$(echo "$response" | jq -r '.allowed')" = "true" ] \
          || { echo "$response" | jq -r '.summary, (.reasons // [])[]'; exit 1; }

The if matters. AI CodeOps opens its pull requests from codeops/run-<id> branches, and the gate denies a change with no AI CodeOps sessions, so running it on a person's pull request would always fail. The endpoint returns HTTP 200 for both allow and deny, so the step reads allowed. The fields are on the API page.

One caution on minCoveragePct. It denies a change whose test run reported no coverage, because a floor it can't check doesn't pass. If your stack is one where the session records no coverage, such as JaCoCo above, take that field out of the body.

Two cautions if you add disallowedLicenses. The match is exact, so GPL-3.0 doesn't match GPL-3.0-only: list every spelling your SBOMs use. And the check reads the SBOM recorded for the project in AI CodeOps. With a license rule set and no SBOM recorded, the gate denies, because it can't check.

The other half is workspace policy. These rules make any AI change to the files that define your gates wait for an approved review:

[
  { "id": "review-ci-definitions", "action": "diff.apply", "resource": ".github/**", "decision": "ask" },
  { "id": "review-secret-scan-config", "action": "diff.apply", "resource": ".gitleaks.toml", "decision": "ask" },
  { "id": "review-vitest-config", "action": "diff.apply", "resource": "**vitest.config.*", "decision": "ask" }
]

** crosses folders and * stays inside one, so **vitest.config.* matches the config at the root and in every package. Use both halves on top of the plain gates, not instead of them. If you'd rather start from a whole workflow, the templates include a Python coverage floor and an SBOM license gate.

Got a stack we missed?

PHP, Elixir, Kotlin with Gradle and Swift are the obvious gaps. We'll publish all ten recipes as an MIT-licensed repository, and we'd like more. If you run one of these stacks, contribute a recipe. It needs a green run and a red run as proof, and you're credited with a link.

The rules each gate applies on the AI CodeOps side, and how to triage a blocked change, are in the quality gates docs.

Key takeaways

  • A gate only blocks a merge once it is a required check; a red workflow on its own is advice.
  • Fail closed: no continue-on-error, no || true, and an empty SBOM or unreadable coverage number fails.
  • Keep the coverage floor in the workflow, and put .github/ under CODEOWNERS, so the change that drops coverage can't also drop the floor.
  • In a monorepo, require one final job that reads every result, because a skipped job counts as passed.
  • AI CodeOps records a session's coverage as a whole number rounded down, so 79.6% fails a floor of 80.