Reviewing in CI
Make CodeVeto the required check on every pull request, with the GitHub Action or the Forgejo workflow.
On this page
How the CI review works
The CI job is the enforcement point. It runs on every push to a pull request and:
- comes from the base branch (
pull_request_target), so the pull request cannot edit its own gate; - never checks out, installs or runs anything from the pull request: it fetches the head as Git data into a private ref and verifies it equals the event's head SHA;
- reads configuration from the base (the merge base of base and head);
- reports one status,
codeveto / review, which you make a required check.
GitHub: write the workflow
Run this in your repository:
codeveto init githubA released CodeVeto knows the commit of its release and pins the action to it. A build that does not, such as one installed from source, refuses and says what to pass:
codeveto: init: this codeveto build does not know the commit of its release (v0.1.0); pass --action-sha <full commit SHA of the release> to pin the action, or --allow-tag to use the movable v0.1 tag--action-sha pins to a release commit you looked up. --allow-tag uses the movable v0.1 tag, and the file then says it is not a pin. The result, .github/workflows/codeveto.yml:
name: codeveto
on:
pull_request_target:
merge_group:
permissions: {}
concurrency: # block style: ${{ }} is not valid inside a { } flow mapping
group: codeveto-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
review:
name: codeveto / review
runs-on: ubuntu-latest
permissions: { contents: read, pull-requests: write }
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1, base branch only
with: { fetch-depth: 0, persist-credentials: false, submodules: false, lfs: false }
- uses: spink-dev/codeveto@0123456789abcdef0123456789abcdef01234567 # v0.1.0
with: { fail-on: error }The SHA above is an example; yours is the release commit. init never overwrites an existing workflow without --force, and prints what to do next:
wrote .github/workflows/codeveto.yml
Next: commit it on the default branch, make 'codeveto / review' a required check, and protect .github/workflows/ with CODEOWNERS or a ruleset.GitHub: make it required
The workflow only enforces once three things are set:
- Commit it on the default branch.
pull_request_targetruns the workflow as it is on the base branch, so a pull request that adds it is not reviewed by it until it is merged. - Require the check. In a branch ruleset (or branch protection) for the default branch, require the status check
codeveto / review. With a merge queue, themerge_grouptrigger reviews the queued change too. - Protect the gate. Require code owner review for the workflow and the policy, so a change to them needs the people who own them:
# .github/CODEOWNERS
/.github/workflows/ @example-org/review-owners
/.codeveto.toml @example-org/review-ownersTurn on "Require review from Code Owners" in the same ruleset. CodeVeto also reports such changes itself: agent/codeveto-workflow-changed blocks when a workflow that runs CodeVeto changes its inputs or trigger or drops the step, and agent/codeowners-changed flags edits to CODEOWNERS.
Do not add paths, paths-ignore or branches-ignore filters to the workflow: a pull request the filter skips gets no review.
Action inputs
| Input | Default | Meaning |
|---|---|---|
fail-on |
error |
The lowest severity that blocks: error, warning, note or never. |
ai |
none |
The AI pass: none, claude or openai. |
ai-model |
empty | The model ID; empty for the provider default (openai needs one). |
ai-base-url |
empty | The model API base URL, passed as --ai-base-url; empty for the provider default. |
anthropic-api-key |
empty | The Claude API key, used only when ai is claude. |
openai-api-key |
empty | The OpenAI-compatible key, passed as both OPENAI_API_KEY and CODEVETO_AI_API_KEY. |
ai-on-forks |
false |
Run the AI pass on pull requests from forks too. Off by default for cost control. |
comment |
true |
Post the sticky summary comment and inline review comments. |
sarif |
false |
Upload SARIF to code scanning. Needs security-events: write. |
github-token |
${{ github.token }} |
The token for fetching the head and publishing. |
bot-login |
empty | The login the token comments as, when it cannot read its own user (a GitHub App or a fine-grained token), such as my-app[bot]. Empty means github-actions[bot]. |
Outputs: exit-code (0, 1 or 2; empty if the review did not run) and report (the path of the JSON report).
All inputs reach the scripts through env:, never through ${{ }} inside run:. CodeVeto runs from the action's own source at the pinned commit, with Python 3.15 from actions/setup-python: nothing is built, nothing comes from PyPI, nothing comes from the pull request. Only when ai is not none does it install the provider SDKs, into a private virtual environment, from the hash-pinned requirements-ai.txt shipped with the action.
With the AI pass
- uses: spink-dev/codeveto@0123456789abcdef0123456789abcdef01234567 # v0.1.0
with:
fail-on: error
ai: claude
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}Pull requests from forks get no AI pass unless ai-on-forks: true: anyone can open one, and each run costs tokens. AI findings are advisory unless the base branch's .codeveto.toml sets [ai] blocking = true. See AI review.
With SARIF
Add the permission to the job and turn the input on:
permissions: { contents: read, pull-requests: write, security-events: write }
steps:
# ...
- uses: spink-dev/codeveto@0123456789abcdef0123456789abcdef01234567 # v0.1.0
with: { fail-on: error, sarif: true }What the action publishes
- Annotations on the changed lines, blocking findings first.
- A job summary with the Markdown report.
- One sticky comment on the pull request (marked
<!-- codeveto:summary -->), created once and updated on every run, so it never shows an older verdict. - One review per run (
event: COMMENT) with at most 25 inline comments; the rest are only in the summary. Comments the same identity already posted for the same finding are not repeated.
The report is treated as untrusted before anything is published: strict JSON, a size cap, schema validation, base and head that must equal the event's, and a verdict consistent with its findings. Findings outside the lines the pull request changes are dropped. If the pull request's head or base moved while the job ran, nothing is posted; the newer run will.
If CodeVeto could not produce a usable report, the job fails with "CodeVeto did not complete" and exit 2, and the sticky comment says so.
Events
| Event | Compares | Publishes |
|---|---|---|
pull_request_target |
merge base of base and head to head | annotations, summary, comment, review |
merge_group |
base_sha to head_sha, direct |
annotations, summary |
push |
before to after, direct |
annotations, summary |
On push, a new branch (zero before) compares from the merge base with the default branch, a deleted branch is skipped with exit 0, and a before that cannot be fetched (rewritten history) is incomplete. Any other event is incomplete with "unsupported event". A shallow clone is incomplete with the fix: fetch-depth: 0.
Forgejo
codeveto init forgejoThis writes .forgejo/workflows/codeveto.yml: a pull_request_target job with run: steps only. It checks out the base revision, installs exactly this CodeVeto version into a virtual environment with pip --require-hashes, fetches and verifies the head as data, reviews, and publishes. The wheel hashes come from PyPI's JSON API for this version over HTTPS. Without network access, init forgejo fails with instructions rather than writing an unpinned install; pass the hashes yourself with --hash (repeatable):
codeveto init forgejo --hash sha256:<64 hex digits of the wheel>wrote .forgejo/workflows/codeveto.yml
Next: commit it on the default branch, make the 'codeveto / review' status required in branch protection, and protect .forgejo/workflows/.The runner image needs Git and Python 3.11 or newer. Change runs-on: docker to a runner label of your instance. The template reviews with the deterministic rules only (--fail-on error --ai none).
codeveto publish forgejo then posts a commit status with the context codeveto / review (success when clear, failure when vetoed, error when incomplete or the report was rejected) and one sticky comment. It uses the automatic workflow token and the instance's own API (GITHUB_SERVER_URL + /api/v1), and applies the same untrusted-report checks and head re-check as on GitHub.
Make the codeveto / review status required in the branch protection of the default branch, and protect .forgejo/workflows/ with code owners.