-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from le-yams/feat/ctrf_for_custom_reporter
feat: enable ctrf for custom reporter (for any tool)
- Loading branch information
Showing
11 changed files
with
707 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
workflow_dispatch: | ||
|
||
|
||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
go-version: [ 1.19.x, 1.20.x, 1.21.x ] | ||
lint-and-coverage: [ false ] | ||
include: | ||
- go-version: 1.22.x | ||
lint-and-coverage: true | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go ${{ matrix.go-version }} | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- name: Install dependencies | ||
run: go get ./... | ||
|
||
- name: Build | ||
run: go build -v ./... | ||
|
||
- name: Test with the Go CLI | ||
run: | | ||
go version | ||
if [ ${{ matrix.lint-and-coverage }} = true ]; then | ||
GO_TEST_OPTS="-covermode=atomic -coverprofile=coverage.out" | ||
fi | ||
export GORACE="halt_on_error=1" | ||
go test -race $GO_TEST_OPTS ./... | ||
- name: Reporting coverage | ||
if: matrix.lint-and-coverage | ||
uses: shogo82148/actions-goveralls@v1 | ||
with: | ||
path-to-profile: coverage.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
.idea | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,71 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"github.com/ctrf-io/go-ctrf-json-reporter/reporter" | ||
"os" | ||
"flag" | ||
"fmt" | ||
"github.com/ctrf-io/go-ctrf-json-reporter/ctrf" | ||
"github.com/ctrf-io/go-ctrf-json-reporter/reporter" | ||
"os" | ||
) | ||
|
||
func main() { | ||
var outputFile string | ||
var verbose bool | ||
flag.BoolVar(&verbose, "verbose", false, "Enable verbose output") | ||
flag.BoolVar(&verbose, "v", false, "Enable verbose output (shorthand)") | ||
flag.StringVar(&outputFile, "output", "ctrf-report.json", "The output file for the test results") | ||
flag.StringVar(&outputFile, "o", "ctrf-report.json", "The output file for the test results (shorthand)") | ||
var outputFile string | ||
var verbose bool | ||
flag.BoolVar(&verbose, "verbose", false, "Enable verbose output") | ||
flag.BoolVar(&verbose, "v", false, "Enable verbose output (shorthand)") | ||
flag.StringVar(&outputFile, "output", "ctrf-report.json", "The output file for the test results") | ||
flag.StringVar(&outputFile, "o", "ctrf-report.json", "The output file for the test results (shorthand)") | ||
|
||
var tempAppName, tempAppVersion, tempOSPlatform, tempOSRelease, tempOSVersion, tempBuildName, tempBuildNumber string | ||
var tempAppName, tempAppVersion, tempOSPlatform, tempOSRelease, tempOSVersion, tempBuildName, tempBuildNumber string | ||
|
||
flag.StringVar(&tempAppName, "appName", "", "The name of the application being tested.") | ||
flag.StringVar(&tempAppVersion, "appVersion", "", "The version of the application being tested.") | ||
flag.StringVar(&tempOSPlatform, "osPlatform", "", "The operating system platform (e.g., Windows, Linux).") | ||
flag.StringVar(&tempOSRelease, "osRelease", "", "The release version of the operating system.") | ||
flag.StringVar(&tempOSVersion, "osVersion", "", "The version number of the operating system.") | ||
flag.StringVar(&tempBuildName, "buildName", "", "The name of the build (e.g., feature branch name).") | ||
flag.StringVar(&tempBuildNumber, "buildNumber", "", "The build number or identifier.") | ||
flag.StringVar(&tempAppName, "appName", "", "The name of the application being tested.") | ||
flag.StringVar(&tempAppVersion, "appVersion", "", "The version of the application being tested.") | ||
flag.StringVar(&tempOSPlatform, "osPlatform", "", "The operating system platform (e.g., Windows, Linux).") | ||
flag.StringVar(&tempOSRelease, "osRelease", "", "The release version of the operating system.") | ||
flag.StringVar(&tempOSVersion, "osVersion", "", "The version number of the operating system.") | ||
flag.StringVar(&tempBuildName, "buildName", "", "The name of the build (e.g., feature branch name).") | ||
flag.StringVar(&tempBuildNumber, "buildNumber", "", "The build number or identifier.") | ||
|
||
flag.Parse() | ||
flag.Parse() | ||
|
||
var env *reporter.Environment | ||
var env *ctrf.Environment | ||
|
||
if tempAppName != "" || tempAppVersion != "" || tempOSPlatform != "" || | ||
tempOSRelease != "" || tempOSVersion != "" || tempBuildName != "" || tempBuildNumber != "" { | ||
env = &reporter.Environment{} | ||
if tempAppName != "" || tempAppVersion != "" || tempOSPlatform != "" || | ||
tempOSRelease != "" || tempOSVersion != "" || tempBuildName != "" || tempBuildNumber != "" { | ||
env = &ctrf.Environment{} | ||
|
||
if tempAppName != "" { | ||
env.AppName = &tempAppName | ||
} | ||
if tempAppVersion != "" { | ||
env.AppVersion = &tempAppVersion | ||
} | ||
if tempOSPlatform != "" { | ||
env.OSPlatform = &tempOSPlatform | ||
} | ||
if tempOSRelease != "" { | ||
env.OSRelease = &tempOSRelease | ||
} | ||
if tempOSVersion != "" { | ||
env.OSVersion = &tempOSVersion | ||
} | ||
if tempBuildName != "" { | ||
env.BuildName = &tempBuildName | ||
} | ||
if tempBuildNumber != "" { | ||
env.BuildNumber = &tempBuildNumber | ||
} | ||
} | ||
if tempAppName != "" { | ||
env.AppName = tempAppName | ||
} | ||
if tempAppVersion != "" { | ||
env.AppVersion = tempAppVersion | ||
} | ||
if tempOSPlatform != "" { | ||
env.OSPlatform = tempOSPlatform | ||
} | ||
if tempOSRelease != "" { | ||
env.OSRelease = tempOSRelease | ||
} | ||
if tempOSVersion != "" { | ||
env.OSVersion = tempOSVersion | ||
} | ||
if tempBuildName != "" { | ||
env.BuildName = tempBuildName | ||
} | ||
if tempBuildNumber != "" { | ||
env.BuildNumber = tempBuildNumber | ||
} | ||
} | ||
|
||
report, err := reporter.ParseTestResults(os.Stdin, verbose, env) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "Error parsing test results: %v\n", err) | ||
os.Exit(1) | ||
} | ||
report, err := reporter.ParseTestResults(os.Stdin, verbose, env) | ||
if err != nil { | ||
_, _ = fmt.Fprintf(os.Stderr, "Error parsing test results: %v\n", err) | ||
os.Exit(1) | ||
} | ||
|
||
err = reporter.WriteReportToFile(outputFile, report) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "Error writing the report to file: %v\n", err) | ||
os.Exit(1) | ||
} | ||
err = reporter.WriteReportToFile(outputFile, report) | ||
if err != nil { | ||
_, _ = fmt.Fprintf(os.Stderr, "Error writing the report to file: %v\n", err) | ||
os.Exit(1) | ||
} | ||
} |
Oops, something went wrong.