From 666b9c0841e904c44097ec24306f52d36a07c076 Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Mon, 6 Dec 2021 12:38:55 +0300 Subject: [PATCH 01/30] Repackage according new repository name --- .golangci.yml | 2 +- .travis.yml | 2 +- Dockerfile | 2 +- Makefile | 2 +- README.md | 4 ++-- cli/commands.go | 2 +- cli/launch.go | 2 +- cli/report.go | 3 +-- go.mod | 2 +- main.go | 2 +- 10 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index a7518af..f2f61fe 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -18,7 +18,7 @@ linters-settings: lll: line-length: 140 goimports: - local-prefixes: github.com/avarabyeu/goRP/v5 + local-prefixes: github.com/reportportal/goRP/v5 gocritic: enabled-tags: - performance diff --git a/.travis.yml b/.travis.yml index d82a79f..38b83ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,4 +13,4 @@ script: - make checkstyle build after_success: - - curl --request POST "https://goreportcard.com/checks" --data "repo=github.com/avarabyeu/goRP" + - curl --request POST "https://goreportcard.com/checks" --data "repo=github.com/reportportal/goRP" diff --git a/Dockerfile b/Dockerfile index 19336fa..c55250a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ ARG dockerTag RUN echo $dockerTag | awk -F"v" '{ print $2 }' > version RUN cat ./version -RUN version=$(cat version) && curl -L >gorp.tar.gz https://github.com/avarabyeu/goRP/releases/download/$dockerTag/goRP_${version}_linux_amd64.tar.gz \ +RUN version=$(cat version) && curl -L >gorp.tar.gz https://github.com/reportportal/goRP/releases/download/$dockerTag/goRP_${version}_linux_amd64.tar.gz \ && tar -xzvf gorp.tar.gz -C /usr/bin \ && rm gorp.tar.gz diff --git a/Makefile b/Makefile index 2e4ec25..0223d45 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ lint: fmt: gofumpt -extra -l -w -s ${GOFILES_NOVENDOR} gofumports -local -l -w ${GOFILES_NOVENDOR} - gci -local github.com/avarabyeu/goRP/v5 -w ${GOFILES_NOVENDOR} + gci -local github.com/reportportal/goRP/v5 -w ${GOFILES_NOVENDOR} #build: checkstyle test build: diff --git a/README.md b/README.md index 41f7432..0818cc9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -![GitHub Workflow Status](https://img.shields.io/github/workflow/status/avarabyeu/goRP/Build) +![GitHub Workflow Status](https://img.shields.io/github/workflow/status/reportportal/goRP/Build) [![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/eBay/fabio/master/LICENSE) -[![Go Report Card](https://goreportcard.com/badge/github.com/avarabyeu/goRP)](https://goreportcard.com/report/github.com/avarabyeu/goRP) +[![Go Report Card](https://goreportcard.com/badge/github.com/reportportal/goRP)](https://goreportcard.com/report/github.com/reportportal/goRP) # goRP Golang Client and CLI Utility for [ReportPortal](https://reportportal.io) diff --git a/cli/commands.go b/cli/commands.go index cbe1995..c506445 100644 --- a/cli/commands.go +++ b/cli/commands.go @@ -10,7 +10,7 @@ import ( "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" - "github.com/avarabyeu/goRP/v5/gorp" + "github.com/reportportal/goRP/v5/gorp" ) type config struct { diff --git a/cli/launch.go b/cli/launch.go index 1bf86da..08f69f4 100644 --- a/cli/launch.go +++ b/cli/launch.go @@ -7,7 +7,7 @@ import ( "github.com/urfave/cli/v2" - "github.com/avarabyeu/goRP/v5/gorp" + "github.com/reportportal/goRP/v5/gorp" ) var ( diff --git a/cli/report.go b/cli/report.go index 4044d9a..8f3fb70 100644 --- a/cli/report.go +++ b/cli/report.go @@ -11,10 +11,9 @@ import ( "sync" "time" + "github.com/reportportal/goRP/gorp" "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" - - "github.com/avarabyeu/goRP/gorp" ) const logsBatchSize = 10 diff --git a/go.mod b/go.mod index dec4bf3..843d82d 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/avarabyeu/goRP/v5 +module github.com/reportportal/goRP/v5 go 1.13 diff --git a/main.go b/main.go index c065215..883134d 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,7 @@ import ( "github.com/urfave/cli/v2" - rp "github.com/avarabyeu/goRP/v5/cli" + rp "github.com/reportportal/goRP/v5/cli" ) var ( From 1849eb23c3b71e8c4b3423806c2a1a13104f9012 Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Mon, 6 Dec 2021 12:40:33 +0300 Subject: [PATCH 02/30] Repackage according new repository name --- cli/report.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cli/report.go b/cli/report.go index 8f3fb70..7ec23dc 100644 --- a/cli/report.go +++ b/cli/report.go @@ -11,9 +11,10 @@ import ( "sync" "time" - "github.com/reportportal/goRP/gorp" "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" + + "github.com/reportportal/goRP/v5/gorp" ) const logsBatchSize = 10 From b874b4c538f9e6599816cace7cc6d7d126008458 Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Mon, 6 Dec 2021 12:45:34 +0300 Subject: [PATCH 03/30] update README --- README.md | 49 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0818cc9..e3c1676 100644 --- a/README.md +++ b/README.md @@ -3,41 +3,72 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/reportportal/goRP)](https://goreportcard.com/report/github.com/reportportal/goRP) # goRP + Golang Client and CLI Utility for [ReportPortal](https://reportportal.io) ## Installation ## Usage + ``` gorp [global options] command [command options] [arguments...] COMMANDS: - launch Operations over launches - help, h Shows a list of commands or help for one command + launch Operations over launches + report Reports input to report portal + init Initializes configuration cache + help, h Shows a list of commands or help for one command GLOBAL OPTIONS: - -u value, --uuid value Access Token [$GORP_UUID] - -p value, --project value ReportPortal Project Name [$GORP_PROJECT] + --uuid value, -u value Access Token [$GORP_UUID] + --project value, -p value ReportPortal Project Name [$GORP_PROJECT] --host value ReportPortal Server Name - --help, -h show help - --version, -v print the version + --help, -h show help (default: false) + --version, -v print the version (default: false) ``` +### Init command + + NAME: + gorp init - Initializes configuration cache + USAGE: + gorp init [command options] [arguments...] + OPTIONS: + --help, -h show help (default: false) + ### Launch command + ``` USAGE: goRP launch command [command options] [arguments...] COMMANDS: - list List launches + list List launches + merge Merge Launches + help, h Shows a list of commands or help for one command ``` #### List Launches + ``` USAGE: goRP launch list [command options] [arguments...] OPTIONS: - --fn value, --filter-name value Filter Name [$FILTER_NAME] - -f value, --filter value Filter [$Filter] + --filter-name value, --fn value Filter Name [$FILTER_NAME] + --filter value, -f value Filter [$Filter] + --help, -h show help (default: false) ``` + +### Report command + + NAME: + goRP report - Reports input to report portal + USAGE: + goRP report command [command options] [arguments...] + COMMANDS: + test2json Input format: test2json + help, h Shows a list of commands or help for one command + OPTIONS: + --help, -h show help (default: false) + From 4f32dc2dd37829705ae2e56e352478d3026125d8 Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Mon, 6 Dec 2021 12:49:05 +0300 Subject: [PATCH 04/30] update README --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index 0223d45..6aee59e 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,5 @@ .DEFAULT_GOAL := build - BUILD_DATE = `date +%FT%T%z` - GO = go BINARY_DIR=bin From 5219740593ca9277f8a165d0020b42de5299e572 Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Tue, 31 May 2022 12:57:44 +0200 Subject: [PATCH 05/30] Add more examples for reporting usage --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index e3c1676..3e77dd0 100644 --- a/README.md +++ b/README.md @@ -72,3 +72,17 @@ OPTIONS: OPTIONS: --help, -h show help (default: false) + +## Using as Golang Test Results Agent +Run tests with JSON output +``` +go test -json ./... > results.txt +``` +Report The results +``` +gorp report test2json -f results.txt +``` +Report directly from go test output +``` +go test -json ./... | bin/gorp report test2json +``` \ No newline at end of file From 1cbd5f6265d9668a2b514fd36303a5b671a3db1e Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Tue, 31 May 2022 12:58:17 +0200 Subject: [PATCH 06/30] Add more examples for reporting usage --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3e77dd0..845a532 100644 --- a/README.md +++ b/README.md @@ -84,5 +84,5 @@ gorp report test2json -f results.txt ``` Report directly from go test output ``` -go test -json ./... | bin/gorp report test2json +go test -json ./... | gorp report test2json ``` \ No newline at end of file From 3effb02a853419591819197143fdacc90cedd0b6 Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Fri, 10 Jun 2022 17:42:56 +0200 Subject: [PATCH 07/30] fixes minor lint issues --- .github/workflows/build.yml | 4 ++-- .golangci.yml | 12 ++++++------ cli/commands.go | 1 + cli/launch.go | 5 ++++- cli/util_test.go | 4 ++++ gorp/client_test.go | 2 ++ gorp/model_api_test.go | 5 +++++ util/util.go | 2 +- 8 files changed, 25 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7b37e9b..4579838 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v2 with: - go-version: '1.15.0' # The Go version to download (if necessary) and use. + go-version: '1.18.3' # The Go version to download (if necessary) and use. # - name: Install dependencies # run: | # go version @@ -29,7 +29,7 @@ jobs: uses: golangci/golangci-lint-action@v2 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.31 + version: v1.45.2 # Optional: show only new issues if it's a pull request. The default value is `false`. only-new-issues: true # Run build of the application diff --git a/.golangci.yml b/.golangci.yml index f2f61fe..f857d1d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -41,6 +41,12 @@ linters: - testpackage - nlreturn - stylecheck + - exhaustivestruct + - varnamelen + - tagliatelle + - wrapcheck + - gomnd + - gci #run: # skip-dirs: @@ -53,9 +59,3 @@ issues: linters: - gosec -# golangci.com configuration -# https://github.com/golangci/golangci/wiki/Configuration -service: - golangci-lint-version: 1.15.x # use the fixed version to not introduce new linters unexpectedly -# prepare: -# - echo "here I can run custom commands, but no preparation needed for this repo" diff --git a/cli/commands.go b/cli/commands.go index c506445..3e9a25f 100644 --- a/cli/commands.go +++ b/cli/commands.go @@ -96,6 +96,7 @@ func initConfiguration(c *cli.Context) error { return cli.Exit(fmt.Sprintf("Cannot read config file. %s", err), 1) } + //nolint:forbidigo //expected output fmt.Println("Configuration has been successfully saved!") return nil diff --git a/cli/launch.go b/cli/launch.go index 08f69f4..0276c44 100644 --- a/cli/launch.go +++ b/cli/launch.go @@ -97,6 +97,8 @@ func mergeLaunches(c *cli.Context) error { if err != nil { return fmt.Errorf("unable to merge launches: %w", err) } + + //nolint:forbidigo //expected output fmt.Println(launchResource.ID) return nil @@ -122,6 +124,7 @@ func listLaunches(c *cli.Context) error { return err } + //nolint:forbidigo //expected output for _, launch := range launches.Content { fmt.Printf("%d #%d \"%s\"\n", launch.ID, launch.Number, launch.Name) } @@ -148,7 +151,7 @@ func getMergeIDs(c *cli.Context, rpClient *gorp.Client) ([]int, error) { return nil, errors.New("no either IDs or filter provided") } if err != nil { - return nil, fmt.Errorf("unable to find launches by filter: %s", err.Error()) + return nil, fmt.Errorf("unable to find launches by filter: %w", err) } ids := make([]int, len(launches.Content)) diff --git a/cli/util_test.go b/cli/util_test.go index 0d75286..5dbeede 100644 --- a/cli/util_test.go +++ b/cli/util_test.go @@ -7,17 +7,21 @@ import ( ) func TestUnderstandsYes(t *testing.T) { + t.Parallel() assert.Equal(t, true, answerYes("yes")) } func TestUnderstandsYesUpper(t *testing.T) { + t.Parallel() assert.Equal(t, true, answerYes("YES")) } func TestEmptyAnswer(t *testing.T) { + t.Parallel() assert.Equal(t, false, answerYes("")) } func TestUnderstandsNo(t *testing.T) { + t.Parallel() assert.Equal(t, false, answerYes("no")) } diff --git a/gorp/client_test.go b/gorp/client_test.go index 1bd6a17..ba6c31b 100644 --- a/gorp/client_test.go +++ b/gorp/client_test.go @@ -9,6 +9,7 @@ import ( ) func TestCreateRPClient(t *testing.T) { + t.Parallel() client := NewClient("http://host.com", "prj", "uuid") assert.Equal(t, "prj", client.project) @@ -17,6 +18,7 @@ func TestCreateRPClient(t *testing.T) { } func TestHandleErrors(t *testing.T) { + t.Parallel() server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusBadRequest) })) diff --git a/gorp/model_api_test.go b/gorp/model_api_test.go index 51f8520..d569b6b 100644 --- a/gorp/model_api_test.go +++ b/gorp/model_api_test.go @@ -9,6 +9,7 @@ import ( ) func TestUnixTimeDeserialization(t *testing.T) { + t.Parallel() const jsonStr = `"1512114178671"` const expTime = "2017-12-01T07:42:59+00:00" @@ -25,6 +26,7 @@ func TestUnixTimeDeserialization(t *testing.T) { } func TestUnixTimeSerialization(t *testing.T) { + t.Parallel() const jsonStr = `1512114179000` const expTime = "2017-12-01T07:42:59+00:00" @@ -35,6 +37,7 @@ func TestUnixTimeSerialization(t *testing.T) { } func TestErrOnIncorrectTime(t *testing.T) { + t.Parallel() const jsonStr = `"hello-world"` var unitTime Timestamp @@ -43,11 +46,13 @@ func TestErrOnIncorrectTime(t *testing.T) { } func TestDirectionConverter(t *testing.T) { + t.Parallel() assert.Equal(t, "ASC", directionToStr(true)) assert.Equal(t, "DESC", directionToStr(false)) } func TestFiltersConverter(t *testing.T) { + t.Parallel() fp := ConvertToFilterParams(&FilterResource{ Entities: []*FilterEntity{ { diff --git a/util/util.go b/util/util.go index 3ab4ad1..3f63ac8 100644 --- a/util/util.go +++ b/util/util.go @@ -22,5 +22,5 @@ func Retry(attempts int, timeout time.Duration, callback func() (interface{}, er log.Infof("Retrying... Attempt: %d. Left: %d", i+1, attempts-1-i) } - return nil, fmt.Errorf("after %d attempts, last error: %s", attempts, err) + return nil, fmt.Errorf("after %d attempts, last error: %w", attempts, err) } From e03d9c91005ac71d0fdb0047f77169961785848c Mon Sep 17 00:00:00 2001 From: Gulom Alimov Date: Wed, 5 Apr 2023 21:41:04 +0500 Subject: [PATCH 08/30] saving logs with attachments --- gorp/model_reporting.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/gorp/model_reporting.go b/gorp/model_reporting.go index 71c1453..2ce3ee5 100644 --- a/gorp/model_reporting.go +++ b/gorp/model_reporting.go @@ -26,13 +26,14 @@ type ( RetryOf string `json:"retryOf,omitempty"` } - // SaveLogRQ payload representation. Without attaches. + // SaveLogRQ payload representation. SaveLogRQ struct { - LaunchUUID string `json:"launchUuid,omitempty"` - ItemID string `json:"itemUuid,omitempty"` - LogTime Timestamp `json:"time,omitempty"` - Message string `json:"message,omitempty"` - Level string `json:"level,omitempty"` + File FileAttachment `json:"file,omitempty"` + LaunchUUID string `json:"launchUuid,omitempty"` + ItemID string `json:"itemUuid,omitempty"` + LogTime Timestamp `json:"time,omitempty"` + Message string `json:"message,omitempty"` + Level string `json:"level,omitempty"` } // StartTestRQ payload representation @@ -102,6 +103,11 @@ type ( Timestamp struct { time.Time } + + // FileAttachment represents file attachment in log entries + FileAttachment struct { + Name string `json:"name,omitempty"` + } ) // UnmarshalJSON converts Epoch milliseconds (timestamp) to appropriate object From 002f5e1403bbf0efa5010218c2ff44509ab17965 Mon Sep 17 00:00:00 2001 From: Gulom Alimov Date: Thu, 6 Apr 2023 15:55:57 +0500 Subject: [PATCH 09/30] fix SaveLogMultipart method and add example usage in comment. --- gorp/client.go | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/gorp/client.go b/gorp/client.go index db94afa..850d8d8 100644 --- a/gorp/client.go +++ b/gorp/client.go @@ -4,7 +4,9 @@ import ( "bytes" "encoding/json" "fmt" + "mime" "os" + "path/filepath" "time" "github.com/go-resty/resty/v2" @@ -194,7 +196,29 @@ func (c *Client) SaveLogs(logs ...*SaveLogRQ) (*EntryCreatedRS, error) { return c.SaveLogMultipart(logs, nil) } -// SaveLogMultipart attaches log in RP +// SaveLogMultipart saves a batch of logs in RP, along with any associated files (if any). +// +// Example usage: +// +// f, _ := os.Open("someFile.txt") +// +// logs := []*SaveLogRQ{{ +// File: FileAttachment{ +// // note that this value must present in 'files' map as key (see below) +// Name: "fileAttachment.txt", +// }, +// LaunchUUID: launchID, +// ItemID: itemID, +// Level: gorp.LogLevelError, +// LogTime: NewTimestamp(time.Now()), +// Message: "Important message!", +// }} +// +// files := map[string]*os.File{ +// "fileAttachment.txt": f, // key must match the FileAttachment.Name field +// } +// +// resp, err := client.SaveLogMultipart(log, files) func (c *Client) SaveLogMultipart(log []*SaveLogRQ, files map[string]*os.File) (*EntryCreatedRS, error) { var bodyBuf bytes.Buffer err := json.NewEncoder(&bodyBuf).Encode(log) @@ -218,7 +242,7 @@ func (c *Client) SaveLogMultipart(log []*SaveLogRQ, files map[string]*os.File) ( if _, sErr := os.Stat(v.Name()); os.IsNotExist(sErr) { return nil, fmt.Errorf("file %s does not exist", v.Name()) } - rq.SetMultipartField(k, k, "", v) + rq.SetMultipartField("file", k, mime.TypeByExtension(filepath.Ext(k)), v) } var rs EntryCreatedRS From 244b45117e0a96ec2cbf8615b9249c9861e53f83 Mon Sep 17 00:00:00 2001 From: Gulom Alimov Date: Thu, 6 Apr 2023 15:57:21 +0500 Subject: [PATCH 10/30] a bit formatting --- gorp/client.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/gorp/client.go b/gorp/client.go index 850d8d8..5ae533c 100644 --- a/gorp/client.go +++ b/gorp/client.go @@ -203,20 +203,20 @@ func (c *Client) SaveLogs(logs ...*SaveLogRQ) (*EntryCreatedRS, error) { // f, _ := os.Open("someFile.txt") // // logs := []*SaveLogRQ{{ -// File: FileAttachment{ -// // note that this value must present in 'files' map as key (see below) -// Name: "fileAttachment.txt", -// }, -// LaunchUUID: launchID, -// ItemID: itemID, -// Level: gorp.LogLevelError, -// LogTime: NewTimestamp(time.Now()), -// Message: "Important message!", -// }} +// File: FileAttachment{ +// // note that this value must present in 'files' map as key (see below) +// Name: "fileAttachment.txt", +// }, +// LaunchUUID: launchID, +// ItemID: itemID, +// Level: gorp.LogLevelError, +// LogTime: NewTimestamp(time.Now()), +// Message: "Important message!", +// }} // // files := map[string]*os.File{ -// "fileAttachment.txt": f, // key must match the FileAttachment.Name field -// } +// "fileAttachment.txt": f, // key must match the FileAttachment.Name field +// } // // resp, err := client.SaveLogMultipart(log, files) func (c *Client) SaveLogMultipart(log []*SaveLogRQ, files map[string]*os.File) (*EntryCreatedRS, error) { From 3385ad137faaf9cd9952455164851dbce5955e48 Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Thu, 6 Apr 2023 13:54:23 +0200 Subject: [PATCH 11/30] update deps, change logger --- Makefile | 3 +-- cli/commands.go | 4 ++-- cli/report.go | 14 +++++++------- go.mod | 22 ++++++++++++++++++---- go.sum | 45 +++++++++++++++++++++++++++------------------ main.go | 6 ++++-- util/util.go | 6 +++--- 7 files changed, 62 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index 6aee59e..60853b5 100644 --- a/Makefile +++ b/Makefile @@ -32,8 +32,7 @@ lint: fmt: gofumpt -extra -l -w -s ${GOFILES_NOVENDOR} - gofumports -local -l -w ${GOFILES_NOVENDOR} - gci -local github.com/reportportal/goRP/v5 -w ${GOFILES_NOVENDOR} + gci write --section Standard --section Default --section "Prefix(github.com/reportportal/goRP/v5)" ${GOFILES_NOVENDOR} #build: checkstyle test build: diff --git a/cli/commands.go b/cli/commands.go index 3e9a25f..1aa0005 100644 --- a/cli/commands.go +++ b/cli/commands.go @@ -7,8 +7,8 @@ import ( "os" "github.com/manifoldco/promptui" - "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" + "go.uber.org/zap" "github.com/reportportal/goRP/v5/gorp" ) @@ -54,7 +54,7 @@ func initConfiguration(c *cli.Context) error { } defer func() { if closeErr := f.Close(); closeErr != nil { - logrus.Error(closeErr) + zap.S().Error(closeErr) } }() diff --git a/cli/report.go b/cli/report.go index 7ec23dc..7380f84 100644 --- a/cli/report.go +++ b/cli/report.go @@ -11,8 +11,8 @@ import ( "sync" "time" - "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" + "go.uber.org/zap" "github.com/reportportal/goRP/v5/gorp" ) @@ -77,7 +77,7 @@ func reportTest2json(c *cli.Context) error { } defer func() { if cErr := f.Close(); cErr != nil { - logrus.Error(cErr) + zap.S().Error(cErr) } }() reader = f @@ -91,7 +91,7 @@ func reportTest2json(c *cli.Context) error { var ev testEvent if err := json.Unmarshal([]byte(data), &ev); err != nil { - logrus.Error(err) + zap.S().Error(err) return err } input <- &ev @@ -139,7 +139,7 @@ func (r *reporter) receive() { var err error r.launchOnce.Do(func() { if err = r.startLaunch(); err != nil { - logrus.Error(err) + zap.S().Error(err) } }) @@ -154,7 +154,7 @@ func (r *reporter) receive() { err = r.finish(ev, gorp.Statuses.Failed) } if err != nil { - logrus.Fatal(err) + zap.S().Fatal(err) } } // make sure we flush all logs that are left @@ -164,7 +164,7 @@ func (r *reporter) receive() { if r.launchID != "" { if err := r.finishLaunch(gorp.Statuses.Passed); err != nil { - logrus.Fatal(err) + zap.S().Fatal(err) } } } @@ -251,7 +251,7 @@ func (r *reporter) flushLogs(force bool) { defer r.waitQueue.Done() if _, err := r.client.SaveLogs(logs...); err != nil { - logrus.Errorf("unable to report logs: %v. Batch len: %d", err, len(logs)) + zap.S().Errorf("unable to report logs: %v. Batch len: %d", err, len(logs)) } }(batch) r.logs = []*gorp.SaveLogRQ{} diff --git a/go.mod b/go.mod index 843d82d..21f6f99 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,26 @@ module github.com/reportportal/goRP/v5 -go 1.13 +go 1.18 require ( github.com/go-resty/resty/v2 v2.7.0 github.com/google/uuid v1.3.0 github.com/manifoldco/promptui v0.9.0 - github.com/sirupsen/logrus v1.8.1 - github.com/stretchr/testify v1.7.0 - github.com/urfave/cli/v2 v2.3.0 + github.com/stretchr/testify v1.8.1 + github.com/urfave/cli/v2 v2.24.4 + go.uber.org/zap v1.24.0 +) + +require ( + github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect + go.uber.org/atomic v1.10.0 // indirect + go.uber.org/multierr v1.9.0 // indirect + golang.org/x/net v0.0.0-20211029224645-99673261e6eb // indirect + golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 4d3bcea..bc4ebe3 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,12 @@ -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= -github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -16,32 +16,41 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= -github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= -github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M= -github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/urfave/cli/v2 v2.24.4 h1:0gyJJEBYtCV87zI/x2nZCPyDxD51K6xM8SkwjHFCNEU= +github.com/urfave/cli/v2 v2.24.4/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= +go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= +go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= +go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= golang.org/x/net v0.0.0-20211029224645-99673261e6eb h1:pirldcYWx7rx7kE5r+9WsOXPXK0+WH5+uZ7uPmJ44uM= golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go index 883134d..113a4f3 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "os" "github.com/urfave/cli/v2" + "go.uber.org/zap" rp "github.com/reportportal/goRP/v5/cli" ) @@ -16,8 +17,9 @@ var ( ) func main() { - log.SetFlags(0) - log.SetOutput(os.Stdout) + logger, _ := zap.NewProduction() + zap.ReplaceGlobals(logger) + defer logger.Sync() app := cli.NewApp() app.Name = "goRP" diff --git a/util/util.go b/util/util.go index 3f63ac8..2d3f532 100644 --- a/util/util.go +++ b/util/util.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - log "github.com/sirupsen/logrus" + "go.uber.org/zap" ) // Retry executes callback func until it executes successfully @@ -16,10 +16,10 @@ func Retry(attempts int, timeout time.Duration, callback func() (interface{}, er if err == nil { return res, nil } - log.Warnf("Retry failed with the following error: %v", err) + zap.S().Warnf("Retry failed with the following error: %v", err) <-time.After(timeout) - log.Infof("Retrying... Attempt: %d. Left: %d", i+1, attempts-1-i) + zap.S().Infof("Retrying... Attempt: %d. Left: %d", i+1, attempts-1-i) } return nil, fmt.Errorf("after %d attempts, last error: %w", attempts, err) From 24fbbb1230c8623d16c5943c8d09130acc4a9929 Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Thu, 6 Apr 2023 14:28:51 +0200 Subject: [PATCH 12/30] fixes minor lint issues adds minor improvements to batch logs saving --- .golangci.yml | 2 ++ Makefile | 8 ++------ cli/commands.go | 8 +++++--- cli/report.go | 12 ++++++------ gorp/client.go | 8 ++++++-- gorp/example_test.go | 38 ++++++++++++++++++++++++++++++-------- gorp/model_api.go | 2 +- gorp/model_enums.go | 2 +- gorp/model_reporting.go | 2 +- main.go | 4 +++- 10 files changed, 57 insertions(+), 29 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index f857d1d..67bb1e8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -42,11 +42,13 @@ linters: - nlreturn - stylecheck - exhaustivestruct + - exhaustruct - varnamelen - tagliatelle - wrapcheck - gomnd - gci + - revive #run: # skip-dirs: diff --git a/Makefile b/Makefile index 60853b5..34c5e00 100644 --- a/Makefile +++ b/Makefile @@ -15,11 +15,7 @@ help: @echo "checkstyle - gofmt+golint+misspell" init-deps: - # installs gometalinter -# curl -L https://git.io/vp6lP | sh -# gometalinter --install - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.31.0 - + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.52.2 #vendor: # dep ensure --vendor-only @@ -28,7 +24,7 @@ test: $(GO) test -cover ${GODIRS_NOVENDOR} lint: - golangci-lint run --enable-all --deadline 10m ./... + bin/golangci-lint run --enable-all --deadline 10m ./... fmt: gofumpt -extra -l -w -s ${GOFILES_NOVENDOR} diff --git a/cli/commands.go b/cli/commands.go index 1aa0005..b5c595e 100644 --- a/cli/commands.go +++ b/cli/commands.go @@ -14,9 +14,9 @@ import ( ) type config struct { - UUID string - Project string - Host string + UUID string `json:"uuid"` + Project string `json:"project"` + Host string `json:"host"` } var ( @@ -48,6 +48,8 @@ func initConfiguration(c *cli.Context) error { return nil } } + + //nolint:nosnakecase // sdk uppercase constants f, err := os.OpenFile(getConfigFile(), os.O_CREATE|os.O_WRONLY, 0o600) if err != nil { return cli.Exit(fmt.Sprintf("Cannot open config file, %s", err), 1) diff --git a/cli/report.go b/cli/report.go index 7380f84..c1a8c04 100644 --- a/cli/report.go +++ b/cli/report.go @@ -100,12 +100,12 @@ func reportTest2json(c *cli.Context) error { } type testEvent struct { - Time time.Time // encodes as an RFC3339-format string - Action string - Package string - Test string - Elapsed float64 // seconds - Output string + Time time.Time `json:"time"` // encodes as an RFC3339-format string + Action string `json:"action"` + Package string `json:"package"` + Test string `json:"test"` + Elapsed float64 `json:"elapsed"` // seconds + Output string `json:"output"` } type reporter struct { diff --git a/gorp/client.go b/gorp/client.go index 5ae533c..0b15fc1 100644 --- a/gorp/client.go +++ b/gorp/client.go @@ -28,7 +28,7 @@ func NewClient(host, project, uuid string) *Client { SetBaseURL(host). SetAuthToken(uuid). OnAfterResponse(func(client *resty.Client, rs *resty.Response) error { - // nolint:gomnd // 4xx errors + //nolint:gomnd // 4xx errors if (rs.StatusCode() / 100) >= 4 { return fmt.Errorf("status code error: %d\n%s", rs.StatusCode(), rs.String()) } @@ -242,7 +242,11 @@ func (c *Client) SaveLogMultipart(log []*SaveLogRQ, files map[string]*os.File) ( if _, sErr := os.Stat(v.Name()); os.IsNotExist(sErr) { return nil, fmt.Errorf("file %s does not exist", v.Name()) } - rq.SetMultipartField("file", k, mime.TypeByExtension(filepath.Ext(k)), v) + mimeType := mime.TypeByExtension(filepath.Ext(k)) + if mimeType == "" { + mimeType = "application/octet-stream" + } + rq.SetMultipartField("file", k, mimeType, v) } var rs EntryCreatedRS diff --git a/gorp/example_test.go b/gorp/example_test.go index 6b50818..09b7d53 100644 --- a/gorp/example_test.go +++ b/gorp/example_test.go @@ -3,13 +3,15 @@ package gorp import ( "log" "os" + "path/filepath" "time" "github.com/google/uuid" ) func ExampleClient() { - client := NewClient("xxx", "xxx", "xxx") + client := NewClient("", + "", "") launchUUID := uuid.New() launch, err := client.StartLaunch(&StartLaunchRQ{ @@ -47,13 +49,31 @@ func ExampleClient() { }) checkErr(err, "unable to save log") - file, _ := os.Open("../go.mod") - _, err = client.SaveLogMultipart([]*SaveLogRQ{{ - LaunchUUID: launchUUID.String(), - ItemID: testUUID.String(), - Level: LogLevelInfo, - Message: "Log with binary", - }}, map[string]*os.File{"go.mod": file}) + file1, _ := os.Open("../go.mod") + file2, _ := os.Open("../go.sum") + _, err = client.SaveLogMultipart([]*SaveLogRQ{ + { + LaunchUUID: launchUUID.String(), + ItemID: testUUID.String(), + Level: LogLevelInfo, + Message: "Log with binary one", + Attachment: FileAttachment{ + Name: "go.mod", + }, + }, + { + LaunchUUID: launchUUID.String(), + ItemID: testUUID.String(), + Level: LogLevelInfo, + Message: "Log with binary two", + Attachment: FileAttachment{ + Name: "go.sum", + }, + }, + }, map[string]*os.File{ + filepath.Base(file1.Name()): file1, + filepath.Base(file2.Name()): file2, + }) checkErr(err, "unable to save log multipart") @@ -71,6 +91,8 @@ func ExampleClient() { EndTime: Timestamp{time.Now()}, }) checkErr(err, "unable to finish launch") + + // Output: } func checkErr(err error, msg string) { diff --git a/gorp/model_api.go b/gorp/model_api.go index 62004e4..267c7ff 100644 --- a/gorp/model_api.go +++ b/gorp/model_api.go @@ -37,7 +37,7 @@ type ( ApproximateDuration float32 `json:"approximateDuration,omitempty"` HasRetries bool `json:"hasRetries,omitempty"` Statistics *Statistics `json:"statistics,omitempty"` - Analyzers []string `json:"analysing,omitempty"` // nolint:misspell // defined as described on server end + Analyzers []string `json:"analysing,omitempty"` //nolint:misspell // defined as described on server end } // FilterResource - GET Filter response model diff --git a/gorp/model_enums.go b/gorp/model_enums.go index 45c31fa..480570c 100644 --- a/gorp/model_enums.go +++ b/gorp/model_enums.go @@ -70,7 +70,7 @@ var Statuses = statusValuesType{ Stopped: "STOPPED", Skipped: "SKIPPED", Interrupted: "INTERRUPTED", - Canceled: "CANCELLED", // nolint:misspell // defined as described on server end + Canceled: "CANCELLED", //nolint:misspell // defined as described on server end Info: "INFO", Warn: "WARN", } diff --git a/gorp/model_reporting.go b/gorp/model_reporting.go index 2ce3ee5..990f07c 100644 --- a/gorp/model_reporting.go +++ b/gorp/model_reporting.go @@ -28,12 +28,12 @@ type ( // SaveLogRQ payload representation. SaveLogRQ struct { - File FileAttachment `json:"file,omitempty"` LaunchUUID string `json:"launchUuid,omitempty"` ItemID string `json:"itemUuid,omitempty"` LogTime Timestamp `json:"time,omitempty"` Message string `json:"message,omitempty"` Level string `json:"level,omitempty"` + Attachment FileAttachment `json:"file,omitempty"` } // StartTestRQ payload representation diff --git a/main.go b/main.go index 113a4f3..32aa951 100644 --- a/main.go +++ b/main.go @@ -19,7 +19,9 @@ var ( func main() { logger, _ := zap.NewProduction() zap.ReplaceGlobals(logger) - defer logger.Sync() + defer func() { + _ = logger.Sync() + }() app := cli.NewApp() app.Name = "goRP" From 934aa9f013e7db444c79c2f7227ecbcd277ac0db Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Thu, 6 Apr 2023 14:33:49 +0200 Subject: [PATCH 13/30] update golang-ci linter --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4579838..521a2af 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,7 @@ jobs: uses: golangci/golangci-lint-action@v2 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.45.2 + version: v1.52.2 # Optional: show only new issues if it's a pull request. The default value is `false`. only-new-issues: true # Run build of the application From a746f6e212deebb69d63d596e5c34d6bf3cfc820 Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Thu, 6 Apr 2023 14:37:29 +0200 Subject: [PATCH 14/30] fixes shields badge --- README.md | 2 +- gorp/example_test.go | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 845a532..16ed29b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![GitHub Workflow Status](https://img.shields.io/github/workflow/status/reportportal/goRP/Build) +![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/reportportal/goRP/build.yml?branch=master) [![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/eBay/fabio/master/LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/reportportal/goRP)](https://goreportcard.com/report/github.com/reportportal/goRP) diff --git a/gorp/example_test.go b/gorp/example_test.go index 09b7d53..993201e 100644 --- a/gorp/example_test.go +++ b/gorp/example_test.go @@ -91,8 +91,6 @@ func ExampleClient() { EndTime: Timestamp{time.Now()}, }) checkErr(err, "unable to finish launch") - - // Output: } func checkErr(err error, msg string) { From 792b84ae85d27b26017ac360e48b7d5127162239 Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Thu, 6 Apr 2023 14:43:14 +0200 Subject: [PATCH 15/30] fixes minor linter issues --- .golangci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.golangci.yml b/.golangci.yml index 67bb1e8..b04cbae 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -49,6 +49,7 @@ linters: - gomnd - gci - revive + - testableexamples #run: # skip-dirs: From fd1c0da81687339c42dee962c7446adfc7dfbfb7 Mon Sep 17 00:00:00 2001 From: Matthew Edwards Date: Tue, 13 Jun 2023 13:17:25 -0700 Subject: [PATCH 16/30] Add launch attributes as command-line arguments --- cli/report.go | 67 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/cli/report.go b/cli/report.go index c1a8c04..761fa45 100644 --- a/cli/report.go +++ b/cli/report.go @@ -43,6 +43,11 @@ var ( EnvVars: []string{"LAUNCH_NAME"}, Value: "gorp launch", }, + &cli.StringSliceFlag{ + Name: "attr", + Aliases: []string{"a"}, + Usage: "Launch attribute with format key:value", + }, }, Action: reportTest2json, } @@ -57,7 +62,8 @@ func reportTest2json(c *cli.Context) error { // run in separate goroutine launchNameArg := c.String("launchName") - rep := newReporter(rpClient, launchNameArg, input) + attrArgs := c.StringSlice("attr") + rep := newReporter(rpClient, launchNameArg, input, attrArgs...) wg := &sync.WaitGroup{} wg.Add(1) @@ -109,28 +115,44 @@ type testEvent struct { } type reporter struct { - input <-chan *testEvent - client *gorp.Client - launchName string - launchID string - launchOnce sync.Once - tests map[string]string - suites map[string]string - logs []*gorp.SaveLogRQ - logsBatchSize int - waitQueue sync.WaitGroup + input <-chan *testEvent + client *gorp.Client + launchName string + launchID string + launchOnce sync.Once + launchAttributes []*gorp.Attribute + tests map[string]string + suites map[string]string + logs []*gorp.SaveLogRQ + logsBatchSize int + waitQueue sync.WaitGroup } -func newReporter(client *gorp.Client, launchName string, input <-chan *testEvent) *reporter { +func newReporter(client *gorp.Client, launchName string, input <-chan *testEvent, launchAttrArgs ...string) *reporter { + launchAttributes := make([]*gorp.Attribute, 0, len(launchAttrArgs)) + for _, attr := range launchAttrArgs { + key, value, valid := strings.Cut(attr, ":") + if valid { + launchAttributes = append(launchAttributes, &gorp.Attribute{ + Parameter: gorp.Parameter{ + Key: key, + Value: value, + }, + System: false, + }) + } + } + return &reporter{ - input: input, - launchName: launchName, - client: client, - launchOnce: sync.Once{}, - tests: map[string]string{}, - suites: map[string]string{}, - logs: []*gorp.SaveLogRQ{}, - logsBatchSize: logsBatchSize, + input: input, + launchName: launchName, + launchAttributes: launchAttributes, + client: client, + launchOnce: sync.Once{}, + tests: map[string]string{}, + suites: map[string]string{}, + logs: []*gorp.SaveLogRQ{}, + logsBatchSize: logsBatchSize, } } @@ -266,8 +288,9 @@ func (r *reporter) startLaunch() error { var launch *gorp.EntryCreatedRS launch, err := r.client.StartLaunch(&gorp.StartLaunchRQ{ StartRQ: gorp.StartRQ{ - Name: r.launchName, - StartTime: gorp.NewTimestamp(time.Now()), + Name: r.launchName, + StartTime: gorp.NewTimestamp(time.Now()), + Attributes: r.launchAttributes, }, Mode: gorp.LaunchModes.Default, }) From 601145d9a9439704e5f64c5a8c33384e558f4fb1 Mon Sep 17 00:00:00 2001 From: Matthew Edwards Date: Fri, 16 Jun 2023 07:36:50 -0700 Subject: [PATCH 17/30] Update launch attribute parsing to include tagging of values --- cli/report.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/cli/report.go b/cli/report.go index 761fa45..280464f 100644 --- a/cli/report.go +++ b/cli/report.go @@ -46,7 +46,7 @@ var ( &cli.StringSliceFlag{ Name: "attr", Aliases: []string{"a"}, - Usage: "Launch attribute with format key:value", + Usage: "Launch attribute with format 'key:value'. Omitting a ':' separator will tag the launch with the value.", }, }, Action: reportTest2json, @@ -131,16 +131,18 @@ type reporter struct { func newReporter(client *gorp.Client, launchName string, input <-chan *testEvent, launchAttrArgs ...string) *reporter { launchAttributes := make([]*gorp.Attribute, 0, len(launchAttrArgs)) for _, attr := range launchAttrArgs { - key, value, valid := strings.Cut(attr, ":") - if valid { - launchAttributes = append(launchAttributes, &gorp.Attribute{ - Parameter: gorp.Parameter{ - Key: key, - Value: value, - }, - System: false, - }) + // Separate the key:value pair. If `:` is not present, the entire string is considered the value and an empty key is used + var p gorp.Parameter + if key, value, ok := strings.Cut(attr, ":"); ok { + p.Key = key + p.Value = value + } else { + p.Value = attr } + launchAttributes = append(launchAttributes, &gorp.Attribute{ + Parameter: p, + System: false, + }) } return &reporter{ From 942e3d6df1df6f39c16c7c271b069bb2e1b55835 Mon Sep 17 00:00:00 2001 From: Matthew Edwards Date: Fri, 30 Jun 2023 13:51:36 -0700 Subject: [PATCH 18/30] Reporting now uses the timestamp from the JSON go test log --- cli/report.go | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/cli/report.go b/cli/report.go index c1a8c04..7b36797 100644 --- a/cli/report.go +++ b/cli/report.go @@ -135,10 +135,11 @@ func newReporter(client *gorp.Client, launchName string, input <-chan *testEvent } func (r *reporter) receive() { + prevEventTime := time.Now() for ev := range r.input { var err error r.launchOnce.Do(func() { - if err = r.startLaunch(); err != nil { + if err = r.startLaunch(ev.Time); err != nil { zap.S().Error(err) } }) @@ -156,6 +157,7 @@ func (r *reporter) receive() { if err != nil { zap.S().Fatal(err) } + prevEventTime = ev.Time } // make sure we flush all logs that are left r.flushLogs(true) @@ -163,7 +165,7 @@ func (r *reporter) receive() { r.waitQueue.Wait() if r.launchID != "" { - if err := r.finishLaunch(gorp.Statuses.Passed); err != nil { + if err := r.finishLaunch(gorp.Statuses.Passed, prevEventTime); err != nil { zap.S().Fatal(err) } } @@ -173,7 +175,7 @@ func (r *reporter) startSuite(ev *testEvent) (string, error) { rs, err := r.client.StartTest(&gorp.StartTestRQ{ StartRQ: gorp.StartRQ{ Name: ev.Package, - StartTime: gorp.NewTimestamp(time.Now()), + StartTime: gorp.NewTimestamp(ev.Time), }, LaunchID: r.launchID, HasStats: false, @@ -200,7 +202,7 @@ func (r *reporter) startTest(ev *testEvent) (string, error) { rs, err := r.client.StartChildTest(parentID, &gorp.StartTestRQ{ StartRQ: gorp.StartRQ{ Name: ev.Test, - StartTime: gorp.NewTimestamp(time.Now()), + StartTime: gorp.NewTimestamp(ev.Time), }, LaunchID: r.launchID, HasStats: true, @@ -236,7 +238,7 @@ func (r *reporter) log(ev *testEvent) { ItemID: testID, LaunchUUID: r.launchID, Level: gorp.LogLevelInfo, - LogTime: gorp.NewTimestamp(time.Now()), + LogTime: gorp.NewTimestamp(ev.Time), Message: ev.Output, } r.logs = append(r.logs, rq) @@ -262,12 +264,12 @@ func (r *reporter) getTestName(ev *testEvent) string { return fmt.Sprintf("%s/%s", ev.Package, ev.Test) } -func (r *reporter) startLaunch() error { +func (r *reporter) startLaunch(startTime time.Time) error { var launch *gorp.EntryCreatedRS launch, err := r.client.StartLaunch(&gorp.StartLaunchRQ{ StartRQ: gorp.StartRQ{ Name: r.launchName, - StartTime: gorp.NewTimestamp(time.Now()), + StartTime: gorp.NewTimestamp(startTime), }, Mode: gorp.LaunchModes.Default, }) @@ -278,10 +280,10 @@ func (r *reporter) startLaunch() error { return err } -func (r *reporter) finishLaunch(status gorp.Status) error { +func (r *reporter) finishLaunch(status gorp.Status, endTime time.Time) error { _, err := r.client.FinishLaunch(r.launchID, &gorp.FinishExecutionRQ{ Status: status, - EndTime: gorp.NewTimestamp(time.Now()), + EndTime: gorp.NewTimestamp(endTime), }) return err } @@ -292,7 +294,7 @@ func (r *reporter) finishTest(ev *testEvent, status gorp.Status) error { _, err := r.client.FinishTest(testID, &gorp.FinishTestRQ{ FinishExecutionRQ: gorp.FinishExecutionRQ{ - EndTime: gorp.NewTimestamp(time.Now()), + EndTime: gorp.NewTimestamp(ev.Time), Status: status, }, LaunchUUID: r.launchID, @@ -315,7 +317,7 @@ func (r *reporter) finishSuite(ev *testEvent, status gorp.Status) error { _, err := r.client.FinishTest(suiteID, &gorp.FinishTestRQ{ FinishExecutionRQ: gorp.FinishExecutionRQ{ - EndTime: gorp.NewTimestamp(time.Now()), + EndTime: gorp.NewTimestamp(ev.Time), Status: status, }, LaunchUUID: r.launchID, From 0ef5cbd2e147f6d35cd7a8a51cb685365ddbdb6e Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Wed, 19 Jul 2023 10:21:40 +0200 Subject: [PATCH 19/30] update dependencies up to the latest versions --- go.mod | 14 +++++++------- go.sum | 40 +++++++++++++++++++--------------------- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/go.mod b/go.mod index 21f6f99..42939fd 100644 --- a/go.mod +++ b/go.mod @@ -6,21 +6,21 @@ require ( github.com/go-resty/resty/v2 v2.7.0 github.com/google/uuid v1.3.0 github.com/manifoldco/promptui v0.9.0 - github.com/stretchr/testify v1.8.1 - github.com/urfave/cli/v2 v2.24.4 + github.com/stretchr/testify v1.8.4 + github.com/urfave/cli/v2 v2.25.7 go.uber.org/zap v1.24.0 ) require ( - github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect + github.com/chzyer/readline v1.5.1 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - go.uber.org/atomic v1.10.0 // indirect - go.uber.org/multierr v1.9.0 // indirect - golang.org/x/net v0.0.0-20211029224645-99673261e6eb // indirect - golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect + go.uber.org/atomic v1.11.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + golang.org/x/net v0.12.0 // indirect + golang.org/x/sys v0.10.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index bc4ebe3..f965ccd 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,15 @@ github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8= +github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM= +github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8= +github.com/chzyer/readline v1.5.1 h1:upd/6fQk4src78LMRzh5vItIt361/o4uq553V8B5sGI= +github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04= +github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY= @@ -21,36 +23,32 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/urfave/cli/v2 v2.24.4 h1:0gyJJEBYtCV87zI/x2nZCPyDxD51K6xM8SkwjHFCNEU= -github.com/urfave/cli/v2 v2.24.4/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= +github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= -go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= -go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= +go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= -go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= -go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= -golang.org/x/net v0.0.0-20211029224645-99673261e6eb h1:pirldcYWx7rx7kE5r+9WsOXPXK0+WH5+uZ7uPmJ44uM= golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= +golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 8b2cd92791928d654ae159276b708250af4ca2df Mon Sep 17 00:00:00 2001 From: Matthew Edwards Date: Wed, 19 Jul 2023 10:10:27 -0700 Subject: [PATCH 20/30] Fix error identified by linter --- cli/report.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cli/report.go b/cli/report.go index ffb9ce0..4f32443 100644 --- a/cli/report.go +++ b/cli/report.go @@ -162,8 +162,9 @@ func (r *reporter) receive() { prevEventTime := time.Now() for ev := range r.input { var err error + startTime := ev.Time r.launchOnce.Do(func() { - if err = r.startLaunch(ev.Time); err != nil { + if err = r.startLaunch(startTime); err != nil { zap.S().Error(err) } }) From 1fa1ce5e5ddf0b08b94871e6bee839de1439fb99 Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Thu, 24 Aug 2023 11:51:37 +0200 Subject: [PATCH 21/30] support arm64. restructure project according default go project structure guide --- .goreleaser.yml | 22 +++++-- Makefile | 4 +- main.go => cmd/gorp/main.go | 2 +- go.mod | 5 +- go.sum | 15 ++--- {cli => internal/commands}/commands.go | 4 +- {cli => internal/commands}/launch.go | 14 ++-- {cli => internal/commands}/report.go | 88 ++++++++++++------------- {cli => internal/commands}/util.go | 2 +- {cli => internal/commands}/util_test.go | 2 +- {gorp => pkg/gorp}/client.go | 0 {gorp => pkg/gorp}/client_test.go | 0 {gorp => pkg/gorp}/example_test.go | 0 {gorp => pkg/gorp}/model_api.go | 0 {gorp => pkg/gorp}/model_api_test.go | 0 {gorp => pkg/gorp}/model_enums.go | 0 {gorp => pkg/gorp}/model_reporting.go | 0 {gorp => pkg/gorp}/util.go | 0 util/util.go | 26 -------- 19 files changed, 81 insertions(+), 103 deletions(-) rename main.go => cmd/gorp/main.go (95%) rename {cli => internal/commands}/commands.go (97%) rename {cli => internal/commands}/launch.go (92%) rename {cli => internal/commands}/report.go (74%) rename {cli => internal/commands}/util.go (98%) rename {cli => internal/commands}/util_test.go (96%) rename {gorp => pkg/gorp}/client.go (100%) rename {gorp => pkg/gorp}/client_test.go (100%) rename {gorp => pkg/gorp}/example_test.go (100%) rename {gorp => pkg/gorp}/model_api.go (100%) rename {gorp => pkg/gorp}/model_api_test.go (100%) rename {gorp => pkg/gorp}/model_enums.go (100%) rename {gorp => pkg/gorp}/model_reporting.go (100%) rename {gorp => pkg/gorp}/util.go (100%) delete mode 100644 util/util.go diff --git a/.goreleaser.yml b/.goreleaser.yml index 543289c..0eb1438 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,17 +1,25 @@ builds: - - env: + - id: gorp + main: ./cmd/gorp + binary: gorp + env: - CGO_ENABLED=0 goos: - linux - windows - darwin + goarch: + - amd64 + - arm + - arm64 archives: - - replacements: - darwin: Darwin - linux: Linux - windows: Windows - 386: i386 - amd64: x86_64 + - name_template: >- + {{- .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end -}} checksum: name_template: 'checksums.txt' snapshot: diff --git a/Makefile b/Makefile index 34c5e00..92ed8ce 100644 --- a/Makefile +++ b/Makefile @@ -32,10 +32,10 @@ fmt: #build: checkstyle test build: - $(GO) build ${BUILD_INFO_LDFLAGS} -o ${BINARY_DIR}/gorp ./ + $(GO) build ${BUILD_INFO_LDFLAGS} -o ${BINARY_DIR}/gorp ./cmd/gorp cross-build: - gox ${BUILD_INFO_LDFLAGS} -arch="amd64 386" -os="linux windows darwin" -output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}" + gox ${BUILD_INFO_LDFLAGS} -arch="amd64 arm64" -os="linux windows darwin" -output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}" ./cmd/gorp clean: if [ -d ${BINARY_DIR} ] ; then rm -r ${BINARY_DIR} ; fi diff --git a/main.go b/cmd/gorp/main.go similarity index 95% rename from main.go rename to cmd/gorp/main.go index 32aa951..64518e9 100644 --- a/main.go +++ b/cmd/gorp/main.go @@ -8,7 +8,7 @@ import ( "github.com/urfave/cli/v2" "go.uber.org/zap" - rp "github.com/reportportal/goRP/v5/cli" + rp "github.com/reportportal/goRP/v5/internal/commands" ) var ( diff --git a/go.mod b/go.mod index 42939fd..bb8af18 100644 --- a/go.mod +++ b/go.mod @@ -4,11 +4,11 @@ go 1.18 require ( github.com/go-resty/resty/v2 v2.7.0 - github.com/google/uuid v1.3.0 + github.com/google/uuid v1.3.1 github.com/manifoldco/promptui v0.9.0 github.com/stretchr/testify v1.8.4 github.com/urfave/cli/v2 v2.25.7 - go.uber.org/zap v1.24.0 + go.uber.org/zap v1.25.0 ) require ( @@ -18,7 +18,6 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.12.0 // indirect golang.org/x/sys v0.10.0 // indirect diff --git a/go.sum b/go.sum index f965ccd..79f4aca 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,4 @@ -github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= +github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM= github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ= @@ -14,11 +14,10 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY= github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= @@ -29,13 +28,11 @@ github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= -go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= -go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= +go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= +go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= diff --git a/cli/commands.go b/internal/commands/commands.go similarity index 97% rename from cli/commands.go rename to internal/commands/commands.go index b5c595e..e8c13e3 100644 --- a/cli/commands.go +++ b/internal/commands/commands.go @@ -1,4 +1,4 @@ -package cli +package commands import ( "encoding/json" @@ -10,7 +10,7 @@ import ( "github.com/urfave/cli/v2" "go.uber.org/zap" - "github.com/reportportal/goRP/v5/gorp" + "github.com/reportportal/goRP/v5/pkg/gorp" ) type config struct { diff --git a/cli/launch.go b/internal/commands/launch.go similarity index 92% rename from cli/launch.go rename to internal/commands/launch.go index 0276c44..adab109 100644 --- a/cli/launch.go +++ b/internal/commands/launch.go @@ -1,4 +1,4 @@ -package cli +package commands import ( "errors" @@ -7,7 +7,7 @@ import ( "github.com/urfave/cli/v2" - "github.com/reportportal/goRP/v5/gorp" + gorp2 "github.com/reportportal/goRP/v5/pkg/gorp" ) var ( @@ -88,9 +88,9 @@ func mergeLaunches(c *cli.Context) error { if err != nil { return err } - rq := &gorp.MergeLaunchesRQ{ + rq := &gorp2.MergeLaunchesRQ{ Name: c.String("name"), - MergeType: gorp.MergeType(c.String("type")), + MergeType: gorp2.MergeType(c.String("type")), Launches: ids, } launchResource, err := rpClient.MergeLaunches(rq) @@ -110,7 +110,7 @@ func listLaunches(c *cli.Context) error { return err } - var launches *gorp.LaunchPage + var launches *gorp2.LaunchPage if filters := c.StringSlice("filter"); len(filters) > 0 { filter := strings.Join(filters, "&") @@ -132,12 +132,12 @@ func listLaunches(c *cli.Context) error { return nil } -func getMergeIDs(c *cli.Context, rpClient *gorp.Client) ([]int, error) { +func getMergeIDs(c *cli.Context, rpClient *gorp2.Client) ([]int, error) { if ids := c.IntSlice("ids"); len(ids) > 0 { return ids, nil } - var launches *gorp.LaunchPage + var launches *gorp2.LaunchPage var err error filter := c.String("filter") diff --git a/cli/report.go b/internal/commands/report.go similarity index 74% rename from cli/report.go rename to internal/commands/report.go index 4f32443..93fd558 100644 --- a/cli/report.go +++ b/internal/commands/report.go @@ -1,4 +1,4 @@ -package cli +package commands import ( "bufio" @@ -14,7 +14,7 @@ import ( "github.com/urfave/cli/v2" "go.uber.org/zap" - "github.com/reportportal/goRP/v5/gorp" + gorp2 "github.com/reportportal/goRP/v5/pkg/gorp" ) const logsBatchSize = 10 @@ -116,30 +116,30 @@ type testEvent struct { type reporter struct { input <-chan *testEvent - client *gorp.Client + client *gorp2.Client launchName string launchID string launchOnce sync.Once - launchAttributes []*gorp.Attribute + launchAttributes []*gorp2.Attribute tests map[string]string suites map[string]string - logs []*gorp.SaveLogRQ + logs []*gorp2.SaveLogRQ logsBatchSize int waitQueue sync.WaitGroup } -func newReporter(client *gorp.Client, launchName string, input <-chan *testEvent, launchAttrArgs ...string) *reporter { - launchAttributes := make([]*gorp.Attribute, 0, len(launchAttrArgs)) +func newReporter(client *gorp2.Client, launchName string, input <-chan *testEvent, launchAttrArgs ...string) *reporter { + launchAttributes := make([]*gorp2.Attribute, 0, len(launchAttrArgs)) for _, attr := range launchAttrArgs { // Separate the key:value pair. If `:` is not present, the entire string is considered the value and an empty key is used - var p gorp.Parameter + var p gorp2.Parameter if key, value, ok := strings.Cut(attr, ":"); ok { p.Key = key p.Value = value } else { p.Value = attr } - launchAttributes = append(launchAttributes, &gorp.Attribute{ + launchAttributes = append(launchAttributes, &gorp2.Attribute{ Parameter: p, System: false, }) @@ -153,7 +153,7 @@ func newReporter(client *gorp.Client, launchName string, input <-chan *testEvent launchOnce: sync.Once{}, tests: map[string]string{}, suites: map[string]string{}, - logs: []*gorp.SaveLogRQ{}, + logs: []*gorp2.SaveLogRQ{}, logsBatchSize: logsBatchSize, } } @@ -175,9 +175,9 @@ func (r *reporter) receive() { case "output": r.log(ev) case "pass": - err = r.finish(ev, gorp.Statuses.Passed) + err = r.finish(ev, gorp2.Statuses.Passed) case "fail": - err = r.finish(ev, gorp.Statuses.Failed) + err = r.finish(ev, gorp2.Statuses.Failed) } if err != nil { zap.S().Fatal(err) @@ -190,21 +190,21 @@ func (r *reporter) receive() { r.waitQueue.Wait() if r.launchID != "" { - if err := r.finishLaunch(gorp.Statuses.Passed, prevEventTime); err != nil { + if err := r.finishLaunch(gorp2.Statuses.Passed, prevEventTime); err != nil { zap.S().Fatal(err) } } } func (r *reporter) startSuite(ev *testEvent) (string, error) { - rs, err := r.client.StartTest(&gorp.StartTestRQ{ - StartRQ: gorp.StartRQ{ + rs, err := r.client.StartTest(&gorp2.StartTestRQ{ + StartRQ: gorp2.StartRQ{ Name: ev.Package, - StartTime: gorp.NewTimestamp(ev.Time), + StartTime: gorp2.NewTimestamp(ev.Time), }, LaunchID: r.launchID, HasStats: false, - Type: gorp.TestItemTypes.Suite, + Type: gorp2.TestItemTypes.Suite, Retry: false, }) if err != nil { @@ -224,17 +224,17 @@ func (r *reporter) startTest(ev *testEvent) (string, error) { return "", err } } - rs, err := r.client.StartChildTest(parentID, &gorp.StartTestRQ{ - StartRQ: gorp.StartRQ{ + rs, err := r.client.StartChildTest(parentID, &gorp2.StartTestRQ{ + StartRQ: gorp2.StartRQ{ Name: ev.Test, - StartTime: gorp.NewTimestamp(ev.Time), + StartTime: gorp2.NewTimestamp(ev.Time), }, LaunchID: r.launchID, HasStats: true, UniqueID: testID, CodeRef: testID, TestCaseID: testID, - Type: gorp.TestItemTypes.Test, + Type: gorp2.TestItemTypes.Test, Retry: false, }) if err != nil { @@ -255,15 +255,15 @@ func (r *reporter) log(ev *testEvent) { if strings.HasPrefix(strings.TrimLeft(ev.Output, " "), "\t") && len(r.logs) > 0 { lastLog := r.logs[len(r.logs)-1] lastLog.Message = lastLog.Message + "\n" + ev.Output - lastLog.Level = gorp.LogLevelError + lastLog.Level = gorp2.LogLevelError return } - rq := &gorp.SaveLogRQ{ + rq := &gorp2.SaveLogRQ{ ItemID: testID, LaunchUUID: r.launchID, - Level: gorp.LogLevelInfo, - LogTime: gorp.NewTimestamp(ev.Time), + Level: gorp2.LogLevelInfo, + LogTime: gorp2.NewTimestamp(ev.Time), Message: ev.Output, } r.logs = append(r.logs, rq) @@ -274,14 +274,14 @@ func (r *reporter) flushLogs(force bool) { if force || (len(r.logs) >= r.logsBatchSize) { batch := r.logs r.waitQueue.Add(1) - go func(logs []*gorp.SaveLogRQ) { + go func(logs []*gorp2.SaveLogRQ) { defer r.waitQueue.Done() if _, err := r.client.SaveLogs(logs...); err != nil { zap.S().Errorf("unable to report logs: %v. Batch len: %d", err, len(logs)) } }(batch) - r.logs = []*gorp.SaveLogRQ{} + r.logs = []*gorp2.SaveLogRQ{} } } @@ -290,14 +290,14 @@ func (r *reporter) getTestName(ev *testEvent) string { } func (r *reporter) startLaunch(startTime time.Time) error { - var launch *gorp.EntryCreatedRS - launch, err := r.client.StartLaunch(&gorp.StartLaunchRQ{ - StartRQ: gorp.StartRQ{ + var launch *gorp2.EntryCreatedRS + launch, err := r.client.StartLaunch(&gorp2.StartLaunchRQ{ + StartRQ: gorp2.StartRQ{ Name: r.launchName, - StartTime: gorp.NewTimestamp(startTime), + StartTime: gorp2.NewTimestamp(startTime), Attributes: r.launchAttributes, }, - Mode: gorp.LaunchModes.Default, + Mode: gorp2.LaunchModes.Default, }) if err != nil { return err @@ -306,21 +306,21 @@ func (r *reporter) startLaunch(startTime time.Time) error { return err } -func (r *reporter) finishLaunch(status gorp.Status, endTime time.Time) error { - _, err := r.client.FinishLaunch(r.launchID, &gorp.FinishExecutionRQ{ +func (r *reporter) finishLaunch(status gorp2.Status, endTime time.Time) error { + _, err := r.client.FinishLaunch(r.launchID, &gorp2.FinishExecutionRQ{ Status: status, - EndTime: gorp.NewTimestamp(endTime), + EndTime: gorp2.NewTimestamp(endTime), }) return err } -func (r *reporter) finishTest(ev *testEvent, status gorp.Status) error { +func (r *reporter) finishTest(ev *testEvent, status gorp2.Status) error { testName := r.getTestName(ev) testID := r.tests[testName] - _, err := r.client.FinishTest(testID, &gorp.FinishTestRQ{ - FinishExecutionRQ: gorp.FinishExecutionRQ{ - EndTime: gorp.NewTimestamp(ev.Time), + _, err := r.client.FinishTest(testID, &gorp2.FinishTestRQ{ + FinishExecutionRQ: gorp2.FinishExecutionRQ{ + EndTime: gorp2.NewTimestamp(ev.Time), Status: status, }, LaunchUUID: r.launchID, @@ -328,7 +328,7 @@ func (r *reporter) finishTest(ev *testEvent, status gorp.Status) error { return err } -func (r *reporter) finish(ev *testEvent, status gorp.Status) error { +func (r *reporter) finish(ev *testEvent, status gorp2.Status) error { var err error if ev.Test == "" { err = r.finishSuite(ev, status) @@ -338,12 +338,12 @@ func (r *reporter) finish(ev *testEvent, status gorp.Status) error { return err } -func (r *reporter) finishSuite(ev *testEvent, status gorp.Status) error { +func (r *reporter) finishSuite(ev *testEvent, status gorp2.Status) error { suiteID := r.suites[ev.Package] - _, err := r.client.FinishTest(suiteID, &gorp.FinishTestRQ{ - FinishExecutionRQ: gorp.FinishExecutionRQ{ - EndTime: gorp.NewTimestamp(ev.Time), + _, err := r.client.FinishTest(suiteID, &gorp2.FinishTestRQ{ + FinishExecutionRQ: gorp2.FinishExecutionRQ{ + EndTime: gorp2.NewTimestamp(ev.Time), Status: status, }, LaunchUUID: r.launchID, diff --git a/cli/util.go b/internal/commands/util.go similarity index 98% rename from cli/util.go rename to internal/commands/util.go index 89624af..ef880af 100644 --- a/cli/util.go +++ b/internal/commands/util.go @@ -1,4 +1,4 @@ -package cli +package commands import ( "errors" diff --git a/cli/util_test.go b/internal/commands/util_test.go similarity index 96% rename from cli/util_test.go rename to internal/commands/util_test.go index 5dbeede..7c42c8d 100644 --- a/cli/util_test.go +++ b/internal/commands/util_test.go @@ -1,4 +1,4 @@ -package cli +package commands import ( "testing" diff --git a/gorp/client.go b/pkg/gorp/client.go similarity index 100% rename from gorp/client.go rename to pkg/gorp/client.go diff --git a/gorp/client_test.go b/pkg/gorp/client_test.go similarity index 100% rename from gorp/client_test.go rename to pkg/gorp/client_test.go diff --git a/gorp/example_test.go b/pkg/gorp/example_test.go similarity index 100% rename from gorp/example_test.go rename to pkg/gorp/example_test.go diff --git a/gorp/model_api.go b/pkg/gorp/model_api.go similarity index 100% rename from gorp/model_api.go rename to pkg/gorp/model_api.go diff --git a/gorp/model_api_test.go b/pkg/gorp/model_api_test.go similarity index 100% rename from gorp/model_api_test.go rename to pkg/gorp/model_api_test.go diff --git a/gorp/model_enums.go b/pkg/gorp/model_enums.go similarity index 100% rename from gorp/model_enums.go rename to pkg/gorp/model_enums.go diff --git a/gorp/model_reporting.go b/pkg/gorp/model_reporting.go similarity index 100% rename from gorp/model_reporting.go rename to pkg/gorp/model_reporting.go diff --git a/gorp/util.go b/pkg/gorp/util.go similarity index 100% rename from gorp/util.go rename to pkg/gorp/util.go diff --git a/util/util.go b/util/util.go deleted file mode 100644 index 2d3f532..0000000 --- a/util/util.go +++ /dev/null @@ -1,26 +0,0 @@ -package util - -import ( - "fmt" - "time" - - "go.uber.org/zap" -) - -// Retry executes callback func until it executes successfully -func Retry(attempts int, timeout time.Duration, callback func() (interface{}, error)) (interface{}, error) { - var err error - for i := 0; i < attempts; i++ { - var res interface{} - res, err = callback() - if err == nil { - return res, nil - } - zap.S().Warnf("Retry failed with the following error: %v", err) - - <-time.After(timeout) - zap.S().Infof("Retrying... Attempt: %d. Left: %d", i+1, attempts-1-i) - } - - return nil, fmt.Errorf("after %d attempts, last error: %w", attempts, err) -} From b9bb64b2cdba229c0a63d0e2f85ce0975fb73ddd Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Fri, 12 Jan 2024 12:25:53 +0100 Subject: [PATCH 22/30] update dependencies --- Makefile | 2 +- go.mod | 16 ++++++++-------- go.sum | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 92ed8ce..38f1752 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ lint: bin/golangci-lint run --enable-all --deadline 10m ./... fmt: - gofumpt -extra -l -w -s ${GOFILES_NOVENDOR} + gofumpt -extra -l -w ${GOFILES_NOVENDOR} gci write --section Standard --section Default --section "Prefix(github.com/reportportal/goRP/v5)" ${GOFILES_NOVENDOR} #build: checkstyle test diff --git a/go.mod b/go.mod index bb8af18..9c14cdd 100644 --- a/go.mod +++ b/go.mod @@ -3,23 +3,23 @@ module github.com/reportportal/goRP/v5 go 1.18 require ( - github.com/go-resty/resty/v2 v2.7.0 - github.com/google/uuid v1.3.1 + github.com/go-resty/resty/v2 v2.11.0 + github.com/google/uuid v1.5.0 github.com/manifoldco/promptui v0.9.0 github.com/stretchr/testify v1.8.4 - github.com/urfave/cli/v2 v2.25.7 - go.uber.org/zap v1.25.0 + github.com/urfave/cli/v2 v2.27.1 + go.uber.org/zap v1.26.0 ) require ( github.com/chzyer/readline v1.5.1 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect + github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/net v0.12.0 // indirect - golang.org/x/sys v0.10.0 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/sys v0.16.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 79f4aca..e7c2f17 100644 --- a/go.sum +++ b/go.sum @@ -10,12 +10,18 @@ github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04= github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY= github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I= +github.com/go-resty/resty/v2 v2.11.0 h1:i7jMfNOJYMp69lq7qozJP+bjgzfAzeOhuGlyDrqxT/8= +github.com/go-resty/resty/v2 v2.11.0/go.mod h1:iiP/OpA0CkcL3IGt1O0+/SIItFUbkkyw5BGXiVdTu+A= github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= +github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -26,25 +32,71 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= +github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho= +github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e h1:+SOyEddqYF09QP7vr7CgJ1eti3pY9Fn3LHO1M1r/0sI= +github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= +go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= From f6c98bee55f6d1bcf4f4322418ef90cccd1e118e Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Mon, 11 Mar 2024 18:36:09 +0100 Subject: [PATCH 23/30] update dependencies --- go.mod | 6 +++--- go.sum | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9c14cdd..492e4bc 100644 --- a/go.mod +++ b/go.mod @@ -4,11 +4,11 @@ go 1.18 require ( github.com/go-resty/resty/v2 v2.11.0 - github.com/google/uuid v1.5.0 + github.com/google/uuid v1.6.0 github.com/manifoldco/promptui v0.9.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 github.com/urfave/cli/v2 v2.27.1 - go.uber.org/zap v1.26.0 + go.uber.org/zap v1.27.0 ) require ( diff --git a/go.sum b/go.sum index e7c2f17..30900b6 100644 --- a/go.sum +++ b/go.sum @@ -22,6 +22,8 @@ github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -30,6 +32,8 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho= @@ -46,6 +50,8 @@ go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= From 91d99535b46eb7c26a0b08d88ea98656fdbd5086 Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Mon, 11 Mar 2024 19:11:57 +0100 Subject: [PATCH 24/30] fixes minor issues with linter --- .github/workflows/build.yml | 2 +- .golangci.yml | 1 + Makefile | 4 ++-- internal/commands/util_test.go | 8 ++++---- pkg/gorp/model_api_test.go | 5 +++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 521a2af..13b0063 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,7 @@ jobs: uses: golangci/golangci-lint-action@v2 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.52.2 + version: v1.56.0 # Optional: show only new issues if it's a pull request. The default value is `false`. only-new-issues: true # Run build of the application diff --git a/.golangci.yml b/.golangci.yml index b04cbae..b5cd21c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -50,6 +50,7 @@ linters: - gci - revive - testableexamples + - depguard #run: # skip-dirs: diff --git a/Makefile b/Makefile index 38f1752..1a165e8 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ help: @echo "checkstyle - gofmt+golint+misspell" init-deps: - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.52.2 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.56.0 #vendor: # dep ensure --vendor-only @@ -24,7 +24,7 @@ test: $(GO) test -cover ${GODIRS_NOVENDOR} lint: - bin/golangci-lint run --enable-all --deadline 10m ./... + bin/golangci-lint run --deadline 10m ./... fmt: gofumpt -extra -l -w ${GOFILES_NOVENDOR} diff --git a/internal/commands/util_test.go b/internal/commands/util_test.go index 7c42c8d..947f97a 100644 --- a/internal/commands/util_test.go +++ b/internal/commands/util_test.go @@ -8,20 +8,20 @@ import ( func TestUnderstandsYes(t *testing.T) { t.Parallel() - assert.Equal(t, true, answerYes("yes")) + assert.True(t, answerYes("yes")) } func TestUnderstandsYesUpper(t *testing.T) { t.Parallel() - assert.Equal(t, true, answerYes("YES")) + assert.True(t, answerYes("YES")) } func TestEmptyAnswer(t *testing.T) { t.Parallel() - assert.Equal(t, false, answerYes("")) + assert.False(t, answerYes("")) } func TestUnderstandsNo(t *testing.T) { t.Parallel() - assert.Equal(t, false, answerYes("no")) + assert.False(t, answerYes("no")) } diff --git a/pkg/gorp/model_api_test.go b/pkg/gorp/model_api_test.go index d569b6b..3d6d250 100644 --- a/pkg/gorp/model_api_test.go +++ b/pkg/gorp/model_api_test.go @@ -6,6 +6,7 @@ import ( "time" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestUnixTimeDeserialization(t *testing.T) { @@ -15,7 +16,7 @@ func TestUnixTimeDeserialization(t *testing.T) { var unitTime Timestamp err := json.Unmarshal([]byte(jsonStr), &unitTime) - assert.NoError(t, err) + require.NoError(t, err) unitTime = Timestamp{unitTime.Truncate(1 * time.Minute)} @@ -32,7 +33,7 @@ func TestUnixTimeSerialization(t *testing.T) { d, _ := time.Parse(time.RFC3339, expTime) bytes, err := json.Marshal(&Timestamp{d}) - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, jsonStr, string(bytes)) } From ea02ddbded9fafd7eaf3ed940bcb8cb63bf985fd Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Tue, 12 Mar 2024 11:12:39 +0100 Subject: [PATCH 25/30] updates date flag to be set by goreleaser --- cmd/gorp/main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/gorp/main.go b/cmd/gorp/main.go index 64518e9..2e7e3fd 100644 --- a/cmd/gorp/main.go +++ b/cmd/gorp/main.go @@ -12,8 +12,8 @@ import ( ) var ( - version = "" - buildDate = "" + version = "dev" + date = "unknown" ) func main() { @@ -26,7 +26,7 @@ func main() { app := cli.NewApp() app.Name = "goRP" app.Usage = "ReportPortal CLI Client" - app.Version = fmt.Sprintf("%s (%s)", version, buildDate) + app.Version = fmt.Sprintf("%s (%s)", version, date) app.Authors = []*cli.Author{{ Name: "Andrei Varabyeu", Email: "andrei.varabyeu@gmail.com", From b274a9377ab739db95d1a16aaf0b11a9efdfbc3c Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Wed, 3 Apr 2024 09:55:51 +0200 Subject: [PATCH 26/30] add possibility to pass reader to logs multipart --- .github/workflows/build.yml | 2 +- .goreleaser.yml | 2 +- Makefile | 6 ++-- go.mod | 10 +++--- go.sum | 57 +++++++++----------------------- internal/commands/commands.go | 5 ++- internal/commands/report.go | 61 +++++++++++++++++++++++------------ cmd/gorp/main.go => main.go | 13 ++++---- pkg/gorp/client.go | 32 ++++++++---------- pkg/gorp/example_test.go | 24 ++++++++------ pkg/gorp/model_reporting.go | 16 ++++----- pkg/gorp/multipart.go | 52 +++++++++++++++++++++++++++++ 12 files changed, 162 insertions(+), 118 deletions(-) rename cmd/gorp/main.go => main.go (86%) create mode 100644 pkg/gorp/multipart.go diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 13b0063..406131e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,7 @@ jobs: uses: golangci/golangci-lint-action@v2 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.56.0 + version: v1.57.2 # Optional: show only new issues if it's a pull request. The default value is `false`. only-new-issues: true # Run build of the application diff --git a/.goreleaser.yml b/.goreleaser.yml index 0eb1438..f4770f4 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,6 +1,6 @@ builds: - id: gorp - main: ./cmd/gorp + main: ./ binary: gorp env: - CGO_ENABLED=0 diff --git a/Makefile b/Makefile index 1a165e8..00bb397 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ help: @echo "checkstyle - gofmt+golint+misspell" init-deps: - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.56.0 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.57.2 #vendor: # dep ensure --vendor-only @@ -24,7 +24,7 @@ test: $(GO) test -cover ${GODIRS_NOVENDOR} lint: - bin/golangci-lint run --deadline 10m ./... + bin/golangci-lint run ./... fmt: gofumpt -extra -l -w ${GOFILES_NOVENDOR} @@ -32,7 +32,7 @@ fmt: #build: checkstyle test build: - $(GO) build ${BUILD_INFO_LDFLAGS} -o ${BINARY_DIR}/gorp ./cmd/gorp + $(GO) build ${BUILD_INFO_LDFLAGS} -o ${BINARY_DIR}/gorp ./ cross-build: gox ${BUILD_INFO_LDFLAGS} -arch="amd64 arm64" -os="linux windows darwin" -output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}" ./cmd/gorp diff --git a/go.mod b/go.mod index 492e4bc..9f53993 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,13 @@ module github.com/reportportal/goRP/v5 -go 1.18 +go 1.21 require ( - github.com/go-resty/resty/v2 v2.11.0 + github.com/go-resty/resty/v2 v2.12.0 github.com/google/uuid v1.6.0 github.com/manifoldco/promptui v0.9.0 github.com/stretchr/testify v1.9.0 github.com/urfave/cli/v2 v2.27.1 - go.uber.org/zap v1.27.0 ) require ( @@ -18,8 +17,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e // indirect - go.uber.org/multierr v1.11.0 // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/sys v0.16.0 // indirect + golang.org/x/net v0.22.0 // indirect + golang.org/x/sys v0.18.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 30900b6..d4acd3d 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,3 @@ -github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM= github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ= @@ -8,20 +7,12 @@ github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObk github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04= github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= -github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= -github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY= -github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I= -github.com/go-resty/resty/v2 v2.11.0 h1:i7jMfNOJYMp69lq7qozJP+bjgzfAzeOhuGlyDrqxT/8= -github.com/go-resty/resty/v2 v2.11.0/go.mod h1:iiP/OpA0CkcL3IGt1O0+/SIItFUbkkyw5BGXiVdTu+A= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= -github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/go-resty/resty/v2 v2.12.0 h1:rsVL8P90LFvkUYq/V5BTVe203WfRIU4gvcf+yfzJzGA= +github.com/go-resty/resty/v2 v2.12.0/go.mod h1:o0yGPrkS3lOe1+eFajk6kBW8ScXzwU3hD69/gt2yB/0= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= @@ -30,74 +21,56 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= -github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho= github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e h1:+SOyEddqYF09QP7vr7CgJ1eti3pY9Fn3LHO1M1r/0sI= github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= -go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= -go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= -go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= -go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= -go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= -go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= -go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= -golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= diff --git a/internal/commands/commands.go b/internal/commands/commands.go index e8c13e3..29cade3 100644 --- a/internal/commands/commands.go +++ b/internal/commands/commands.go @@ -3,12 +3,12 @@ package commands import ( "encoding/json" "fmt" + "log/slog" "net/url" "os" "github.com/manifoldco/promptui" "github.com/urfave/cli/v2" - "go.uber.org/zap" "github.com/reportportal/goRP/v5/pkg/gorp" ) @@ -49,14 +49,13 @@ func initConfiguration(c *cli.Context) error { } } - //nolint:nosnakecase // sdk uppercase constants f, err := os.OpenFile(getConfigFile(), os.O_CREATE|os.O_WRONLY, 0o600) if err != nil { return cli.Exit(fmt.Sprintf("Cannot open config file, %s", err), 1) } defer func() { if closeErr := f.Close(); closeErr != nil { - zap.S().Error(closeErr) + slog.Default().Error(closeErr.Error()) } }() diff --git a/internal/commands/report.go b/internal/commands/report.go index 93fd558..961a53d 100644 --- a/internal/commands/report.go +++ b/internal/commands/report.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "io" + "log/slog" "os" "path/filepath" "strings" @@ -12,7 +13,6 @@ import ( "time" "github.com/urfave/cli/v2" - "go.uber.org/zap" gorp2 "github.com/reportportal/goRP/v5/pkg/gorp" ) @@ -53,7 +53,8 @@ var ( } ) -func reportTest2json(c *cli.Context) error { +//nolint:nonamedreturns // for readability +func reportTest2json(c *cli.Context) (err error) { rpClient, err := buildClient(c) if err != nil { return err @@ -69,8 +70,9 @@ func reportTest2json(c *cli.Context) error { wg.Add(1) go func() { defer wg.Done() - rep.receive() + err = rep.receive() }() + // wait for report to complete defer wg.Wait() defer close(input) @@ -83,7 +85,7 @@ func reportTest2json(c *cli.Context) error { } defer func() { if cErr := f.Close(); cErr != nil { - zap.S().Error(cErr) + slog.Error(cErr.Error()) } }() reader = f @@ -97,7 +99,7 @@ func reportTest2json(c *cli.Context) error { var ev testEvent if err := json.Unmarshal([]byte(data), &ev); err != nil { - zap.S().Error(err) + slog.Default().Error(err.Error()) return err } input <- &ev @@ -158,42 +160,61 @@ func newReporter(client *gorp2.Client, launchName string, input <-chan *testEven } } -func (r *reporter) receive() { +func (r *reporter) reportEvent(ev *testEvent) error { + var err error + switch ev.Action { + case "run": + _, err = r.startTest(ev) + case "output": + r.log(ev) + case "pass": + err = r.finish(ev, gorp2.Statuses.Passed) + case "fail": + err = r.finish(ev, gorp2.Statuses.Failed) + } + return err +} + +func (r *reporter) receive() error { prevEventTime := time.Now() for ev := range r.input { var err error startTime := ev.Time + + // start launch once + // when first event comes r.launchOnce.Do(func() { if err = r.startLaunch(startTime); err != nil { - zap.S().Error(err) + slog.Error(err.Error()) } }) - - switch ev.Action { - case "run": - _, err = r.startTest(ev) - case "output": - r.log(ev) - case "pass": - err = r.finish(ev, gorp2.Statuses.Passed) - case "fail": - err = r.finish(ev, gorp2.Statuses.Failed) + if err != nil { + return err } + + // report event to ReportPortal + err = r.reportEvent(ev) if err != nil { - zap.S().Fatal(err) + return err } + + // remember last's event time + // for RP's finishLaunch prevEventTime = ev.Time } + // make sure we flush all logs that are left r.flushLogs(true) // wait for requests to get sent r.waitQueue.Wait() + // finish launch of started if r.launchID != "" { if err := r.finishLaunch(gorp2.Statuses.Passed, prevEventTime); err != nil { - zap.S().Fatal(err) + return err } } + return nil } func (r *reporter) startSuite(ev *testEvent) (string, error) { @@ -278,7 +299,7 @@ func (r *reporter) flushLogs(force bool) { defer r.waitQueue.Done() if _, err := r.client.SaveLogs(logs...); err != nil { - zap.S().Errorf("unable to report logs: %v. Batch len: %d", err, len(logs)) + slog.Error("unable to report logs", "error", err, "batch_length", len(logs)) } }(batch) r.logs = []*gorp2.SaveLogRQ{} diff --git a/cmd/gorp/main.go b/main.go similarity index 86% rename from cmd/gorp/main.go rename to main.go index 2e7e3fd..43fb1e7 100644 --- a/cmd/gorp/main.go +++ b/main.go @@ -3,10 +3,10 @@ package main import ( "fmt" "log" + "log/slog" "os" "github.com/urfave/cli/v2" - "go.uber.org/zap" rp "github.com/reportportal/goRP/v5/internal/commands" ) @@ -17,11 +17,12 @@ var ( ) func main() { - logger, _ := zap.NewProduction() - zap.ReplaceGlobals(logger) - defer func() { - _ = logger.Sync() - }() + slog.SetDefault(slog.New( + slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{ + Level: slog.LevelError, + AddSource: true, + }), + )) app := cli.NewApp() app.Name = "goRP" diff --git a/pkg/gorp/client.go b/pkg/gorp/client.go index 0b15fc1..2cb6423 100644 --- a/pkg/gorp/client.go +++ b/pkg/gorp/client.go @@ -3,10 +3,8 @@ package gorp import ( "bytes" "encoding/json" + "errors" "fmt" - "mime" - "os" - "path/filepath" "time" "github.com/go-resty/resty/v2" @@ -21,12 +19,12 @@ type Client struct { // NewClient creates new instance of Client // host - server hostname // project - name of the project -// uuid - User Token (see user profile page) -func NewClient(host, project, uuid string) *Client { +// apiKey - User Token (see user profile page) +func NewClient(host, project, apiKey string) *Client { http := resty.New(). // SetDebug(true). SetBaseURL(host). - SetAuthToken(uuid). + SetAuthToken(apiKey). OnAfterResponse(func(client *resty.Client, rs *resty.Response) error { //nolint:gomnd // 4xx errors if (rs.StatusCode() / 100) >= 4 { @@ -181,7 +179,7 @@ func (c *Client) finishTest(id string, body interface{}) (*MsgRS, error) { // SaveLog attaches log in RP func (c *Client) SaveLog(log *SaveLogRQ) (*EntryCreatedRS, error) { var rs EntryCreatedRS - _, err := c.http.SetDebug(true).R(). + _, err := c.http.R(). SetPathParams(map[string]string{ "project": c.project, }). @@ -219,7 +217,7 @@ func (c *Client) SaveLogs(logs ...*SaveLogRQ) (*EntryCreatedRS, error) { // } // // resp, err := client.SaveLogMultipart(log, files) -func (c *Client) SaveLogMultipart(log []*SaveLogRQ, files map[string]*os.File) (*EntryCreatedRS, error) { +func (c *Client) SaveLogMultipart(log []*SaveLogRQ, files []Multipart) (*EntryCreatedRS, error) { var bodyBuf bytes.Buffer err := json.NewEncoder(&bodyBuf).Encode(log) if err != nil { @@ -235,18 +233,16 @@ func (c *Client) SaveLogMultipart(log []*SaveLogRQ, files map[string]*os.File) ( rq.SetMultipartField("json_request_part", "", "application/json", &bodyBuf) // BINARY PART - for k, v := range files { - if v == nil { - return nil, fmt.Errorf("no file for [%s] is provided", k) - } - if _, sErr := os.Stat(v.Name()); os.IsNotExist(sErr) { - return nil, fmt.Errorf("file %s does not exist", v.Name()) + for _, v := range files { + fileName, contentType, reader, lErr := v.Load() + if lErr != nil { + return nil, fmt.Errorf("unable to read multipart: %w", lErr) } - mimeType := mime.TypeByExtension(filepath.Ext(k)) - if mimeType == "" { - mimeType = "application/octet-stream" + if fileName == "" { + return nil, errors.New("no file name is provided") } - rq.SetMultipartField("file", k, mimeType, v) + + rq.SetMultipartField("file", fileName, contentType, reader) } var rs EntryCreatedRS diff --git a/pkg/gorp/example_test.go b/pkg/gorp/example_test.go index 993201e..7e3cb33 100644 --- a/pkg/gorp/example_test.go +++ b/pkg/gorp/example_test.go @@ -3,15 +3,14 @@ package gorp import ( "log" "os" - "path/filepath" "time" "github.com/google/uuid" ) func ExampleClient() { - client := NewClient("", - "", "") + client := NewClient("https://reportportal.epam.com", + "andrei_varabyeu_personal", "gorp-test_MCQZajD8S_ClBSGo-Q6X7KtzBKjFGiw0PPf6oB0-nexU1MSRMMcO_4_Sn4YGTBtk") launchUUID := uuid.New() launch, err := client.StartLaunch(&StartLaunchRQ{ @@ -49,15 +48,18 @@ func ExampleClient() { }) checkErr(err, "unable to save log") - file1, _ := os.Open("../go.mod") - file2, _ := os.Open("../go.sum") + file1, err := os.Open("../../go.mod") + checkErr(err, "unable to read file") + file2, err := os.Open("../../go.sum") + checkErr(err, "unable to read file") + _, err = client.SaveLogMultipart([]*SaveLogRQ{ { LaunchUUID: launchUUID.String(), ItemID: testUUID.String(), Level: LogLevelInfo, Message: "Log with binary one", - Attachment: FileAttachment{ + Attachment: Attachment{ Name: "go.mod", }, }, @@ -66,13 +68,13 @@ func ExampleClient() { ItemID: testUUID.String(), Level: LogLevelInfo, Message: "Log with binary two", - Attachment: FileAttachment{ + Attachment: Attachment{ Name: "go.sum", }, }, - }, map[string]*os.File{ - filepath.Base(file1.Name()): file1, - filepath.Base(file2.Name()): file2, + }, []Multipart{ + &FileMultipart{File: file1}, + &ReaderMultipart{ContentType: "text/plain", FileName: file2.Name(), Reader: file2}, }) checkErr(err, "unable to save log multipart") @@ -91,6 +93,8 @@ func ExampleClient() { EndTime: Timestamp{time.Now()}, }) checkErr(err, "unable to finish launch") + + // Output: } func checkErr(err error, msg string) { diff --git a/pkg/gorp/model_reporting.go b/pkg/gorp/model_reporting.go index 990f07c..f64f25b 100644 --- a/pkg/gorp/model_reporting.go +++ b/pkg/gorp/model_reporting.go @@ -28,12 +28,12 @@ type ( // SaveLogRQ payload representation. SaveLogRQ struct { - LaunchUUID string `json:"launchUuid,omitempty"` - ItemID string `json:"itemUuid,omitempty"` - LogTime Timestamp `json:"time,omitempty"` - Message string `json:"message,omitempty"` - Level string `json:"level,omitempty"` - Attachment FileAttachment `json:"file,omitempty"` + LaunchUUID string `json:"launchUuid,omitempty"` + ItemID string `json:"itemUuid,omitempty"` + LogTime Timestamp `json:"time,omitempty"` + Message string `json:"message,omitempty"` + Level string `json:"level,omitempty"` + Attachment Attachment `json:"file,omitempty"` } // StartTestRQ payload representation @@ -104,8 +104,8 @@ type ( time.Time } - // FileAttachment represents file attachment in log entries - FileAttachment struct { + // Attachment represents file attachment in log entries + Attachment struct { Name string `json:"name,omitempty"` } ) diff --git a/pkg/gorp/multipart.go b/pkg/gorp/multipart.go new file mode 100644 index 0000000..1c37fcf --- /dev/null +++ b/pkg/gorp/multipart.go @@ -0,0 +1,52 @@ +package gorp + +import ( + "errors" + "fmt" + "io" + "mime" + "os" + "path/filepath" +) + +// Multipart is an interface that allows to pass over different types +// of multipart data sources +type Multipart interface { + // Load loads multipart data + Load() (fileName, contentType string, reader io.Reader, err error) +} + +// FileMultipart is a multipart content in form of file +type FileMultipart struct { + *os.File +} + +//nolint:nonamedreturns // for readability +func (fm *FileMultipart) Load() (fileName, contentType string, reader io.Reader, err error) { + if fm.File == nil { + return "", "", nil, errors.New("file shouldn't be nil") + } + fName := fm.File.Name() + if _, sErr := os.Stat(fName); os.IsNotExist(sErr) { + return "", "", nil, fmt.Errorf("file %s does not exist", fName) + } + contentType = mime.TypeByExtension(filepath.Ext(fName)) + if contentType == "" { + contentType = "application/octet-stream" + } + return filepath.Base(fName), contentType, fm.File, nil +} + +// ReaderMultipart is a multipart content in form of io.Reader +type ReaderMultipart struct { + FileName, ContentType string + io.Reader +} + +//nolint:nonamedreturns // for readability +func (fm *ReaderMultipart) Load() (fileName, contentType string, reader io.Reader, err error) { + if fm.FileName == "" { + return "", "", nil, errors.New("multipart filename shouldn't be nil") + } + return fm.FileName, fm.ContentType, fm, nil +} From 29be72005b192fe5bf75e1a5968290ec2ffa986a Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Wed, 3 Apr 2024 10:50:19 +0200 Subject: [PATCH 27/30] add release workflow, update installation steps --- .github/workflows/release.yml | 41 +++++++++++++++++++++++++++++++++++ README.md | 22 +++++++++++++++++-- 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..30629d5 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,41 @@ +# .github/workflows/release.yml +name: goreleaser + +on: + pull_request: + push: + # run only against tags + tags: + - "*" + +permissions: + contents: write + # packages: write + # issues: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: stable + # More assembly might be required: Docker logins, GPG, etc. + # It all depends on your needs. + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + # either 'goreleaser' (default) or 'goreleaser-pro' + distribution: goreleaser + # 'latest', 'nightly', or a semver + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution + # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} \ No newline at end of file diff --git a/README.md b/README.md index 16ed29b..8352e6a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ -![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/reportportal/goRP/build.yml?branch=master) -[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/eBay/fabio/master/LICENSE) +![Build Status](https://github.com/golangci/golangci-lint/workflows/CI/badge.svg) [![Go Report Card](https://goreportcard.com/badge/github.com/reportportal/goRP)](https://goreportcard.com/report/github.com/reportportal/goRP) +[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/reportportal/goRP/master/LICENSE) +[![License](https://img.shields.io/github/license/golangci/golangci-lint)](/LICENSE) +[![Release](https://img.shields.io/github/release/reportportal/goRP.svg)](https://github.com/reportportal/goRP/releases/latest) +[![GitHub Releases Stats of goRP](https://img.shields.io/github/downloads/reportportal/goRP/total.svg?logo=github)](https://somsubhra.github.io/github-release-stats/?username=reportportal&repository=gorP) # goRP @@ -8,6 +11,21 @@ Golang Client and CLI Utility for [ReportPortal](https://reportportal.io) ## Installation +- Via Go Install +```sh +go install github.com/reportportal/goRP@latest +``` +- Via cURL (passing version and arch) +```sh +curl -sL https://github.com/avarabyeu/goRP/releases/download/v5.0.2/goRP_5.0.2_darwin_amd64.tar.gz | tar zx -C . +``` +- Via cURL (latest one) +```sh +curl -s https://api.github.com/repos/reportportal/goRP/releases/latest | \ + jq -r '.assets[] | select(.name | contains ("tar.gz")) | .browser_download_url' | \ + grep "$(uname)_$(arch)" | \ + xargs curl -sL | tar zx -C . +``` ## Usage ``` From b56ba778b13976594d15af897ff1f54e77b1f465 Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Wed, 3 Apr 2024 10:53:46 +0200 Subject: [PATCH 28/30] minor documentation fixes --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 8352e6a..6053b86 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ -![Build Status](https://github.com/golangci/golangci-lint/workflows/CI/badge.svg) +![Build Status](https://github.com/reportportal/goRP/workflows/Build/badge.svg) [![Go Report Card](https://goreportcard.com/badge/github.com/reportportal/goRP)](https://goreportcard.com/report/github.com/reportportal/goRP) [![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/reportportal/goRP/master/LICENSE) -[![License](https://img.shields.io/github/license/golangci/golangci-lint)](/LICENSE) [![Release](https://img.shields.io/github/release/reportportal/goRP.svg)](https://github.com/reportportal/goRP/releases/latest) [![GitHub Releases Stats of goRP](https://img.shields.io/github/downloads/reportportal/goRP/total.svg?logo=github)](https://somsubhra.github.io/github-release-stats/?username=reportportal&repository=gorP) From ddd7bf68ee8a8c749871cca43d0c6ed6f6737300 Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Wed, 3 Apr 2024 10:57:20 +0200 Subject: [PATCH 29/30] run goreleaser only on tags creation --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 30629d5..a6449c8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,6 @@ name: goreleaser on: - pull_request: push: # run only against tags tags: From bdbc696386016569a060e67244196c93735d6dff Mon Sep 17 00:00:00 2001 From: Andrei Varabyeu Date: Wed, 3 Apr 2024 10:58:51 +0200 Subject: [PATCH 30/30] update go compiler in github actions --- .github/workflows/build.yml | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 406131e..1b54764 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,11 +16,11 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v5 with: - go-version: '1.18.3' # The Go version to download (if necessary) and use. + go-version: '1.21.8' # The Go version to download (if necessary) and use. # - name: Install dependencies # run: | # go version @@ -39,22 +39,3 @@ jobs: # Run testing on the code - name: Run testing run: make test -# -# -# # The "deploy" workflow -# deploy: -# # The type of runner that the job will run on -# runs-on: ubuntu-latest -# needs: [build] # Only run this workflow when "build" workflow succeeds -# if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' }} # Only run this workflow if it is master branch on push event -# steps: -# - uses: actions/checkout@v2 -# -# # Deploy to Docker registry -# - name: Deploy to Docker registry -# uses: docker/build-push-action@v1 -# with: -# username: ${{ secrets.DOCKER_USERNAME }} -# password: ${{ secrets.DOCKER_PASSWORD }} -# repository: wilsontanwm/gosimple -# tag_with_ref: true \ No newline at end of file