From 0e07c0c605c2c94b01511fc109c6a175c95818cc Mon Sep 17 00:00:00 2001 From: Lucas Pinheiro Date: Tue, 10 May 2022 09:57:38 -0300 Subject: [PATCH 1/7] Run CI unit tests in Windows --- .github/workflows/test.yml | 17 +++++++++++++++++ cmd/gen-pipeline-report.go | 2 +- pkg/cli/cli.go | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..9c81e3f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,17 @@ +on: [push] +name: Unit tests +jobs: + unit-testing: + runs-on: windows-latest + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.16.x + - name: Check out repository code + uses: actions/checkout@v2 + - name: Run tests + run: | + go get ./... + go get -u gotest.tools/gotestsum + gotestsum --junitfile /tmp/junit.xml \ No newline at end of file diff --git a/cmd/gen-pipeline-report.go b/cmd/gen-pipeline-report.go index 5b247d2..d32c7cb 100644 --- a/cmd/gen-pipeline-report.go +++ b/cmd/gen-pipeline-report.go @@ -52,7 +52,7 @@ var genPipelineReportCmd = &cobra.Command{ } if len(args) == 0 { - dir, err = ioutil.TempDir("/tmp", "test-results") + dir, err = ioutil.TempDir("", "test-results") if err != nil { logger.Error("Creating temporary directory failed %v", err) return err diff --git a/pkg/cli/cli.go b/pkg/cli/cli.go index 187e078..e95a5c2 100644 --- a/pkg/cli/cli.go +++ b/pkg/cli/cli.go @@ -142,7 +142,7 @@ func WriteToFile(data []byte, path string) (string, error) { // WriteToTmpFile saves data to temporary file func WriteToTmpFile(data []byte) (string, error) { - file, err := ioutil.TempFile("/tmp", "test-results") + file, err := ioutil.TempFile("", "test-results") if err != nil { logger.Error("Opening file %s: %v", file.Name(), err) From 3fba75f74b3d22aff12c2fc9f1123d1774944512 Mon Sep 17 00:00:00 2001 From: Lucas Pinheiro Date: Tue, 10 May 2022 10:50:56 -0300 Subject: [PATCH 2/7] Remove Github actions and update goreleaser --- .github/workflows/test.yml | 17 ---------------- .goreleaser.yml | 41 +++++++++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 20 deletions(-) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 9c81e3f..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,17 +0,0 @@ -on: [push] -name: Unit tests -jobs: - unit-testing: - runs-on: windows-latest - steps: - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: 1.16.x - - name: Check out repository code - uses: actions/checkout@v2 - - name: Run tests - run: | - go get ./... - go get -u gotest.tools/gotestsum - gotestsum --junitfile /tmp/junit.xml \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml index 3af7e5f..a99469d 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,24 +1,59 @@ project_name: test-results + before: hooks: - go generate ./... + builds: - - env: - - CGO_ENABLED=0 + - id: non-windows-build + env: + - CGO_ENABLED=0 goos: - linux - darwin + goarch: + - 386 + - amd64 + - arm + - arm64 + - id: windows-build + env: + - CGO_ENABLED=0 + ldflags: + - -s -w -X main.VERSION={{.Tag}} + goos: + - windows + goarch: + - 386 + - amd64 + - arm + - arm64 + archives: - - name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' + - id: non-windows-archive + builds: + - non-windows-build + name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' replacements: darwin: Darwin linux: Linux 386: i386 amd64: x86_64 + - id: windows-archive + builds: + - windows-build + name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' + replacements: + 386: i386 + amd64: x86_64 + windows: Windows + checksum: name_template: '{{ .ProjectName }}_checksums.txt' + snapshot: name_template: "{{ .Tag }}-next" + changelog: sort: asc filters: From d8efef8785cd2beeff23ea3cf4240804f012e73a Mon Sep 17 00:00:00 2001 From: Lucas Pinheiro Date: Tue, 13 Sep 2022 09:34:47 -0300 Subject: [PATCH 3/7] Add helper Makefile target --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index c92aaab..0906b04 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,9 @@ test.watch: build: CGO_ENABLED=0 go build -o bin/test-results +build.windows: + CGO_ENABLED=0 GOOS=windows go build -o bin/test-results + release.major: git fetch --tags latest=$$(git tag | sort --version-sort | tail -n 1); new=$$(echo $$latest | cut -c 2- | awk -F '.' '{ print "v" $$1+1 ".0.0" }'); echo $$new; git tag $$new; git push origin $$new From 1dd56e64a6ecaba294317c48c492e63416eedf41 Mon Sep 17 00:00:00 2001 From: Lucas Pinheiro Date: Tue, 13 Sep 2022 09:44:34 -0300 Subject: [PATCH 4/7] add CI tests --- .github/workflows/test.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..090ded6 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,17 @@ +on: [push] +name: Unit tests +jobs: + unit-testing: + runs-on: windows-latest + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.17.x + - name: Check out repository code + uses: actions/checkout@v2 + - name: Run tests + run: | + go get ./... + go install gotest.tools/gotestsum@latest + gotestsum --format short-verbose --packages="./..." -- -p 1 \ No newline at end of file From 4330991e8bf60f03a0f04b830fa702b152b7a05f Mon Sep 17 00:00:00 2001 From: Lucas Pinheiro Date: Tue, 13 Sep 2022 09:46:57 -0300 Subject: [PATCH 5/7] trigger build again From 643e0d0451bb4db067432828ec8212e059d270fe Mon Sep 17 00:00:00 2001 From: Lucas Pinheiro Date: Tue, 13 Sep 2022 09:54:09 -0300 Subject: [PATCH 6/7] trigger build again From 264c0ae62ec002c268fe8615d65de8a2c6229205 Mon Sep 17 00:00:00 2001 From: Lucas Pinheiro Date: Tue, 13 Sep 2022 10:03:55 -0300 Subject: [PATCH 7/7] use Go 1.18 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 090ded6..80f24c1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ jobs: - name: Install Go uses: actions/setup-go@v2 with: - go-version: 1.17.x + go-version: 1.18.x - name: Check out repository code uses: actions/checkout@v2 - name: Run tests