This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/main by this push:
new 6be1c1bd3 chore: use the same make targhet for lkint and vuln check
locally and on ci
6be1c1bd3 is described below
commit 6be1c1bd3d4e694d49c8984fd4ec3bac047e23a5
Author: Luca Burgazzoli <[email protected]>
AuthorDate: Wed May 8 11:00:38 2024 +0200
chore: use the same make targhet for lkint and vuln check locally and on ci
---
.github/workflows/security.yaml | 8 +++-----
.github/workflows/validate.yml | 11 ++++-------
.gitignore | 1 +
script/Makefile | 43 +++++++++++++++++++++++++++++++++++++----
4 files changed, 47 insertions(+), 16 deletions(-)
diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml
index ed2877794..23d9b49e5 100644
--- a/.github/workflows/security.yaml
+++ b/.github/workflows/security.yaml
@@ -51,9 +51,7 @@ jobs:
with:
go-version-file: 'go.mod'
check-latest: true
- - name: Install govulncheck
- run: go install golang.org/x/vuln/cmd/govulncheck@latest
- shell: bash
- - name: Run govulncheck
- run: govulncheck ./...
+ - name: lint
shell: bash
+ run: |
+ make vuln
diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml
index 91955e7d2..6a9a371e3 100644
--- a/.github/workflows/validate.yml
+++ b/.github/workflows/validate.yml
@@ -50,10 +50,7 @@ jobs:
with:
go-version-file: 'go.mod'
check-latest: true
- - name: golangci-lint
- uses: golangci/golangci-lint-action@v4
- env:
- GOGC: 20
- with:
- version: v1.58.0
- args: --verbose --timeout 15m --config .golangci.yml
+ - name: lint
+ shell: bash
+ run: |
+ make lint
diff --git a/.gitignore b/.gitignore
index 6896b7685..ef4f286cf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@
/kamel.*
/license-check
/**/platform-check
+bin/
# Config files
/kamel-config.yaml
diff --git a/script/Makefile b/script/Makefile
index 08d4adf3f..db79a62ee 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -19,6 +19,10 @@
#
SHELL := /bin/bash
+MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
+PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
+LOCALBIN := $(PROJECT_PATH)/bin
+
VERSIONFILE := pkg/util/defaults/defaults.go
VERSION ?= 2.4.0-SNAPSHOT
LAST_RELEASED_IMAGE_NAME := camel-k-operator
@@ -29,6 +33,12 @@ CODEGEN_VERSION := v0.27.4
OPERATOR_SDK_VERSION := v1.28.0
KUSTOMIZE_VERSION := v4.5.4
OPM_VERSION := v1.24.0
+LINTER_VERSION ?= v1.58.0
+GOVULNCHECK_VERSION ?= latest
+
+LINTER ?= $(LOCALBIN)/golangci-lint
+GOVULNCHECK ?= $(LOCALBIN)/govulncheck
+
BASE_IMAGE := eclipse-temurin:17
LOCAL_REPOSITORY := /etc/maven/m2
IMAGE_NAME ?= docker.io/apache/camel-k
@@ -394,6 +404,7 @@ clean:
rm -f camel-k
rm -f kamel
rm -f *.test
+ rm -rf $(LOCALBIN)
rm -rf build/_maven_output
rm -rf build/_maven_overlay
rm -rf build/_output
@@ -418,11 +429,19 @@ OS := $(patsubst MINGW%,MSYS,$(OS))
OS_LOWER := $(shell echo $(OS) | tr '[:upper:]' '[:lower:]')
endif
-lint:
- GOGC=$(LINT_GOGC) golangci-lint run --config .golangci.yml --out-format
colored-tab --timeout $(LINT_DEADLINE) --verbose
+check: lint vuln
-lint-fix:
- GOGC=$(LINT_GOGC) golangci-lint run --config .golangci.yml --out-format
colored-tab --timeout $(LINT_DEADLINE) --fix
+.PHONY: lint
+lint: golangci-lint
+ GOGC=$(LINT_GOGC) $(LINTER) run --config .golangci.yml --out-format
colored-tab --timeout $(LINT_DEADLINE) --verbose
+
+.PHONY: lint-fix
+lint-fix: golangci-lint
+ GOGC=$(LINT_GOGC) $(LINTER) run --config .golangci.yml --out-format
colored-tab --timeout $(LINT_DEADLINE) --fix
+
+.PHONY: vuln
+vuln: govulncheck
+ @$(GOVULNCHECK) ./...
dir-licenses:
./script/vendor-license-directory.sh
@@ -708,3 +727,19 @@ bundle-index: opm yq
OPM=$(OPM) BUNDLE_IMAGE=$(BUNDLE_IMAGE_NAME):$(CUSTOM_VERSION)
CSV_NAME=$(CSV_PRODUCTION_NAME) \
CSV_SKIPS=$(CSV_SKIP_RANGE) CSV_REPLACES=$(CSV_REPLACES)
CHANNELS="$(CHANNELS)" \
./script/build_bundle_index.sh
+
+## Location to install dependencies to
+$(LOCALBIN):
+ mkdir -p $(LOCALBIN)
+
+.PHONY: golangci-lint
+golangci-lint: $(LINTER)
+$(LINTER): $(LOCALBIN)
+ @test -s $(LOCALBIN)/golangci-lint || \
+ GOBIN=$(LOCALBIN) go install
github.com/golangci/golangci-lint/cmd/golangci-lint@$(LINTER_VERSION)
+
+.PHONY: govulncheck
+govulncheck: $(GOVULNCHECK)
+$(GOVULNCHECK): $(LOCALBIN)
+ @test -s $(GOVULNCHECK) || \
+ GOBIN=$(LOCALBIN) go install
golang.org/x/vuln/cmd/govulncheck@$(GOVULNCHECK_VERSION)