Skip to content

Commit 96df85e

Browse files
authored
Merge branch 'main' into fix-duration
2 parents cdd40cb + 3f53062 commit 96df85e

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
test:
1313
strategy:
1414
matrix:
15-
go-version: [ 1.19.x, 1.20.x, 1.21.x ]
15+
go-version: [ 1.19.x, 1.20.x, 1.21.x, 1.22.x, 1.23.x ]
1616
lint-and-coverage: [ false ]
1717
include:
1818
- go-version: 1.22.x

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ The test object in the report includes the following [CTRF properties](https://c
126126

127127
| Name | Type | Required | Details |
128128
| ---------- | ------ | -------- | ----------------------------------------------------------------------------------- |
129+
| `suite` | String | Required | The name of go package containing the test. |
129130
| `name` | String | Required | The name of the test. |
130131
| `status` | String | Required | The outcome of the test. One of: `passed`, `failed`, `skipped`, `pending`, `other`. |
131132
| `duration` | Number | Required | The time taken for the test execution, in milliseconds. |

reporter/reporter.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ func ParseTestResults(r io.Reader, verbose bool, env *ctrf.Environment) (*ctrf.R
5959
report.Results.Summary.Stop = endTime
6060
}
6161
}
62-
6362
if event.Action == "pass" {
6463
report.Results.Summary.Tests++
6564
report.Results.Summary.Passed++
6665
report.Results.Tests = append(report.Results.Tests, &ctrf.TestResult{
66+
Suite: event.Package,
6767
Name: event.Test,
6868
Status: ctrf.TestPassed,
6969
Duration: duration,
@@ -72,6 +72,7 @@ func ParseTestResults(r io.Reader, verbose bool, env *ctrf.Environment) (*ctrf.R
7272
report.Results.Summary.Tests++
7373
report.Results.Summary.Failed++
7474
report.Results.Tests = append(report.Results.Tests, &ctrf.TestResult{
75+
Suite: event.Package,
7576
Name: event.Test,
7677
Status: ctrf.TestFailed,
7778
Duration: duration,
@@ -80,11 +81,13 @@ func ParseTestResults(r io.Reader, verbose bool, env *ctrf.Environment) (*ctrf.R
8081
report.Results.Summary.Tests++
8182
report.Results.Summary.Skipped++
8283
report.Results.Tests = append(report.Results.Tests, &ctrf.TestResult{
84+
Suite: event.Package,
8385
Name: event.Test,
8486
Status: ctrf.TestSkipped,
8587
Duration: duration,
8688
})
8789
}
90+
8891
}
8992
return report, nil
9093
}
@@ -94,25 +97,19 @@ func WriteReportToFile(filename string, report *ctrf.Report) error {
9497
if err != nil {
9598
return err
9699
}
97-
98100
fmt.Println("go-ctrf-json-reporter: successfully written ctrf json to", filename)
99101
return nil
100102
}
101103

102104
func secondsToMillis(seconds float64) int64 {
103105
return int64(seconds * 1000)
104106
}
105-
func parseTimeString(timeString string) (int64, error) {
106-
// Define the layout for parsing the time string
107-
layout := time.RFC3339Nano
108107

109-
// Parse the time string
108+
func parseTimeString(timeString string) (int64, error) {
109+
layout := time.RFC3339Nano
110110
t, err := time.Parse(layout, timeString)
111111
if err != nil {
112112
return 0, err
113113
}
114-
115-
// Convert the time to Unix timestamp in milliseconds
116-
timestamp := t.UnixNano() / int64(time.Millisecond)
117-
return timestamp, nil
114+
return t.UnixNano() / int64(time.Millisecond), nil
118115
}

0 commit comments

Comments
 (0)