Skip to content

Commit e5f6875

Browse files
authored
feat(report-message): add indicate_source_message flag for reference to this repo (#9)
* feat: watermark message * feat: watermarking * Watermark * build
1 parent d1c2ec7 commit e5f6875

File tree

5 files changed

+30
-18
lines changed

5 files changed

+30
-18
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,17 @@ In the example below, all `_test.rego` files' location are valid and will be exe
7575

7676
### Inputs
7777

78-
| Input | Description | Required | Default |
79-
| ----------------------- | ------------------------------------------------------------------------------------------ | -------- | --------------------------------- |
80-
| `path` | Path to the directory containing OPA Rego files to test | No | `.` (root directory) |
81-
| `test_file_postfix` | Postfix of the test files to run (e.g. notification.rego <> notification_test.rego) | No | `_test` |
82-
| `write_pr_comment` | Flag to write a user-friendly PR comment with test results | No | `true` |
83-
| `pr_comment_title` | Title of the PR comment for test results | No | `🧪 OPA Rego Policy Test Results` |
84-
| `pr_comment_mode` | Mode that will be used to update comment. Options of upsert (update in place) or recreate. | No | `upsert` |
85-
| `run_coverage_report` | Flag to run OPA coverage tests and include in PR comment | No | `true` |
86-
| `report_untested_files` | Check & report Rego files without corresponding test files | No | `false` |
87-
| `opa_version` | Version of the OPA CLI to use. | No | `0.67.1` |
78+
| Input | Description | Required | Default |
79+
| ------------------------- | ----------------------------------------------------------------------------------------------- | -------- | --------------------------------- |
80+
| `path` | Path to the directory containing OPA Rego files to test | No | `.` (root directory) |
81+
| `test_file_postfix` | Postfix of the test files to run (e.g. notification.rego <> notification_test.rego) | No | `_test` |
82+
| `write_pr_comment` | Flag to write a user-friendly PR comment with test results | No | `true` |
83+
| `pr_comment_title` | Title of the PR comment for test results | No | `🧪 OPA Rego Policy Test Results` |
84+
| `pr_comment_mode` | Mode that will be used to update comment. Options of upsert (update in place) or recreate. | No | `upsert` |
85+
| `run_coverage_report` | Flag to run OPA coverage tests and include in PR comment | No | `true` |
86+
| `report_untested_files` | Check & report Rego files without corresponding test files | No | `false` |
87+
| `opa_version` | Version of the OPA CLI to use. | No | `0.67.1` |
88+
| `indicate_source_message` | Flag to comment the origins watermark (this repository) of the GitHub Action in the PR comment. | No | `true` |
8889

8990
### Outputs
9091

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

152153
- publish to marketplace
153-
- add a little something at the bottom, generated with action by Masterpoint? user can turn off.

action.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
name: "OPA Test and Coverage Report GitHub Actions"
1+
name: "OPA Test and Coverage Report"
22
description: "Run OPA tests and generate coverage report for PRs. Test your OPA Rego policies!"
3-
author: ""
4-
5-
#
3+
author: Masterpoint
64

75
branding:
8-
icon: "check-circle"
9-
color: "green"
6+
icon: "zap"
7+
color: "blue"
108

119
inputs:
1210
path:
@@ -40,6 +38,10 @@ inputs:
4038
description: "Version of OPA CLI to use. Default is 0.67.1."
4139
required: false
4240
default: "0.67.1"
41+
indicate_source_message:
42+
description: Flag to comment the origins watermark (this repository) of the GitHub Action in the PR comment. Default of true.
43+
required: false
44+
default: true
4345
outputs:
4446
parsed_results:
4547
description: The parsed results after processing the tests and/or coverage report.
@@ -128,6 +130,7 @@ runs:
128130
no_test_files: ${{ steps.find-no-test.outputs.no_test_files }}
129131
pr_comment_title: ${{ inputs.pr_comment_title }}
130132
run_coverage_report: ${{ inputs.run_coverage_report }}
133+
indicate_source_message: ${{ inputs.indicate_source_message }}
131134

132135
# Create (or update in-place) a PR comment of the test result output
133136
- name: Comment on PR

dist/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25161,6 +25161,10 @@ function formatResults(results, coverageResults, showCoverage) {
2516125161
row += `| ${detailsColumn} |\n`;
2516225162
output += row;
2516325163
}
25164+
if (process.env.indicate_source_message === "true") {
25165+
output +=
25166+
"\n\n<small>Report generated by [🧪 GitHub Actions for OPA Rego Test](https://github.com/masterpointio/github-action-opa-rego-test)</small>";
25167+
}
2516425168
return output;
2516525169
}
2516625170
function main() {

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@ export function formatResults(
253253
output += row;
254254
}
255255

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

0 commit comments

Comments
 (0)