Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Use golangci-lint with Docker #13

Merged
merged 2 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ jobs:
- name: Build
run: |
make build
- name: Lint
run: |
make lint
- name: Run tests
run: |
make test
19 changes: 6 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ IMAGE_TAG ?= latest

all: build

.PHONY: setup
setup: install-linter

.PHONY: install-linter
install-linter:
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.31.0

.PHONY: git-config
git-config:
echo "" > ~/.gitconfig
Expand All @@ -34,13 +27,13 @@ clean:
test:
$(GO_TEST) $(GO_TEST_PACKAGES)

.PHONY: goimports
goimports:
goimports -w .

lint: ## Run golangci-lint
docker run --rm -v ${GOPATH}/pkg/mod:/go/pkg/mod -v $(shell pwd):/app -v $(shell go env GOCACHE):/cache/go -e GOCACHE=/cache/go -e GOLANGCI_LINT_CACHE=/cache/go -w /app golangci/golangci-lint:v1.59.1 golangci-lint run --modules-download-mode=readonly /app/...
.PHONY: lint
lint: install-linter
golangci-lint run

lint/fix: ## Run golangci-lint with --fix
docker run --rm -v ${GOPATH}/pkg/mod:/go/pkg/mod -v $(shell pwd):/app -v $(shell go env GOCACHE):/cache/go -e GOCACHE=/cache/go -e GOLANGCI_LINT_CACHE=/cache/go -w /app golangci/golangci-lint:v1.59.1 golangci-lint run --fix --modules-download-mode=readonly /app/...
.PHONY: lint/fix

# TODO: tag
.PHONY: docker/build
Expand Down
Loading