Skip to content

ci: test and type-check Rego policy on PRs#107

Merged
sspaink merged 2 commits into
open-policy-agent:mainfrom
sspaink:ci/rego-policy-tests
Jul 16, 2026
Merged

ci: test and type-check Rego policy on PRs#107
sspaink merged 2 commits into
open-policy-agent:mainfrom
sspaink:ci/rego-policy-tests

Conversation

@sspaink

@sspaink sspaink commented Jul 6, 2026

Copy link
Copy Markdown
Member

What

Adds a rego-policy job to the PR check that type-checks and tests the Rego under tools/policy/, wired into the pr-check-summary gate:

  • opa check --strict tools/policy/ — catches parse/type errors.
  • opa test tools/policy/ -v — runs the existing pr_check_test.rego suite (9 tests).

Why

tools/policy/pr-check/pr_check.rego is the policy that drives this workflow's own change filter (deciding which module test jobs run). It had a test file but nothing in CI executed it, so a broken rule or a syntax/type error there could silently break CI gating and merge unnoticed.

Notes

  • Scoped to tools/policy/ only. The other .rego files in the repo are Java test fixtures/examples and are intentionally left out of these checks.
  • Uses the setup-opa action already used elsewhere in this workflow (same hash pin).
  • opa fmt was intentionally not added as a gate: formatting rules drift across OPA releases and the workflow pulls version: latest, which would make a fmt check flaky. check + test are deterministic.
  • Verified locally: opa test 9/9 pass, opa check --strict clean.

tools/policy/ contains the Rego that drives this workflow's own change
filter, but nothing tested it. Add a rego-policy job that runs
'opa check --strict' and 'opa test' so a parse/type error or broken rule
can't silently break CI gating.

Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>

@kroekle kroekle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

# Conflicts:
#	.github/workflows/pull-request.yml
@sspaink
sspaink requested a review from a team as a code owner July 14, 2026 17:30
@sspaink
sspaink merged commit bd5be3c into open-policy-agent:main Jul 16, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants