Skip to content

Commit

Permalink
ci: use custom OPA to format Rego
Browse files Browse the repository at this point in the history
Signed-off-by: Nikita Pivkin <[email protected]>
  • Loading branch information
nikpivkin committed Jan 14, 2025
1 parent f3720ad commit a50890e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/test-rego.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,14 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}

- name: Setup OPA
uses: ./.github/actions/setup-opa

- name: Rego Check
run: opa check lib checks --v0-v1
run: go run ./cmd/opa check lib checks --v0-v1

- name: OPA Format
run: |
files=$(opa fmt --list . | grep -v vendor || true)
if [ -n "$files" ]; then
echo "=== The following files are not formatted ==="
echo "$files"
make fmt-rego
if [ -n "$(git status --porcelain)" ]; then
echo "Run 'make fmt-rego' and push it"
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ rego: fmt-rego test-rego

.PHONY: fmt-rego
fmt-rego:
opa fmt -w lib/ checks/ examples/ .regal/rules
go run ./cmd/opa fmt -w lib/ checks/ examples/ .regal/rules

.PHONY: test-rego
test-rego:
Expand Down

0 comments on commit a50890e

Please sign in to comment.