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

feat(report-message): add indicate_source_message flag for reference to this repo #9

Merged
merged 4 commits into from
Aug 22, 2024
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
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 @@
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>";

Check warning on line 258 in src/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 259 in src/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

return output;
}

Expand Down
Loading