Skip to content

Commit

Permalink
Merge pull request #21 from im-open/adding-tests
Browse files Browse the repository at this point in the history
ARCH-2011 - Adding tests & upgrading node
  • Loading branch information
danielle-casella-adams authored Feb 28, 2024
2 parents bb53489 + 954bb43 commit 25f3784
Show file tree
Hide file tree
Showing 37 changed files with 3,239 additions and 292 deletions.
788 changes: 788 additions & 0 deletions .github/workflows/build-and-review-pr.yml

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
/.vscode/launch.json
node_modules/
/.vscode/launch.json
/pull-request.json
52 changes: 32 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,18 @@ This action does not run the Jest tests itself and it can only process one resul

## Failures

The status check can be seen as a new item on the workflow run, a PR comment or on the PR Status Check section. If the test results contain failures, the status check will be marked as failed. Having the status check marked as failed will prevent PRs from being merged. If this status check behavior is not desired, the `ignore-test-failures` input can be set and the outcome will be marked as neutral if test failures are detected. The status badge that is shown in the comment or status check body will still indicate it was a failure though.
The test status & action's conclusion can be viewed in multiple places:

- In the body of a PR comment this action generates
- Next to the name of one of the status checks under the `Checks` section of a PR
- Next to the name of one of the status checks under the `Jobs` section of the workflow run
- In the body of a status check listed on the workflow run

If the test results contain failures, the status check's conclusion will be set to `failure`. If the status check is required and its conclusion is `failure` the PR cannot be merged. If this required status check behavior is not desired, the `ignore-test-failures` input can be set and the conclusion will be marked as `neutral` if test failures are detected. The status badge that is shown in the comment or status check body will still indicate it was a `failure` though.

## Limitations

GitHub does have a size limitation of 65535 characters for a Status Check body or a PR Comment. This action will fail if the test results exceed the GitHub [limit]. To mitigate this size issue only failed tests are included in the output.
GitHub does have a size limitation of 65535 characters for a Status Check body or a PR Comment. This action would fail if the test results exceeded the GitHub [limit]. To mitigate this size issue only details for failed tests are included in the output in addition to a badge, duration info and outcome info. If the comment still exceeds that size, it will be truncated with a note to see the remaining output in the log.

If you have multiple workflows triggered by the same `pull_request` or `push` event, GitHub creates one checksuite for that commit. The checksuite gets assigned to one of the workflows randomly and all status checks for that commit are reported to that checksuite. That means if there are multiple workflows with the same trigger, your status checks may show on a different workflow run than the run that created them.

Expand Down Expand Up @@ -61,22 +68,27 @@ For failed test runs you can expand each failed test and view more details about

## Inputs

| Parameter | Is Required | Default | Description |
|--------------------------------|-------------|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `github-token` | true | N/A | Used for the GitHub Checks API. Value is generally: secrets.GITHUB_TOKEN. |
| `results-file` | true | N/A | The json results file generated by jest. |
| `report-name` | false | jest test results | The desired name of the report that is shown on the PR Comment and inside the Status Check. |
| `create-status-check` | false | true | Flag indicating whether a status check with jest test results should be generated. |
| `create-pr-comment` | false | true | Flag indicating whether a PR comment with jest test results should be generated. When `true` the default behavior is to update an existing comment if one exists. |
| `update-comment-if-one-exists` | false | true | When `create-pr-comment` is true, this flag determines whether a new comment is created or if the action updates an existing comment if one is found which is the default behavior. |
| `ignore-test-failures` | false | `false` | When set to true the check status is set to `Neutral` when there are test failures and it will not block pull requests. |
| `timezone` | false | `UTC` | IANA time zone name (e.g. America/Denver) to display dates in. |
| Parameter | Is Required | Default | Description |
|--------------------------------|-------------|--------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `github-token` | true | N/A | Used for the GitHub Checks API. Value is generally: `secrets.GITHUB_TOKEN`. |
| `results-file` | true | N/A | The json results file generated by jest. |
| `report-name` | false | `Jest Test Results` | The desired name of the report that is shown on the PR Comment and inside the Status Check. |
| `create-status-check` | false | `true` | Flag indicating whether a status check with jest test results should be generated. |
| `ignore-test-failures` | false | `false` | If there are test failures, the check's conclusion is set to `neutral` so it will not block pull requests.<br/><br/>*Only applicable when `create-status-check` is true.* |
| `create-pr-comment` | false | `true` | Flag indicating whether a PR comment with jest test results should be generated. When `true` the default behavior is to update an existing comment if one exists. |
| `update-comment-if-one-exists` | false | `true` | This flag determines whether a new comment is created or if the action updates an existing comment (*if one is found*).<br/><br/>*Only applicable when `create-pr-comment` is true.* |
| `comment-identifier` | false | `${{ env.GITHUB-JOB }}_${{ env.GITHUB-ACTION }}` | A unique identifier which will be added to the generated markdown as a comment (*it will not be visible in the PR comment*).<br/><br/>This identifier enables creating then updating separate results comments on the PR if more than one instance of this action is included in a single job. This can be helpful when there are multiple test projects that run separately but are part of the same job.<br/><br/>*Only applicable when `create-pr-comment` is true.* |
| `timezone` | false | `UTC` | IANA time zone name (e.g. America/Denver) to display dates in. |

## Outputs

| Output | Description |
|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `test-outcome` | Test outcome based on presence of failing tests: *Failed,Passed*<br/>If exceptions are thrown or if it exits early because of argument errors, this is set to Failed. |
| Output | Description |
|--------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `test-outcome` | Test outcome based on presence of failing tests: *Failed,Passed*<br/>If exceptions are thrown or if it exits early because of argument errors, this is set to Failed. |
| `test-results-truncated` | Flag indicating whether test results were truncated due to markdown exceeding character limit of 65535. |
| `test-results-file-path` | File path for the file that contains the pre-truncated test results in markdown format. This is the same output that is posted in the PR comment. |
| `status-check-id` | The ID of the Status Check that was created. This is only set if `create-status-check` is `true` and a status check was created successfully. |
| `pr-comment-id` | The ID of the PR comment that was created. This is only set if `create-pr-comment` is `true` and a PR was created successfully. |

## Usage Examples

Expand All @@ -93,7 +105,7 @@ jobs:
pull-requests: write

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: jest test with Coverage
continue-on-error: true
Expand All @@ -103,7 +115,7 @@ jobs:
- name: Process jest results with default
if: always()
# You may also reference just the major or major.minor version
uses: im-open/process-jest-test-results@v2.1.3
uses: im-open/process-jest-test-results@v2.2.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
results-file: 'src/ProjectWithJestTests/jest-results.json
Expand All @@ -116,7 +128,7 @@ jobs:
advanced-ci:
runs-on: [ubuntu-20.04]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: jest test with results file
continue-on-error: true
Expand All @@ -125,7 +137,7 @@ jobs:

- name: Process jest results
id: process-jest
uses: im-open/process-jest-test-results@v2.1.3
uses: im-open/process-jest-test-results@v2.2.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
results-file: 'jest.json'
Expand Down Expand Up @@ -193,7 +205,7 @@ This project has adopted the [im-open's Code of Conduct](https://github.com/im-o

## License

Copyright &copy; 2023, Extend Health, LLC. Code released under the [MIT license](LICENSE).
Copyright &copy; 2024, Extend Health, LLC. Code released under the [MIT license](LICENSE).

<!-- Links -->
[Incrementing the Version]: #incrementing-the-version
Expand Down
Loading

0 comments on commit 25f3784

Please sign in to comment.