-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install golangci-lint in .tools directory in Makefile (#5)
* Install golangci-lint in .tools directory in Makefile CI is currently failing because it requires golangci-lint, which does not exist in the CI environment. This commit updates the Makefile so that it includes a .tools directory, as well as a Make target for golangci-lint and reference to the vendored golangci-lint binary in the lint target. Signed-off-by: John Schaeffer <[email protected]> * Update test CI workflow to use Go 1.21 iam-runtime-infratographer and golangci-lint both require Go 1.21. This commit updates the test CI workflow to use it instead of 1.20. Signed-off-by: John Schaeffer <[email protected]> --------- Signed-off-by: John Schaeffer <[email protected]>
- Loading branch information
1 parent
e9a832e
commit 2dba94e
Showing
3 changed files
with
20 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*~ | ||
coverage.out | ||
bin/* | ||
bin/* | ||
.tools/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,30 @@ | ||
all: lint test | ||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) | ||
TOOLS_DIR := .tools | ||
|
||
GOLANGCI_LINT_REPO = github.com/golangci/golangci-lint | ||
GOLANGCI_LINT_VERSION = v1.56.1 | ||
|
||
all: test build | ||
PHONY: test coverage lint golint clean vendor docker-up docker-down unit-test | ||
GOOS=linux | ||
# use the working dir as the app name, this should be the repo name | ||
APP_NAME=$(shell basename $(CURDIR)) | ||
|
||
test: | lint | ||
@echo Running tests... | ||
@go test -mod=readonly -race -coverprofile=coverage.out -covermode=atomic ./... | ||
|
||
lint: | ||
lint: $(TOOLS_DIR)/golangci-lint | ||
@echo Linting Go files... | ||
@golangci-lint run --modules-download-mode=readonly | ||
@$(TOOLS_DIR)/golangci-lint run --modules-download-mode=readonly | ||
|
||
build: | ||
@CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o bin/${APP_NAME} | ||
@CGO_ENABLED=0 go build -mod=readonly -v -o bin/${APP_NAME} | ||
|
||
go-dependencies: | ||
@go mod download | ||
@go mod tidy | ||
|
||
$(TOOLS_DIR): | ||
mkdir -p $(TOOLS_DIR) | ||
|
||
$(TOOLS_DIR)/golangci-lint: | $(TOOLS_DIR) | ||
@echo "Installing $(GOLANGCI_LINT_REPO)/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)" | ||
@GOBIN=$(ROOT_DIR)/$(TOOLS_DIR) go install $(GOLANGCI_LINT_REPO)/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) |