diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a2d77c..f9af697 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,11 +15,11 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - # Go 1.15 - - name: Set up Go 1.15 + # Go 1.16 + - name: Set up Go 1.16 uses: actions/setup-go@v2 with: - go-version: ^1.15 + go-version: ^1.16 # Checkout code - name: Checkout repository @@ -32,7 +32,7 @@ jobs: # if: steps.vendor-cache.outputs.cache-hit != 'true' - name: Restore vendor from cache id: vendor-cache - uses: actions/cache@v2.1.4 + uses: actions/cache@v2.1.6 env: cache-name: vendor with: @@ -42,9 +42,9 @@ jobs: # Style consistency and static analysis using 'golangci-lint' # https://github.com/marketplace/actions/run-golangci-lint - name: Static analysis - uses: golangci/golangci-lint-action@v2.4.0 + uses: golangci/golangci-lint-action@v2.5.2 with: - version: v1.38 + version: latest # Run unit tests - name: Test diff --git a/.github/workflows/maintenance.yml b/.github/workflows/maintenance.yml index 34aa7f2..2282eb7 100644 --- a/.github/workflows/maintenance.yml +++ b/.github/workflows/maintenance.yml @@ -7,7 +7,7 @@ jobs: name: "close stale issues and pull requests" runs-on: ubuntu-latest steps: - - uses: actions/stale@v3 + - uses: actions/stale@v3.0.19 with: # On the 'debug' mode the action will not perform any operation. # Add the secret ACTIONS_STEP_DEBUG with a value of 'true' in the repository. diff --git a/.github/workflows/release.yml b/.github/workflows/publish.yml similarity index 80% rename from .github/workflows/release.yml rename to .github/workflows/publish.yml index 08b0bf2..98d8c66 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,4 @@ -name: release +name: publish on: push: tags: @@ -11,15 +11,16 @@ jobs: timeout-minutes: 10 if: startsWith(github.ref, 'refs/tags/') steps: - # Go 1.15 - - name: Set up Go 1.15 + # Go 1.16 + - name: Set up Go 1.16 uses: actions/setup-go@v2 with: - go-version: ^1.15 + go-version: ^1.16 # Checkout code - name: Checkout repository uses: actions/checkout@v2 + # This is required for the changelog to be properly generated with: fetch-depth: 0 @@ -28,20 +29,17 @@ jobs: # if: steps.vendor-cache.outputs.cache-hit != 'true' - name: Restore vendor from cache id: vendor-cache - uses: actions/cache@v2.1.4 + uses: actions/cache@v2.1.6 env: cache-name: vendor with: path: ./vendor key: ${{ env.cache-name }}-${{ hashFiles('go.sum') }} - # Ensure project compile and build successfully - - name: Build - run: make build-for os=linux arch=amd64 - # Use goreleaser to create the new release + # https://github.com/goreleaser/goreleaser-action - name: Create release - uses: goreleaser/goreleaser-action@v2 + uses: goreleaser/goreleaser-action@v2.6.1 if: startsWith(github.ref, 'refs/tags/') with: version: latest diff --git a/.golangci.yml b/.golangci.yml index 44216cb..a65ff49 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -24,7 +24,7 @@ linters: - errcheck - gosimple - govet - - golint + - revive - gofmt - ineffassign - staticcheck @@ -39,7 +39,6 @@ linters: - nakedret - prealloc - gosec - - scopelint - bodyclose - stylecheck - unparam @@ -48,13 +47,12 @@ linters: - asciicheck - errorlint - exhaustive - - exportloopref - forcetypeassert - godot - ifshort - noctx - predeclared - - scopelint + - exportloopref - wastedassign - whitespace #- wrapcheck @@ -75,7 +73,6 @@ issues: - gosec - lll - nakedret - - scopelint - funlen - nestif - noctx @@ -103,8 +100,6 @@ linters-settings: - unusedresult - tests #- fieldalignment - golint: - min-confidence: 0.8 gofmt: simplify: true gocyclo: diff --git a/.goreleaser.yml b/.goreleaser.yml index 831f507..3a25541 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -58,28 +58,30 @@ snapshot: # configure the 'CHANGELOG.md' file produced # https://goreleaser.com/customization/release/#customize-the-changelog changelog: - sort: asc + # Sorts the changelog by the commit messages (asc, desc or '') + sort: '' + # Remove certain commit messages from the changelog filters: + # Standard commit messages can help to produce better changelogs + # https://www.conventionalcommits.org/en/v1.0.0/ exclude: - "^docs:" - "^test:" - - typo + - "^chore:" + - "^typo:" # build and publish docker images # https://goreleaser.com/customization/docker/ dockers: - + # Build IDs to gather the binaries from + ids: + - govanity # GOOS of the built binary that should be used goos: linux # GOARCH of the built binary that should be used goarch: amd64 # Dockerfile location dockerfile: Dockerfile - # Binaries that should be used - binaries: - - govanity - # Build IDs to gather the binaries from - builds: - - govanity # OCI image tags build_flag_templates: - "--pull" @@ -87,9 +89,12 @@ dockers: - "--label=org.opencontainers.image.revision={{ .FullCommit }}" - "--label=org.opencontainers.image.version={{ .Version }}" - "--label=org.opencontainers.image.created={{ .CommitDate }}" + - "--label=org.opencontainers.image.source=https://github.com/bryk-io/{{ .ProjectName }}" # Skips the docker push if there is an indicator for prerelease # in the tag e.g. v1.0.0-rc1 (auto) - skip_push: auto + skip_push: false + # Additional files to add/copy into the container image + extra_files: [] image_templates: - "ghcr.io/bryk-io/{{ .ProjectName }}:{{ .Version }}" - "ghcr.io/bryk-io/{{ .ProjectName }}:latest" diff --git a/Dockerfile b/Dockerfile index 6bec9b3..69add2a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/bryk-io/shell:0.1.0 +FROM ghcr.io/bryk-io/shell:0.2.0 # Expose required ports and volumes VOLUME ["/tmp", "/etc/govanity"] diff --git a/Makefile b/Makefile index d06a4f9..1382248 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,6 @@ LD_FLAGS += -X main.coreVersion=$(GIT_TAG) LD_FLAGS += -X main.buildTimestamp=$(GIT_COMMIT_DATE) LD_FLAGS += -X main.buildCode=$(GIT_COMMIT_HASH) -## help: Prints this help message help: @echo "Commands available" @sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /' | sort @@ -82,7 +81,7 @@ release: ## scan: Look for known vulnerabilities in the project dependencies # https://github.com/sonatype-nexus-community/nancy scan: - @go list -f '{{if not .Indirect}}{{.}}{{end}}' -mod=mod -m all | nancy sleuth -o text + @go list -f '{{if not .Indirect}}{{.}}{{end}}' -m all | nancy sleuth --skip-update-check ## test: Run unit tests excluding the vendor dependencies test: diff --git a/config_test.go b/config_test.go index 32858ba..9ed1c38 100644 --- a/config_test.go +++ b/config_test.go @@ -3,7 +3,6 @@ package main import ( "encoding/json" - "fmt" "io/ioutil" "net/http" "testing" @@ -11,7 +10,7 @@ import ( "gopkg.in/yaml.v2" ) -var sampleConf string = ` +var sampleConf = ` host: go.bryk.io cache_max_age: 3600 paths: @@ -118,7 +117,7 @@ func TestServer(t *testing.T) { if err != nil { t.Error(err) } - if fmt.Sprintf("%s", response) != "pong" { + if string(response) != "pong" { t.Error("invalid response") } }) @@ -153,7 +152,7 @@ func TestServer(t *testing.T) { if err != nil { t.Error(err) } - if fmt.Sprintf("%s", response) != "unknown path" { + if string(response) != "unknown path" { t.Error("invalid response") } })