Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added opa-profile #97

Merged
merged 1 commit into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#### What is this PR About?
Describe the contents of the PR

#### How do we test this?
Have you followed the TESTING.md doc? If not, please provide commands/steps to test this PR.
#### Check list
- [ ] Have you created a test case in `_test/conftest-unittests.sh`
- [ ] Have you created a test case in `_test/opa-profile.sh`
- [ ] Have you created a test case in `_test/gatekeeper-integrationtests.sh`
- [ ] Have you followed the TESTING.md doc? If not, please provide commands/steps to test this PR.
- [ ] Have you re-generated `POLICIES.md`

cc: @redhat-cop/rego-policies
2 changes: 1 addition & 1 deletion .github/workflows/conftest.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run conftest
name: Run conftest-unittests.sh

on: [push, pull_request]

Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/opa-profile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Run opa-profile.sh

on: [push, pull_request]

jobs:
opa:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Opa eval --profile
uses: garethahealy/github-actions/confbatstest@master
with:
tests: _test/opa-profile.sh
policies: '[{"name": "deprek8ion", "url":"github.com/swade1987/deprek8ion.git//policies"}]'

- name: Upload opa-profile.log
uses: actions/upload-artifact@v2
with:
name: profile-results
path: opa-profile.log
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ local.properties

# BATS
_test/test_helper/
opa-profile.log

## Gatekeeper
**/template.yaml
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Run conftest](https://github.com/redhat-cop/rego-policies/workflows/Run%20conftest/badge.svg)
![Run conftest-unittests.sh](https://github.com/garethahealy/rego-policies/workflows/Run%20conftest-unittests.sh/badge.svg)

# rego-policies
[Rego](https://www.openpolicyagent.org/docs/latest/policy-language/) policies collection.
Expand Down
8 changes: 8 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@ Each policy must have a BATS test executed by its usecase:
- unit test files will be executed by [_test/conftest-unittests.sh](_test/conftest-unittests.sh).
- integration test files will be executed by [_test/gatekeeper-integrationtests.sh](_test/gatekeeper-integrationtests.sh).

Each policy, if applicable, must have an `opa eval --profile` test executed by [_test/opa-profile.sh](_test/opa-profile.sh).

## Execute unit tests
```bash
bats _test/conftest-unittests.sh
```

## Execute profile tests
```bash
bats _test/opa-profile.sh
```

## Execute integration units
```bash
_test/deploy-gatekeeper.sh deploy_gatekeeper
Expand All @@ -38,5 +45,6 @@ The following tools must be installed locally:

- [conftest](https://www.conftest.dev/install)
- [konstraint](https://github.com/plexsystems/konstraint#installation)
- [bats-core](https://github.com/bats-core/bats-core)
- [jq](https://stedolan.github.io/jq/download)
- [yq](https://pypi.org/project/yq)
Loading