Skip to content

Commit 8706bc2

Browse files
committed
ci(opa): migrate to setup-opa action, pin runner and OPA version
- Replace manual wget + chmod install with the official open-policy-agent/setup-opa@v2.2.0 action (checksum-verified, cached, no hardcoded download URL) - Bump OPA from v0.43.0 to v1.6.0 (static binary, matching prior behavior via `static: true`) - Upgrade actions/checkout from v2 to v7 - Pin runner to ubuntu-24.04 instead of floating ubuntu-latest - Add contents:read permissions and PR concurrency cancellation - Scope trigger to argocd-helm-charts/gatekeeper/policies/** via paths filter, add reopened to trigger types - Remove dead `if: github.event_name == 'pull_request'` condition (job already only runs on pull_request) Note: OPA v1.x defaults to Rego v1 syntax, a breaking change from the v0.43.0 baseline. Verify `opa test` passes against existing .rego policies before merging; if failures are syntax-related rather than genuine test failures, policies may need migration to v1 Rego syntax or a temporary --v0-compatible flag.
1 parent ac56822 commit 8706bc2

2 files changed

Lines changed: 26 additions & 14 deletions

File tree

.github/workflows/opa-test.yml

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
1-
name: OPA Test
1+
name: Test OPA Policies
22

3-
"on":
3+
on:
44
pull_request:
55
types:
66
- opened
77
- synchronize
8+
- reopened
9+
paths:
10+
- 'argocd-helm-charts/gatekeeper/policies/**'
11+
12+
permissions:
13+
contents: read
14+
15+
# This will only allow a single markdownlint action to run per PR.
16+
# Any github action running on the older commits will be aborted.
17+
concurrency:
18+
group: test-opa-${{ github.workflow }}-${{ github.event.pull_request.number }}
19+
cancel-in-progress: true
820

921
jobs:
10-
opa-test:
11-
runs-on: ubuntu-latest
22+
test-opa:
23+
runs-on: ubuntu-24.04
1224

1325
steps:
14-
- name: Checkout code
15-
uses: actions/checkout@v2
26+
- name: Checkout code
27+
uses: actions/checkout@v7
1628

17-
- name: Install OPA
18-
run: |
19-
wget https://github.com/open-policy-agent/opa/releases/download/v0.43.0/opa_linux_amd64_static -O /usr/local/bin/opa
20-
chmod +x /usr/local/bin/opa
29+
- name: Setup OPA
30+
uses: open-policy-agent/setup-opa@v2.2.0
31+
with:
32+
version: "1.6.0"
33+
static: true
2134

22-
- name: Run OPA tests
23-
if: ${{ github.event_name == 'pull_request' }}
24-
run: |
25-
opa test ./argocd-helm-charts/gatekeeper/policies -v
35+
- name: Run OPA tests
36+
run: opa test ./argocd-helm-charts/gatekeeper/policies -v

argocd-helm-charts/gatekeeper/policies/K8sRequiredResources.rego

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# package k8srequiredresources handles compliance of containers and initContainers
22
# having a predefined resource limits and requests of cpu and memory.
33
# Objects that do not specify the resource limits and requests show up as violators of the policy.
4+
# Test comment
45

56
package k8srequiredresources
67

0 commit comments

Comments
 (0)