Skip to content

Commit b97512f

Browse files
Merge pull request #78 from ctrf-io/feat/commit-report
Feat/commit report #77 #75
2 parents 6240d3b + c5af6fd commit b97512f

File tree

16 files changed

+260
-3
lines changed

16 files changed

+260
-3
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: commit-action-example
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
pull_request:
8+
branches:
9+
- '**'
10+
11+
jobs:
12+
testing:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
- name: Install dependencies
18+
run: npm install
19+
- name: Build
20+
run: npm run all:action
21+
- name: Publish Test Report
22+
uses: ./
23+
with:
24+
report-path: './ctrf/*.json'
25+
commit-report: true
26+
if: always()
27+
- name: Upload test results
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: ctrf-report
31+
path: ctrf-reports/ctrf-report.json
32+
- name: Upload test results
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: custom-artifact-name
36+
path: ctrf-reports/ctrf-report-no-fails.json

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ There are several inputs available
113113
suite-folded-report: false
114114
suite-list-report: false
115115
pull-request-report: false
116+
commit-report: false
116117
custom-report: false
117118
118119
# Behavior Options

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ inputs:
7878
description: 'Include the pull request report.'
7979
required: false
8080
default: false
81+
commit-report:
82+
description: 'Include the commit report.'
83+
required: false
84+
default: false
8185
custom-report:
8286
description: >
8387
Include a custom report using a Handlebars template. To group tests in the

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

dist/index.js

Lines changed: 73 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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.

dist/reports/commit-table.hbs

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/report-showcase.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ execution.
1919
- [Skipped Report](#skipped-report)
2020
- [Suite Folded Report](#suite-folded-report)
2121
- [Suite List Report](#suite-list-report)
22+
- [Commit Report](#commit-report)
2223
- [Pull Request Report](#pull-request-report)
2324

2425
## Summary Report
@@ -671,6 +672,39 @@ Set the `suite-list-report` input to true in your workflow configuration:
671672
- **✅ stripAnsi handles empty strings correctly**
672673
- **✅ stripAnsi throws a TypeError if the input is not a string**
673674

675+
## Commit Report
676+
677+
### Overview
678+
679+
Provides a detailed summary of test results and associated commits for an
680+
execution. It helps teams trace test outcomes back to specific changes in the
681+
codebase
682+
683+
### Usage
684+
685+
Set the `commit-report` input to true in your workflow configuration:
686+
687+
```yaml
688+
- name: Publish Test Report
689+
uses: ctrf-io/github-test-reporter@v1
690+
with:
691+
report-path: './ctrf/*.json'
692+
commit-report: true
693+
if: always()
694+
```
695+
696+
---
697+
698+
<p><strong>14 passed</strong>, <strong>0 failed</strong>, and <strong>0 other</strong></p>
699+
700+
| Timestamp | **Hash** | **Author** | Message |
701+
| ----------------- | --------------------------------------------------------------------------------------------------------------------- | -------------- | ------------- |
702+
| Jan 19, 25, 16:49 | [2eac572](https://github.com/Ma11hewThomas/github-test-reporter-test/commit/2eac57223c6fc070f8657076b2c578363b01f601) | @Ma11hewThomas | third commit |
703+
| Jan 19, 25, 16:48 | [2ed8310](https://github.com/Ma11hewThomas/github-test-reporter-test/commit/2ed831054406356c12ea1520de632a04ca23bb3e) | @Ma11hewThomas | second commit |
704+
| Jan 19, 25, 16:48 | [23c693e](https://github.com/Ma11hewThomas/github-test-reporter-test/commit/23c693ebfbf42c5526f8d0b8744414c2aa4a8cc6) | @Ma11hewThomas | first commit |
705+
706+
[Compare before f9aecf1 and after 2eac572](https://github.com/Ma11hewThomas/github-test-reporter-test/compare/f9aecf1b04ed...2eac57223c6f)
707+
674708
## Pull Request Report
675709

676710
### Overview

src/core/inputs.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export function getCliInputs(args: Arguments): Inputs {
2525
suiteFoldedReport: args._.includes('suite-folded'),
2626
suiteListReport: args._.includes('suite-list'),
2727
pullRequestReport: args._.includes('pull-request'),
28+
commitReport: args._.includes('commit'),
2829
customReport: args._.includes('custom'),
2930
communityReport: args._.includes('community'),
3031
communityReportName: args.communityReportName || '',
@@ -76,6 +77,8 @@ export function getInputs(): Inputs {
7677
core.getInput('suite-list-report').toLowerCase() === 'true',
7778
pullRequestReport:
7879
core.getInput('pull-request-report').toLowerCase() === 'true',
80+
commitReport: core.getInput('commit-report').toLowerCase() === 'true',
81+
7982
customReport: core.getInput('custom-report').toLowerCase() === 'true',
8083
communityReport: core.getInput('community-report').toLowerCase() === 'true',
8184
communityReportName: core.getInput('community-report-name'),

src/github/core.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export function generateViews(inputs: Inputs, report: CtrfReport): void {
3333
inputs.suiteFoldedReport ||
3434
inputs.suiteListReport ||
3535
inputs.pullRequestReport ||
36+
inputs.commitReport ||
3637
inputs.customReport ||
3738
inputs.communityReport
3839

@@ -89,6 +90,10 @@ export function generateViews(inputs: Inputs, report: CtrfReport): void {
8990
addViewToSummary('', BuiltInReports.PullRequest, report)
9091
}
9192

93+
if (inputs.commitReport) {
94+
addViewToSummary('### Commits', BuiltInReports.CommitTable, report)
95+
}
96+
9297
if (inputs.customReport && inputs.templatePath) {
9398
const customTemplate = readTemplate(inputs.templatePath)
9499
const customMarkdown = generateMarkdown(customTemplate, report)

0 commit comments

Comments
 (0)