Skip to content

Commit

Permalink
feat(report-message): add indicate_source_message flag for referenc…
Browse files Browse the repository at this point in the history
…e to this repo (#9)

* feat: watermark message

* feat: watermarking

* Watermark

* build
  • Loading branch information
oycyc authored Aug 22, 2024
1 parent d1c2ec7 commit e5f6875
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 18 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,17 @@ In the example below, all `_test.rego` files' location are valid and will be exe

### Inputs

| Input | Description | Required | Default |
| ----------------------- | ------------------------------------------------------------------------------------------ | -------- | --------------------------------- |
| `path` | Path to the directory containing OPA Rego files to test | No | `.` (root directory) |
| `test_file_postfix` | Postfix of the test files to run (e.g. notification.rego <> notification_test.rego) | No | `_test` |
| `write_pr_comment` | Flag to write a user-friendly PR comment with test results | No | `true` |
| `pr_comment_title` | Title of the PR comment for 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. | No | `upsert` |
| `run_coverage_report` | Flag to run OPA coverage tests and include in PR comment | No | `true` |
| `report_untested_files` | Check & report Rego files without corresponding test files | No | `false` |
| `opa_version` | Version of the OPA CLI to use. | No | `0.67.1` |
| Input | Description | Required | Default |
| ------------------------- | ----------------------------------------------------------------------------------------------- | -------- | --------------------------------- |
| `path` | Path to the directory containing OPA Rego files to test | No | `.` (root directory) |
| `test_file_postfix` | Postfix of the test files to run (e.g. notification.rego <> notification_test.rego) | No | `_test` |
| `write_pr_comment` | Flag to write a user-friendly PR comment with test results | No | `true` |
| `pr_comment_title` | Title of the PR comment for 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. | No | `upsert` |
| `run_coverage_report` | Flag to run OPA coverage tests and include in PR comment | No | `true` |
| `report_untested_files` | Check & report Rego files without corresponding test files | No | `false` |
| `opa_version` | Version of the OPA CLI to use. | No | `0.67.1` |
| `indicate_source_message` | Flag to comment the origins watermark (this repository) of the GitHub Action in the PR comment. | No | `true` |

### Outputs

Expand Down Expand Up @@ -150,4 +151,3 @@ Contributions are welcome! Please feel free to submit a Pull Request or open any
### TODO

- publish to marketplace
- add a little something at the bottom, generated with action by Masterpoint? user can turn off.
15 changes: 9 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
name: "OPA Test and Coverage Report GitHub Actions"
name: "OPA Test and Coverage Report"
description: "Run OPA tests and generate coverage report for PRs. Test your OPA Rego policies!"
author: ""

#
author: Masterpoint

branding:
icon: "check-circle"
color: "green"
icon: "zap"
color: "blue"

inputs:
path:
Expand Down Expand Up @@ -40,6 +38,10 @@ inputs:
description: "Version of OPA CLI to use. Default is 0.67.1."
required: false
default: "0.67.1"
indicate_source_message:
description: Flag to comment the origins watermark (this repository) of the GitHub Action in the PR comment. Default of true.
required: false
default: true
outputs:
parsed_results:
description: The parsed results after processing the tests and/or coverage report.
Expand Down Expand Up @@ -128,6 +130,7 @@ runs:
no_test_files: ${{ steps.find-no-test.outputs.no_test_files }}
pr_comment_title: ${{ inputs.pr_comment_title }}
run_coverage_report: ${{ inputs.run_coverage_report }}
indicate_source_message: ${{ inputs.indicate_source_message }}

# Create (or update in-place) a PR comment of the test result output
- name: Comment on PR
Expand Down
4 changes: 4 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25161,6 +25161,10 @@ function formatResults(results, coverageResults, showCoverage) {
row += `| ${detailsColumn} |\n`;
output += row;
}
if (process.env.indicate_source_message === "true") {
output +=
"\n\n<small>Report generated by [🧪 GitHub Actions for OPA Rego Test](https://github.com/masterpointio/github-action-opa-rego-test)</small>";
}
return output;
}
function main() {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ export function formatResults(
output += row;
}

if (process.env.indicate_source_message === "true") {
output +=
"\n\n<small>Report generated by [🧪 GitHub Actions for OPA Rego Test](https://github.com/masterpointio/github-action-opa-rego-test)</small>";
}

return output;
}

Expand Down

0 comments on commit e5f6875

Please sign in to comment.