Skip to content

Commit 41756bc

Browse files
author
Chris Vermeulen
authored
Merge pull request #10 from compliance-framework/feature-standard-make
Standardise make and actions
2 parents 9eec80b + 6598d1d commit 41756bc

5 files changed

Lines changed: 35 additions & 6 deletions

File tree

.github/workflows/build-and-upload.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ jobs:
3131
- name: gooci Upload Latest
3232
if: "!github.event.release.prerelease"
3333
run: gooci upload-single dist/bundle.tar.gz ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
34+

.github/workflows/push.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Push
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- '*'
8+
9+
jobs:
10+
test:
11+
permissions:
12+
contents: read
13+
uses: ./.github/workflows/test.yml

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ jobs:
1010
permissions:
1111
packages: write
1212
contents: write
13-
uses: ./.github/workflows/build-and-upload.yml
13+
uses: ./.github/workflows/build-and-upload.yml

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
- name: Setup OPA
1515
uses: open-policy-agent/setup-opa@v2
1616
with:
17-
version: latest
17+
version: 1.6.0
1818

1919
- name: Run OPA Tests
2020
run: opa test policies
2121

2222
- name: Run OPA Check
23-
run: opa check policies
23+
run: opa check policies

Makefile

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
# More info on the awk command:
1010
# http://linuxcommand.org/lc3_adv_awk.php
1111

12+
# Check if OPA CLI is installed
13+
OPA := $(shell command -v opa 2> /dev/null)
14+
ifeq ($(OPA),)
15+
$(error "opa CLI not found. Please install it: https://www.openpolicyagent.org/docs/latest/cli/")
16+
endif
17+
1218
##@ Help
1319
help: ## Display this concise help, ie only the porcelain target
1420
@awk 'BEGIN {FS = ":.*##"; printf "\033[1mUsage\033[0m\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-30s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
@@ -17,8 +23,17 @@ help-all: ## Display all help items, ie including plumbing targets
1723
@awk 'BEGIN {FS = ":.*#"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?#/ { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 } /^#@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
1824

1925
##@ Policies
20-
build: ## Build the OPA bundle
26+
test: ## Test policy files
27+
@OPA test policies
28+
29+
validate: ## Validate policy files
30+
@opa check policies
31+
32+
clean: # Cleanup build artifacts
33+
@rm -f dist/*
34+
35+
# Bundle the policies into a tarball for OCI registry
36+
build: clean ## Build the policy bundle
37+
@mkdir -p dist/
2138
@opa build -b policies -o dist/bundle.tar.gz
2239

23-
test: ## Test the OPA policies
24-
@opa test policies

0 commit comments

Comments
 (0)