From c32060b5aed434bf1fff3aa3bd971a49bee0fb04 Mon Sep 17 00:00:00 2001 From: Phillip Miller Date: Wed, 29 Dec 2021 03:39:32 -0500 Subject: [PATCH] fixed linter warnings - fixed caching workflow --- .../workflows/codacy-coverage-reporter.yml | 28 +++-- .github/workflows/go.yml | 103 +++++++++++------- githubapi/githubapi.go | 2 +- 3 files changed, 83 insertions(+), 50 deletions(-) diff --git a/.github/workflows/codacy-coverage-reporter.yml b/.github/workflows/codacy-coverage-reporter.yml index 8f0aa13..114a8ae 100644 --- a/.github/workflows/codacy-coverage-reporter.yml +++ b/.github/workflows/codacy-coverage-reporter.yml @@ -23,17 +23,24 @@ jobs: with: go-version: ${{ matrix.go-version }} - - name: Cache Go modules + - id: go-cache-paths + run: | + echo "::set-output name=go-build::$(go env GOCACHE)" + echo "::set-output name=go-mod::$(go env GOMODCACHE)" + + # Cache go build cache + - name: Go Build Cache + uses: actions/cache@v2 + with: + path: ${{ steps.go-cache-paths.outputs.go-build }} + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} + + # Cache go mod cache + - name: Go Mod Cache uses: actions/cache@v2 with: - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-codacy-coverage-reporter-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.OS }}-codacy-coverage-reporter-${{ env.cache-name }}- - ${{ runner.OS }}-codacy-coverage-reporter- - ${{ runner.OS }}- + path: ${{ steps.go-cache-paths.outputs.go-mod }} + key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} # Remove apt repos that are known to break from time to time # See https://github.com/actions/virtual-environments/issues/323 @@ -60,7 +67,8 @@ jobs: # Run Tests and Coverage - name: Run Tests and Coverage run: | - go test -v -coverprofile=coverage.out ./... | tee >(richgo testfilter) | go-junit-report > coverage/${{ runner.OS }}-report.xml + go test -v -coverprofile=coverage.out ./... | tee test.out + cat test.out | go-junit-report > coverage/${{ runner.OS }}-report.xml gocov convert coverage.out | gocov-xml > coverage/${{ runner.OS }}-report.xml - name: Run codacy-coverage-reporter diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index daf318b..91ab09c 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -22,18 +22,24 @@ jobs: with: go-version: ${{ matrix.go-version }} - - name: Cache Go modules + - id: go-cache-paths + run: | + echo "::set-output name=go-build::$(go env GOCACHE)" + echo "::set-output name=go-mod::$(go env GOMODCACHE)" + + # Cache go build cache + - name: Go Build Cache + uses: actions/cache@v2 + with: + path: ${{ steps.go-cache-paths.outputs.go-build }} + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} + + # Cache go mod cache + - name: Go Mod Cache uses: actions/cache@v2 with: - path: | - ~/go/pkg/mod - ~/.cache/go-build - ~/Library/Caches/go-build - key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.OS }}-build-${{ env.cache-name }}- - ${{ runner.OS }}-build- - ${{ runner.OS }}- + path: ${{ steps.go-cache-paths.outputs.go-mod }} + key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} - name: Install dependencies run: go get github.com/mattn/go-isatty@v0.0.12 @@ -58,18 +64,24 @@ jobs: with: go-version: ${{ matrix.go-version }} - - name: Cache Go modules + - id: go-cache-paths + run: | + echo "::set-output name=go-build::$(go env GOCACHE)" + echo "::set-output name=go-mod::$(go env GOMODCACHE)" + + # Cache go build cache + - name: Go Build Cache + uses: actions/cache@v2 + with: + path: ${{ steps.go-cache-paths.outputs.go-build }} + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} + + # Cache go mod cache + - name: Go Mod Cache uses: actions/cache@v2 with: - path: | - ~/go/pkg/mod - ~/.cache/go-build - ~/Library/Caches/go-build - key: ${{ runner.os }}-test-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.OS }}-test-${{ env.cache-name }}- - ${{ runner.OS }}-test- - ${{ runner.OS }}- + path: ${{ steps.go-cache-paths.outputs.go-mod }} + key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} - name: Install dependencies run: go get github.com/mattn/go-isatty@v0.0.12 @@ -104,18 +116,24 @@ jobs: with: go-version: ${{ matrix.go-version }} - - name: Cache Go modules + - id: go-cache-paths + run: | + echo "::set-output name=go-build::$(go env GOCACHE)" + echo "::set-output name=go-mod::$(go env GOMODCACHE)" + + # Cache go build cache + - name: Go Build Cache + uses: actions/cache@v2 + with: + path: ${{ steps.go-cache-paths.outputs.go-build }} + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} + + # Cache go mod cache + - name: Go Mod Cache uses: actions/cache@v2 with: - path: | - ~/go/pkg/mod - ~/.cache/go-build - ~/Library/Caches/go-build - key: ${{ runner.os }}-run-pimp-my-shell-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.OS }}-run-pimp-my-shell-${{ env.cache-name }}- - ${{ runner.OS }}-run-pimp-my-shell- - ${{ runner.OS }}- + path: ${{ steps.go-cache-paths.outputs.go-mod }} + key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} - name: Go Build run: | @@ -176,17 +194,24 @@ jobs: with: go-version: 1.17.x - - name: Cache Go modules + - id: go-cache-paths + run: | + echo "::set-output name=go-build::$(go env GOCACHE)" + echo "::set-output name=go-mod::$(go env GOMODCACHE)" + + # Cache go build cache + - name: Go Build Cache + uses: actions/cache@v2 + with: + path: ${{ steps.go-cache-paths.outputs.go-build }} + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} + + # Cache go mod cache + - name: Go Mod Cache uses: actions/cache@v2 with: - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-release-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.OS }}-release-${{ env.cache-name }}- - ${{ runner.OS }}-release- - ${{ runner.OS }}- + path: ${{ steps.go-cache-paths.outputs.go-mod }} + key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} - name: Install dependencies run: go get github.com/mattn/go-isatty@v0.0.12 diff --git a/githubapi/githubapi.go b/githubapi/githubapi.go index f47a128..742ce52 100644 --- a/githubapi/githubapi.go +++ b/githubapi/githubapi.go @@ -35,7 +35,7 @@ type ReleaseAssets struct { } func getLatestReleasesFromGithubRepo(owner, repo string) (*ReleaseAssets, error) { - client := &github.Client{} + var client = &github.Client{} ctx := context.Background() githubToken, ok := os.LookupEnv("GITHUB_TOKEN") if ok {