Skip to content

Commit 297920d

Browse files
Detailed run control with entrypoint script (#1)
1 parent 0d338bc commit 297920d

File tree

3 files changed

+37
-9
lines changed

3 files changed

+37
-9
lines changed

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM ubuntu:18.04
2+
RUN apt-get update && apt-get install -y curl
3+
RUN curl -L -o /opa https://openpolicyagent.org/downloads/latest/opa_linux_amd64
4+
RUN chmod 755 /opa
5+
RUN /opa version
6+
COPY entrypoint.sh /
7+
RUN chmod +x /entrypoint.sh
8+
ENTRYPOINT ["/entrypoint.sh"]

action.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
name: OPA Test
2-
description: Run Open Policy Agent tests
3-
author: Petro Protsakh
1+
name: "OPA Test"
2+
description: "Run Open Policy Agent tests"
3+
author: "Petro Protsakh"
44
branding:
55
icon: check-square
66
color: green
77
inputs:
88
tests:
9-
description: Rego file or directory path where to discover tests. Defaults to repository root.
9+
description: "Rego file or directory path where to discover tests. Defaults to repository root."
1010
required: false
1111
default: ./
12+
options:
13+
description: "Additional OPA command line flags. Example: `--verbose --timeout 3`. See `opa test --help` for more."
14+
required: false
1215
runs:
1316
using: docker
14-
image: docker://openpolicyagent/opa:latest
15-
args:
16-
- test
17-
- ${{ inputs.tests }}
18-
- -v
17+
image: Dockerfile

entrypoint.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
printf "\n\n"
4+
echo "# Open Policy Agent"
5+
/opa version
6+
printf "\n\n"
7+
8+
IFS=';'
9+
mapfile -t lines < <(echo "$INPUT_TESTS" | grep -v "^$")
10+
11+
e_code=0
12+
for line in "${lines[@]}"; do
13+
read -r -a args <<< "$line"
14+
cmd="/opa test ${args[*]} $INPUT_OPTIONS"
15+
echo " 🚀 Running: $cmd"
16+
printf "\n"
17+
eval "$cmd" || e_code=1
18+
printf "\n\n"
19+
done
20+
21+
exit $e_code

0 commit comments

Comments
 (0)