Skip to content

Commit

Permalink
Detailed run control with entrypoint script (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
petroprotsakh authored Jan 13, 2020
1 parent 0d338bc commit 297920d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y curl
RUN curl -L -o /opa https://openpolicyagent.org/downloads/latest/opa_linux_amd64
RUN chmod 755 /opa
RUN /opa version
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
17 changes: 8 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
name: OPA Test
description: Run Open Policy Agent tests
author: Petro Protsakh
name: "OPA Test"
description: "Run Open Policy Agent tests"
author: "Petro Protsakh"
branding:
icon: check-square
color: green
inputs:
tests:
description: Rego file or directory path where to discover tests. Defaults to repository root.
description: "Rego file or directory path where to discover tests. Defaults to repository root."
required: false
default: ./
options:
description: "Additional OPA command line flags. Example: `--verbose --timeout 3`. See `opa test --help` for more."
required: false
runs:
using: docker
image: docker://openpolicyagent/opa:latest
args:
- test
- ${{ inputs.tests }}
- -v
image: Dockerfile
21 changes: 21 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

printf "\n\n"
echo "# Open Policy Agent"
/opa version
printf "\n\n"

IFS=';'
mapfile -t lines < <(echo "$INPUT_TESTS" | grep -v "^$")

e_code=0
for line in "${lines[@]}"; do
read -r -a args <<< "$line"
cmd="/opa test ${args[*]} $INPUT_OPTIONS"
echo " 🚀 Running: $cmd"
printf "\n"
eval "$cmd" || e_code=1
printf "\n\n"
done

exit $e_code

0 comments on commit 297920d

Please sign in to comment.