masterpointio/OPA Rego Test and Coverage Report
Run OPA tests and generate coverage report for PRs. Test your OPA Rego policies!
View on GitHubTrust Signals
- Scorecard Score
- not yet scored
- Maintenance Recency
- Stale
- License
- None
Inputs
| name | description | required | default |
|---|---|---|---|
| path | Path to the directory containing OPA Rego files to test. | yes | — |
| test_mode | Whether to test the Rego by an entire directory (including entire package, e.g. `opa test ./`) or by individual files (e.g. `opa test a_test.rego a.rego`). Options of `directory` or `file`. Default is `directory`. | no | directory |
| test_file_postfix | The postfix to use for test files, only applicable for testing file by file. E.g. notification.rego <> notification_test.rego. Default is "_test". | no | _test |
| write_pr_comment | Flag to write an user friendly PR comment of the test results. Default of true. | no | true |
| pr_comment_title | Title of the PR comment of the test results. | no | 🧪 OPA Rego Policy Test Results |
| pr_comment_mode | Mode that will be used to update comment. Options of upsert (update in place) or recreate. | — | upsert |
| run_coverage_report | Flag to run OPA coverage tests and write to the PR. The `write_pr_comment` must be enabled for the coverage report to be written. Default of true. | no | true |
| report_untested_files | Check & report in the PR comments of the Rego files that do not have any corresponding test files. For best conventions, append the postfix `_test` (or what you set as the `test_file_postfix` input) for your test file. E.g. `notification.rego` <> `notification_test.rego` | no | false |
| opa_version | Version of OPA CLI to use. Default is 1.4.2, latest as of 2025-05-15. | no | 1.4.2 |
| opa_static | Whether to use the static binary. Default is false. | no | false |
| v1_compatible_check | Flag to run OPA v1 compatibility check (`opa check --v1-compatible`) on all Rego files in the path. Fails the action if any files are not Rego v1 compatible. Default of true. | no | true |
| indicate_source_message | Flag to comment the origins (this repository) of the GitHub Action in the PR comment. Default of true. | no | true |
Outputs
| name | description |
|---|---|
| parsed_results | The parsed results after processing the tests and/or coverage report. |
| tests_failed | A `true` or `false` flag indicating if any of the tests failed or not. |