diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..80f24c1 --- /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.18.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 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: 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 diff --git a/cmd/gen-pipeline-report.go b/cmd/gen-pipeline-report.go index ffb3c04..2030607 100644 --- a/cmd/gen-pipeline-report.go +++ b/cmd/gen-pipeline-report.go @@ -53,7 +53,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 3640246..b3a1659 100644 --- a/pkg/cli/cli.go +++ b/pkg/cli/cli.go @@ -147,7 +147,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)