nikoksr/proji

View on GitHub
Makefile

Summary

Maintainability
Test Coverage
# Adapted from https://github.com/goreleaser/goreleaser/blob/master/Makefile

export PATH := ./bin:$(PATH)
export GO111MODULE := on

# Install all the build and lint dependencies
setup:
    go mod download
    go generate -v ./...
.PHONY: setup

# Run all the tests
test:
    LC_ALL=C go test -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt -timeout=5m ./...
.PHONY: test

# Run all the tests and opens the coverage report
cover: test
    go tool cover -html=coverage.txt
.PHONY: cover

# gofmt and goimports all go files
fmt:
    find . -name '*.go' -not -wholename './vendor/*' | while read -r file; do gofumports -w "$$file"; done
.PHONY: fmt

# Run all the linters
lint:
    golangci-lint run ./...
    misspell -error **/*
.PHONY: lint

# Run all the tests and code checks
ci: build test lint
.PHONY: ci

# Build a beta version of goreleaser
build:
    go build -o ./bin/proji .
.PHONY: build

# Show to-do items per file.
todo:
    @grep \
        --exclude-dir=vendor \
        --exclude-dir=node_modules \
        --exclude=Makefile \
        --text \
        --color \
        -nRo -E ' TODO:.*|SkipNow' .
.PHONY: todo

.DEFAULT_GOAL := build