Skip to content

Commit 40390ac

Browse files
Merge pull request #2 from ctrf-io/fix/duplicate-report-success
Fix/duplicate report success
2 parents 3b79fe4 + 706ea49 commit 40390ac

File tree

5 files changed

+97
-85
lines changed

5 files changed

+97
-85
lines changed

.github/workflows/main.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ name: Test summary example
33
on:
44
push:
55
branches:
6-
- main
6+
- '**'
7+
pull_request:
8+
branches:
9+
- '**'
710
schedule:
8-
- cron: '0 2 * * *'
11+
- cron: '0 2 * * *'
12+
913
jobs:
1014
testing:
1115
runs-on: ubuntu-latest
16+
if: github.event_name == 'schedule' && github.ref == 'refs/heads/main' || github.event_name != 'schedule'
1217
steps:
1318
- name: Checkout code
1419
uses: actions/checkout@v4
@@ -17,4 +22,5 @@ jobs:
1722
- name: build
1823
run: npx tsc
1924
- name: Run index.js
20-
run: node dist/index.js ctrf-report.json
25+
run: node dist/index.js ctrf-report.json
26+
if: always()

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
uses: actions/checkout@v4
4545
- name: Run CTRF annotations
4646
run: npx github-actions-ctrf path-to-your-ctrf-report.json
47+
if: always()
4748
```
4849
4950
### Generating All Tables
@@ -53,6 +54,7 @@ For a all tables, add the following to your workflow YAML:
5354
``` yaml
5455
- name: Publish CTRF Test Summary Results
5556
run: npx github-actions-ctrf path-to-your-ctrf-report.json
57+
if: always()
5658
```
5759
5860
### Generating Test Summary Table
@@ -62,6 +64,7 @@ For a test summary table, add the `summary` argument to your workflow yaml:
6264
``` yaml
6365
- name: Publish CTRF Test Summary Results
6466
run: npx github-actions-ctrf summary path-to-your-ctrf-report.json
67+
if: always()
6568
```
6669

6770
### Generating Detailed Test Table
@@ -71,6 +74,7 @@ For a test details table, add the `tests` argument to your workflow yaml:
7174
``` yaml
7275
- name: Publish CTRF Detailed Test Summary Results
7376
run: npx github-actions-ctrf tests path-to-your-ctrf-report.json
77+
if: always()
7478
```
7579

7680
### Generating Failed Test Details Table
@@ -80,6 +84,7 @@ For a failed test details table, add the `failed` argument to your workflow yaml
8084
``` yaml
8185
- name: Publish CTRF Failed Test Summary Results
8286
run: npx github-actions-ctrf failed path-to-your-ctrf-report.json
87+
if: always()
8388
```
8489

8590
### Generating Flaky Test Details Table
@@ -89,6 +94,7 @@ For a flaky test details table, add the `flaky` argument to your workflow yaml:
8994
``` yaml
9095
- name: Publish CTRF Flaky Test Summary Results
9196
run: npx github-actions-ctrf flaky path-to-your-ctrf-report.json
97+
if: always()
9298
```
9399

94100
### Generating Fail annotations
@@ -99,6 +105,7 @@ For test annotations, add the `annotate` argument to your workflow yaml:
99105
``` yaml
100106
- name: Annotate failed tests
101107
run: npx github-actions-ctrf annotate path-to-your-ctrf-report.json
108+
if: always()
102109
```
103110

104111
## Components

ctrf-report.json

Lines changed: 75 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,79 @@
11
{
2-
"results": {
3-
"tool": {
4-
"name": "jest"
2+
"results": {
3+
"tool": {
4+
"name": "jest"
5+
},
6+
"summary": {
7+
"tests": 10,
8+
"passed": 5,
9+
"failed": 2,
10+
"pending": 1,
11+
"skipped": 1,
12+
"other": 1,
13+
"start": 1706644023,
14+
"stop": 1706644048
15+
},
16+
"tests": [
17+
{
18+
"name": "should be able to login",
19+
"status": "passed",
20+
"duration": 1200
521
},
6-
"summary": {
7-
"tests": 10,
8-
"passed": 5,
9-
"failed": 2,
10-
"pending": 1,
11-
"skipped": 1,
12-
"other": 1,
13-
"start": 1706644023,
14-
"stop": 1706644048
22+
{
23+
"name": "should display profile information",
24+
"status": "failed",
25+
"duration": 800,
26+
"message": "Assertion Failure: profile mismatch",
27+
"trace": "ProfileTest.js:45"
1528
},
16-
"tests": [
17-
{
18-
"name": "should be able to login",
19-
"status": "passed",
20-
"duration": 1200
21-
},
22-
{
23-
"name": "should display profile information",
24-
"status": "failed",
25-
"duration": 800,
26-
"message": "Assertion Failure: profile mismatch",
27-
"trace": "ProfileTest.js:45"
28-
},
29-
{
30-
"name": "should be able to update profile",
31-
"status": "passed",
32-
"duration": 1200,
33-
"flaky": true,
34-
"retries": 2
35-
},
36-
{
37-
"name": "should be able to logout",
38-
"status": "skipped",
39-
"duration": 0
40-
},
41-
{
42-
"name": "should validate user settings",
43-
"status": "passed",
44-
"duration": 1100
45-
},
46-
{
47-
"name": "should fail to update profile on network failure",
48-
"status": "failed",
49-
"duration": 900,
50-
"message": "Network Timeout",
51-
"trace": "ProfileUpdateTest.js:60"
52-
},
53-
{
54-
"name": "should load user data",
55-
"status": "pending",
56-
"duration": 0
57-
},
58-
{
59-
"name": "should handle session timeouts",
60-
"status": "passed",
61-
"duration": 950,
62-
"flaky": true,
63-
"retries": 1
64-
},
65-
{
66-
"name": "should clean up user session on logout",
67-
"status": "other",
68-
"duration": 1050
69-
},
70-
{
71-
"name": "should allow user to change password",
72-
"status": "passed",
73-
"duration": 1300,
74-
"flaky": true,
75-
"retries": 3
76-
}
77-
]
78-
}
29+
{
30+
"name": "should be able to update profile",
31+
"status": "passed",
32+
"duration": 1200,
33+
"flaky": true,
34+
"retries": 2
35+
},
36+
{
37+
"name": "should be able to logout",
38+
"status": "skipped",
39+
"duration": 0
40+
},
41+
{
42+
"name": "should validate user settings",
43+
"status": "passed",
44+
"duration": 1100
45+
},
46+
{
47+
"name": "should fail to update profile on network failure",
48+
"status": "failed",
49+
"duration": 900,
50+
"message": "Network Timeout",
51+
"trace": "ProfileUpdateTest.js:60"
52+
},
53+
{
54+
"name": "should load user data",
55+
"status": "pending",
56+
"duration": 0
57+
},
58+
{
59+
"name": "should handle session timeouts",
60+
"status": "passed",
61+
"duration": 950,
62+
"flaky": true,
63+
"retries": 1
64+
},
65+
{
66+
"name": "should clean up user session on logout",
67+
"status": "other",
68+
"duration": 1050
69+
},
70+
{
71+
"name": "should allow user to change password",
72+
"status": "passed",
73+
"duration": 1300,
74+
"flaky": true,
75+
"retries": 3
76+
}
77+
]
7978
}
80-
79+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-actions-ctrf",
3-
"version": "0.0.17",
3+
"version": "0.0.19",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

src/summary.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function generateTestDetailsTable(tests: CtrfTest[]): void {
2525
]);
2626

2727
core.summary.addTable([headers, ...rows])
28-
.addLink('A ctrf plugin', 'https://ctrf.io')
28+
.addLink('A ctrf plugin', 'https://github.com/ctrf-io/github-actions-ctrf')
2929

3030

3131
} catch (error) {
@@ -59,7 +59,7 @@ export function generateFlakyTestsDetailsTable(tests: CtrfTest[]): void {
5959
]);
6060

6161
core.summary.addTable([headers, ...rows])
62-
.addLink('A ctrf plugin', 'https://ctrf.io');
62+
.addLink('A ctrf plugin', 'https://github.com/ctrf-io/github-actions-ctrf');
6363
} else {
6464
core.summary.addRaw('No flaky tests detected. ✨');
6565
}
@@ -89,9 +89,9 @@ export function generateFailedTestsDetailsTable(tests: CtrfTest[]) {
8989
{ data: `${test.message}`, header: false }
9090
])
9191
])
92-
.addLink('A ctrf plugin', 'https://ctrf.io')
92+
.addLink('A ctrf plugin', 'https://github.com/ctrf-io/github-actions-ctrf')
9393
} else {
94-
core.summary.addRaw('No failed tests ✨').write();
94+
core.summary.addRaw('No failed tests ✨');
9595
}
9696
} catch (error) {
9797
if (error instanceof Error) {
@@ -127,7 +127,7 @@ export function generateSummaryDetailsTable(report: CtrfReport): void {
127127
durationFormatted,
128128
]
129129
])
130-
.addLink('A ctrf plugin', 'https://ctrf.io')
130+
.addLink('A ctrf plugin', 'https://github.com/ctrf-io/github-actions-ctrf')
131131
} catch (error) {
132132
if (error instanceof Error) {
133133
core.setFailed(`Failed to append to job summary: ${error.message}`);

0 commit comments

Comments
 (0)