Conversation
|
Caution Review failedThe pull request is closed. WalkthroughThe changes introduce a modular refactor of the OPA Rego test GitHub Action, shifting from inline parsing and execution to structured, type-safe modules for test and coverage processing. New configuration options, improved documentation, and updated workflows support both directory and file-based test modes. Test output formats and coverage reporting are modernized and standardized. Changes
Sequence Diagram(s)sequenceDiagram
participant GH_Action as GitHub Action
participant OpaCmd as opaCommands.ts
participant TestProc as testResultProcessing.ts
participant Format as formatResults.ts
GH_Action->>OpaCmd: Execute OPA tests (by directory or file)
OpaCmd-->>GH_Action: Return raw JSON test & coverage output
GH_Action->>TestProc: Process raw test results
GH_Action->>TestProc: Process raw coverage report
TestProc-->>GH_Action: Return processed results
GH_Action->>Format: Format results for PR comment
Format-->>GH_Action: Return Markdown table
GH_Action->>GH_Action: Post comment to PR
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (18)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
This reverts commit 1ab3758.
Coverage report
Show new covered files 🐣
Test suite run success15 tests passing in 1 suite. Report generated by 🧪jest coverage report action from 6852b79 |
There was a problem hiding this comment.
Pull Request Overview
This PR enables the Action to test itself by running against its own policy files and examples, with changes across rego policies, tests, workflow configurations, and project metadata.
- Introduces new rego policies and tests for push, cancel and file validations.
- Updates package metadata and workflow files to support both individual file and directory package testing.
- Adjusts test output processing and result formatting in the testing framework.
Reviewed Changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| spacelift_policies/**/*.rego | New and updated rego policies/tests to validate push‐policy behavior and cancellation logic. |
| package.json | Updated scripts and dependencies to support local testing and processing of test results. |
| action.yml | Revised input definitions and documentation to clarify test mode and result reporting. |
| .github/workflows/test.yml | Workflow updated with separate job configurations for file and package testing. |
| tests/* | Test files updated to parse and format new test/coverage output formats. |
| .vscode/launch.json | Debug configuration updated to support different test modes. |
Comments suppressed due to low confidence (3)
examples/tests/enforce-module-use-policy_test.rego:19
- [nitpick] A test case was removed and replaced with a comment '# TO ADD BACK'. Please clarify if this removal is intentional or if the test case should be reintroduced to avoid confusion during future maintenance.
-test_allow_deletion_of_controlled_resource_type {
action.yml:25
- The input default for write_pr_comment (and similar inputs) has been changed to a string value. Ensure that this change aligns with the expected input types across the Action to avoid type inconsistencies.
default: "true"
spacelift_policies/push_package/cancel_test.rego:29
- The variable 'main_stack' is referenced but not defined in this file. Consider importing or declaring 'main_stack' to ensure the test runs as intended.
"base": {"branch": main_stack.branch},
🤖 I have created a release *beep* *boop* --- ## [2.0.0](v1.2.0...v2.0.0) (2025-05-30) This new release changes how the OPA test commands are executed. Previously, it was executed as a bash script within the `action.yml`. Now, it is executed programmatically with [GitHub's `@action/exec` package ](https://github.com/actions/toolkit/tree/main/packages/exec). This allows the output to be easily fed as JSON and processed. There is also a new input option of `test_mode` which allows the option to test the OPA by the entire package (directory based aka `opa test ./`) or file by file (e.g. `opa test a_test.rego a.rego`). * The end result should be the same if the OPA package is structured properly. * Previously, it was tested file by file, so if tests are failing, to maintain old behavior, use the input `test_mode = file` * If encountering any issues, please be sure to report them! ### ⚠ BREAKING CHANGES * **ts:** use @actions/exec instead of bash script for OPA commands, allow testing entire directory vs file by file ([#27](#27)) ### Bug Fixes * **ts:** coverage only if it passed ([#30](#30)) ([7e4e69c](7e4e69c)) ### Code Refactoring * **ts:** use @actions/exec instead of bash script for OPA commands, allow testing entire directory vs file by file ([#27](#27)) ([9eecaf7](9eecaf7)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Describe your changes
test_modeto indicate whether to test the Rego by an entire directory -directory- (including entire package, e.g.opa test ./) or by individual file by file basis -file- (e.g.opa test a_test.rego a.rego). Default will test by entire directory package.test_mode = file.--v0-compatibleflag, see official OPA documentation on this: https://www.openpolicyagent.org/docs/latest/v0-compatibility/Reminder:
npm run buildto compile into the distribution/distfolder, which is the source code that the Action uses.Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Refactor
Tests