Skip to content
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
5 changes: 5 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Describe your changes

## Reminder:

- When the PR is ready, be sure to run `npm run build` to compile into the distribution `/dist` folder, which is the source code that the Action uses.
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Tests

on: pull_request

permissions:
contents: read
checks: write
pull-requests: write

jobs:
test-typescript:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run build --if-present
- run: npm test
- name: Jest Coverage Report
uses: ArtiomTr/jest-coverage-report-action@c026e98ae079f4b0b027252c8e957f5ebd420610 # v2.3.0

test-action-on-itself:
name: Test the GitHub Action on itself
runs-on: ubuntu-latest

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Test Local Action
id: test-action
uses: ./
with:
path: ./examples
report_untested_files: true
pr_comment_title: Below is the Action testing on itself with this PR's source code against the `/examples` directory. Confirm it is as expected.
3 changes: 3 additions & 0 deletions .jest/setupTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Set up the environment for the tests
// All these values can be empty because in the tests, we are testing the functions directly.
process.env.test_result = "mock";
6 changes: 6 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ runtimes:
- python@3.10.8
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
ignore:
- linters: [ALL]
paths:
# Ignore linting the distribution packaged folder
- dist/**
- .github/pull_request_template.md
enabled:
- actionlint@1.7.1
- checkov@3.2.231
Expand Down
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ This GitHub Action automates the process of testing OPA (Open Policy Agent) Rego

## 🧪 Running Tests

On each pull request, there is a GitHub Actions workflow that runs the tests automatically, along with it testing itself by running the Action on itself against the `/examples` directory and commenting the OPA results on the same PR. To test locally, see below:

1. `npm install`
2. `npm run test`

Expand All @@ -132,7 +134,7 @@ To package for distribution, simply run the command which will do the above and
npm run build
```

To create a new release... TODO, release please with `npm run build` and commit to /dist distribution
To create a new release, merge the pull request created by Release Please. This will automatically create a new release with the version number and the changes made.

## 🤝 Contributing

Expand All @@ -145,15 +147,7 @@ Contributions are welcome! Please feel free to submit a Pull Request or open any
- ![Masterpoint GitHub Actions OPA Rego Test PR Example](./assets/readme-example-2.png)
- ![Masterpoint GitHub Actions OPA Rego Test PR Example](./assets/readme-example-3.png)

### To-Do's:
### TODO

- make composite action logging better
- add debug logs
- more tests + fix tests + run test on ci
- deal with issues like
- `1 error occurred: ./access/label-based-team-access.rego:35: rego_type_error: conflicting rules data.spacelift.deny found`
- need better visibliity to when this happens and fails
- right now, it just exits code 2. not helpful and someone new to sys wouldn't know where to look at.
- one way is to PR comment error occured in the execution of the tests. please tak eal ook at the logs..
- publish to marketplace
- codeowners
- add a little something at the bottom, generated with action by Masterpoint? user can turn off.
Loading