Skip to content

Commit

Permalink
chore: use the same make targhet for lkint and vuln check locally and…
Browse files Browse the repository at this point in the history
… on ci
  • Loading branch information
lburgazzoli committed May 8, 2024
1 parent 8eeaf83 commit 6be1c1b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 16 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 4 additions & 7 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/kamel.*
/license-check
/**/platform-check
bin/

# Config files
/kamel-config.yaml
Expand Down
43 changes: 39 additions & 4 deletions script/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)

0 comments on commit 6be1c1b

Please sign in to comment.