-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-3: Updating to a more modern Makefile and moving TravisCI to go1.19
- Loading branch information
James Root
committed
Nov 23, 2022
1 parent
f874f01
commit a5f0ab8
Showing
3 changed files
with
16 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
language: go | ||
|
||
go: | ||
- 1.15.x | ||
- 1.19.x | ||
|
||
before_script: | ||
- make lint-install | ||
- make lint |
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 |
---|---|---|
|
@@ -3,45 +3,31 @@ SHELL := bash | |
.SHELLFLAGS := -euo pipefail -c | ||
.DEFAULT_GOAL := all | ||
|
||
BIN_DIR ?= $(shell go env GOPATH)/bin | ||
export PATH := $(PATH):$(BIN_DIR) | ||
RUN_GO_GROUPS := go run oss.indeed.com/go/[email protected] | ||
RUN_GO_OPINE := go run oss.indeed.com/go/[email protected] | ||
RUN_GOLANGCI_LINT := go run github.com/golangci/golangci-lint/cmd/[email protected] | ||
|
||
.PHONY: deps | ||
deps: ## download go modules | ||
go mod download | ||
|
||
.PHONY: fmt | ||
fmt: lint/check ## ensure consistent code style | ||
go run oss.indeed.com/go/go-groups -w . | ||
gofmt -s -w . | ||
golangci-lint run --fix > /dev/null 2>&1 || true | ||
fmt: ## ensure consistent code style | ||
$(RUN_GO_GROUPS) -w . | ||
$(RUN_GOLANGCI_LINT) run --fix > /dev/null 2>&1 || true | ||
go mod tidy | ||
|
||
.PHONY: lint/check | ||
lint/check: | ||
@if ! golangci-lint --version > /dev/null 2>&1; then \ | ||
echo -e "\033[0;33mgolangci-lint is not installed: run \`\033[0;32mmake lint-install\033[0m\033[0;33m\` or install it from https://golangci-lint.run\033[0m"; \ | ||
exit 1; \ | ||
fi | ||
|
||
.PHONY: lint-install | ||
lint-install: ## installs golangci-lint to the go bin dir | ||
@if ! golangci-lint --version > /dev/null 2>&1; then \ | ||
echo "Installing golangci-lint"; \ | ||
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(BIN_DIR) v1.32.0; \ | ||
fi | ||
|
||
.PHONY: lint | ||
lint: lint/check ## run golangci-lint | ||
golangci-lint run | ||
@if [ -n "$$(gofmt -s -l .)" ] || [ -n "$$(go run oss.indeed.com/go/go-groups -d .)" ]; then \ | ||
lint: ## run golangci-lint | ||
$(RUN_GOLANGCI_LINT) run | ||
@if [ -n "$$($(RUN_GO_GROUPS) -l .)" ]; then \ | ||
echo -e "\033[0;33mdetected fmt problems: run \`\033[0;32mmake fmt\033[0m\033[0;33m\`\033[0m"; \ | ||
exit 1; \ | ||
fi | ||
|
||
.PHONY: test | ||
test: lint ## run go tests | ||
go run oss.indeed.com/go/go-opine test -coverprofile=cover.out -junit=report.xml | ||
$(RUN_GO_OPINE) test -coverprofile=cover.out -junit=report.xml | ||
|
||
.PHONY: all | ||
all: test | ||
|
@@ -50,4 +36,4 @@ all: test | |
help: ## displays this help message | ||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_\/-]+:.*?## / {printf "\033[34m%-12s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \ | ||
sort | \ | ||
grep -v '#' | ||
grep -v '#' |
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