Skip to content

Commit c75727a

Browse files
author
Marat Komarov
committed
Adding test-new-style gh job
1 parent 79443f1 commit c75727a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

.github/workflows/opa.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,34 @@ jobs:
3434
placement
3535
providers
3636
user
37+
38+
test-new-style:
39+
runs-on: ubuntu-latest
40+
container:
41+
image: ubuntu:latest # Because it has 'curl'
42+
options: --cpus 1
43+
steps:
44+
- name: Checkout
45+
uses: actions/[email protected]
46+
- name: Install OPA
47+
env:
48+
OPA_VERSION: "0.27.1"
49+
run: |-
50+
apt-get -yq update && apt-get install -yq curl;
51+
curl -L -o /usr/bin/opa https://github.com/open-policy-agent/opa/releases/download/v${OPA_VERSION}/opa_linux_amd64 2>/dev/null;
52+
chmod +x /usr/bin/opa;
53+
- name: Test
54+
env:
55+
TERM: xterm-256color
56+
run: |-
57+
# Directories having 'main.tf' are considered a 'new-style' example
58+
dirs=$(find . -name 'main.tf' | awk -F'/[^/]*$' '{print $1}' | sort | uniq);
59+
for polgrp in $dirs; do
60+
# Call opa test command for every Rego file in every example directory.
61+
for pol in $(find $polgrp -name '*.rego'); do
62+
tput setaf 2;
63+
echo "Test $pol";
64+
tput sgr0;
65+
opa eval -f pretty --data $pol -i ${pol%.rego}.input.json data.terraform.deny;
66+
done;
67+
done;

0 commit comments

Comments
 (0)