Marvin Preuss
1d4ae27878
All checks were successful
continuous-integration/drone/push Build is passing
109 lines
3.0 KiB
Makefile
109 lines
3.0 KiB
Makefile
# Copyright 2020 Enrico Hoffmann
|
|
# Copyright 2021 Adam Chalkley
|
|
#
|
|
# https://github.com/atc0005/go-teams-notify
|
|
#
|
|
# Licensed under the MIT License. See LICENSE file in the project root for
|
|
# full license information.
|
|
|
|
# REFERENCES
|
|
#
|
|
# https://github.com/golangci/golangci-lint#install
|
|
# https://github.com/golangci/golangci-lint/releases/latest
|
|
|
|
SHELL = /bin/bash
|
|
|
|
BUILDCMD = go build -mod=vendor ./...
|
|
GOCLEANCMD = go clean -mod=vendor ./...
|
|
GITCLEANCMD = git clean -xfd
|
|
CHECKSUMCMD = sha256sum -b
|
|
|
|
.DEFAULT_GOAL := help
|
|
|
|
##########################################################################
|
|
# Targets will not work properly if a file with the same name is ever
|
|
# created in this directory. We explicitly declare our targets to be phony
|
|
# by making them a prerequisite of the special target .PHONY
|
|
##########################################################################
|
|
|
|
.PHONY: help
|
|
## help: prints this help message
|
|
help:
|
|
@echo "Usage:"
|
|
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
|
|
|
|
.PHONY: lintinstall
|
|
## lintinstall: install common linting tools
|
|
# https://github.com/golang/go/issues/30515#issuecomment-582044819
|
|
lintinstall:
|
|
@echo "Installing linting tools"
|
|
|
|
@export PATH="${PATH}:$(go env GOPATH)/bin"
|
|
|
|
@echo "Explicitly enabling Go modules mode per command"
|
|
(cd; GO111MODULE="on" go get honnef.co/go/tools/cmd/staticcheck)
|
|
|
|
@echo Installing latest stable golangci-lint version per official installation script ...
|
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin
|
|
golangci-lint --version
|
|
|
|
@echo "Finished updating linting tools"
|
|
|
|
.PHONY: linting
|
|
## linting: runs common linting checks
|
|
linting:
|
|
@echo "Running linting tools ..."
|
|
|
|
@echo "Running go vet ..."
|
|
@go vet -mod=vendor $(shell go list -mod=vendor ./... | grep -v /vendor/)
|
|
|
|
@echo "Running golangci-lint ..."
|
|
@golangci-lint run
|
|
|
|
@echo "Running staticcheck ..."
|
|
@staticcheck $(shell go list -mod=vendor ./... | grep -v /vendor/)
|
|
|
|
@echo "Finished running linting checks"
|
|
|
|
.PHONY: gotests
|
|
## gotests: runs go test recursively, verbosely
|
|
gotests:
|
|
@echo "Running go tests ..."
|
|
@go test -v -mod=vendor ./...
|
|
@echo "Finished running go tests"
|
|
|
|
.PHONY: goclean
|
|
## goclean: removes local build artifacts, temporary files, etc
|
|
goclean:
|
|
@echo "Removing object files and cached files ..."
|
|
@$(GOCLEANCMD)
|
|
|
|
.PHONY: clean
|
|
## clean: alias for goclean
|
|
clean: goclean
|
|
|
|
.PHONY: gitclean
|
|
## gitclean: WARNING - recursively cleans working tree by removing non-versioned files
|
|
gitclean:
|
|
@echo "Removing non-versioned files ..."
|
|
@$(GITCLEANCMD)
|
|
|
|
.PHONY: pristine
|
|
## pristine: run goclean and gitclean to remove local changes
|
|
pristine: goclean gitclean
|
|
|
|
.PHONY: all
|
|
# https://stackoverflow.com/questions/3267145/makefile-execute-another-target
|
|
## all: run all applicable build steps
|
|
all: clean build
|
|
@echo "Completed build process ..."
|
|
|
|
.PHONY: build
|
|
## build: ensure that packages build
|
|
build:
|
|
@echo "Building packages ..."
|
|
|
|
$(BUILDCMD)
|
|
|
|
@echo "Completed build tasks"
|