--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -23,47 +23,17 @@ jobs:
golang-lint:
- name: Golang Lint
- runs-on: ubuntu-22.04
+ name: golang-lint
+ runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
- - uses: actions/setup-go@v4
- with:
- go-version: '1.22'
- cache: false
- - name: golangci-lint
- uses: golangci/golangci-lint-action@v3
- with:
- # Require: The version of golangci-lint to use.
- # When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
- # When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
- version: v1.54
-
- # Optional: working directory, useful for monorepos
- # working-directory: somedir
-
- # Optional: golangci-lint command line arguments.
- #
- # Note: By default, the `.golangci.yml` file should be at the root of the repository.
- # The location of the configuration file can be changed by using `--config=`
- # args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
- args: --timeout=30m
-
- # Optional: show only new issues if it's a pull request. The default value is `false`.
- # only-new-issues: true
-
- # Optional: if set to true, then all caching functionality will be completely disabled,
- # takes precedence over all other caching options.
- # skip-cache: true
-
- # Optional: if set to true, then the action won't cache or restore ~/go/pkg.
- # skip-pkg-cache: true
-
- # Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
- # skip-build-cache: true
-
- # Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
- # install-mode: "goinstall"
+ - uses: actions/checkout@v3
+ - uses: actions/setup-go@v4
+ with:
+ go-version: '1.23'
+ cache: false
+ - name: golangci-lint
+ run: |
+ make lint
updated makefile
--- a/Makefile
+++ b/Makefile
@@ -119,6 +119,23 @@ fmt: ## Run go fmt against code.
vet: ## Run go vet against code.
go vet ./...
+
+GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
+GOLANGCI_LINT_VERSION ?= v1.60.3
+golangci-lint:
+ @[ -f $(GOLANGCI_LINT) ] || { \
+ set -e ;\
+ curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) $(GOLANGCI_LINT_VERSION) ;\
+ }
+
+.PHONY: lint
+lint: golangci-lint ## Run golangci-lint linter & yamllint
+ $(GOLANGCI_LINT) run --timeout 5m
+
+.PHONY: lint-fix
+lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
+ $(GOLANGCI_LINT) run --fix
+
.PHONY: test
test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out
@@ -126,7 +143,7 @@ test: manifests generate fmt vet envtest ## Run tests.
##@ Build
.PHONY: build
-build: manifests generate fmt vet ## Build manager binary.
+build: manifests generate fmt vet lint ## Build manager binary.
go build -o bin/manager cmd/main.go
.PHONY: run
Duplicates
I have searched the existing issues
Summary 💡
trace:
Examples 🌈
updated ci lint:
updated makefile
Motivation 🔦
No response