From 5c4656ed1fc7582baa9bc454b09602f4db2aafea Mon Sep 17 00:00:00 2001 From: Richard87 Date: Mon, 3 Jun 2024 09:54:11 +0200 Subject: [PATCH] update golangci-lint, goreleaser, remove shorthand flag, add comment about local file and file:// --- .github/workflows/ci.yml | 20 ++++++++------------ .golangci.yaml | 15 +++++++++++++++ Dockerfile | 2 +- Makefile | 6 +++++- cmd/validateRadixConfig.go | 2 +- 5 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 .golangci.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 003a04a..4505faa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,15 +24,15 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: - go-version: '1.21' + go-version-file: 'go.mod' - name: Run GoReleaser uses: goreleaser/goreleaser-action@v5 with: distribution: goreleaser - version: v1.21.2 + version: v1.26.2 args: build --clean --single-target --snapshot env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -44,14 +44,10 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 2 - - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5 with: - go-version: '1.21' - - name: Install dependencies - run: go mod download - - name: Install GolangCI Lint - run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2 - + go-version-file: 'go.mod' - name: golangci-lint - run: golangci-lint run --timeout=30m --max-same-issues=0 --out-format=github-actions - + uses: golangci/golangci-lint-action@v4 + with: + version: v1.58.2 diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..810cb8c --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,15 @@ +run: + timeout: 30m + +linters: + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - zerologlint + +issues: + max-same-issues: 0 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 859dcde..7c91e33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21-alpine3.18 as builder +FROM golang:1.22-alpine3.19 as builder ENV GO111MODULE=on diff --git a/Makefile b/Makefile index 4948fae..dd2e002 100644 --- a/Makefile +++ b/Makefile @@ -18,11 +18,15 @@ lint: bootstrap HAS_SWAGGER := $(shell command -v swagger;) HAS_GOLANGCI_LINT := $(shell command -v golangci-lint;) +HAS_GORELEASER := $(shell command -v goreleaser;) bootstrap: ifndef HAS_SWAGGER go install github.com/go-swagger/go-swagger/cmd/swagger@v0.30.5 endif ifndef HAS_GOLANGCI_LINT - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2 + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.58.2 +endif +ifndef HAS_GORELEASER + go install github.com/goreleaser/goreleaser@v1.26.2 endif diff --git a/cmd/validateRadixConfig.go b/cmd/validateRadixConfig.go index f1c8220..e974ea8 100644 --- a/cmd/validateRadixConfig.go +++ b/cmd/validateRadixConfig.go @@ -168,7 +168,7 @@ func init() { validateCmd.AddCommand(validateRadixConfigCmd) validateRadixConfigCmd.Flags().StringP(flagnames.ConfigFile, "f", "radixconfig.yaml", "Name of the radixconfig file. Defaults to radixconfig.yaml in current directory") validateRadixConfigCmd.Flags().BoolP(flagnames.Print, "p", false, "Print parsed config file") - validateRadixConfigCmd.Flags().StringP(flagnames.Schema, "s", "https://raw.githubusercontent.com/equinor/radix-operator/release/json-schema/radixapplication.json", "Validate against schema") + validateRadixConfigCmd.Flags().String(flagnames.Schema, "https://raw.githubusercontent.com/equinor/radix-operator/release/json-schema/radixapplication.json", "Validate against schema. http://, file:// or path is supported") // Allow but hide token-env flag so radix-github-actions won't interfere validateRadixConfigCmd.Flags().Bool(flagnames.TokenEnvironment, false, fmt.Sprintf("Take the token from environment variable %s", client.TokenEnvironmentName))