forked from romie-gr/romie
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial Makefile * Create Makefile for Go project - Run 'make help' to see the targets. * Tools as dependencies - Introduce tools as dependencies Install golang-ci and mispell via tools pkg (tools.go). It is running via main.go (as part of go generate). This is triggered via 'make setup'. - Minor fixes in the Makefile - Run `go mod tidy` to replace the indirect modules of golang-ci and mispell Fixes #33 Fixes #20 Co-authored-by: Panagiotis Georgiadis <drpaneas@gmail.com> * Fix Makefile to work with gmake Co-authored-by: Panagiotis Georgiadis <drpaneas@gmail.com> Co-authored-by: Panagiotis Georgiadis <pgeorgia@redhat.com>
- Loading branch information
1 parent
4e90d4f
commit 2dd2b52
Showing
7 changed files
with
713 additions
and
1 deletion.
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 +1,3 @@ | ||
.vscode/ | ||
coverage.txt | ||
romie |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# This file contains all available configuration options | ||
# with their default values. | ||
|
||
# options for analysis running | ||
run: | ||
tests: true | ||
|
||
linters: | ||
enable-all: true | ||
disable: | ||
- gomnd | ||
- gocognit | ||
- goerr113 | ||
- gofumpt | ||
- gci | ||
- nlreturn |
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Global variables used later | ||
NAME=romie | ||
GOCMD=LC_ALL=C go | ||
TIMEOUT=5 | ||
|
||
# go tools | ||
export PATH := ./bin:$(PATH) | ||
export GO111MODULE := on | ||
export GOPROXY = https://proxy.golang.org,direct | ||
|
||
# go source files | ||
SRC = $(shell find . -type f -name '*.go') | ||
# The name of the executable (default is current directory name) | ||
TARGET := $(shell echo $${PWD-`pwd`}) | ||
|
||
.PHONY: all build setup fmt test cover lint ci clean todo run help | ||
|
||
## all: Default target, now is build | ||
all: build | ||
|
||
## build: Builds the binary | ||
build: | ||
@echo "Building..." | ||
@$(GOCMD) build -o ${NAME} | ||
|
||
## setup: Runs mod download and generate | ||
setup: | ||
@echo "Downloading tools and dependencies..." | ||
@$(GOCMD) mod download | ||
@$(GOCMD) generate -v ./... | ||
|
||
## fmt: Runs go goimports and go fmt | ||
fmt: setup | ||
@echo "Checking the imports..." | ||
@$(GOCMD)imports -w ${SRC} | ||
@echo "Formating the go files..." | ||
@$(GOCMD)fmt -w -s ${SRC} | ||
|
||
## test: Runs the tests with coverage | ||
test: | ||
@echo "Running tests..." | ||
@$(GOCMD) test -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt ./... -run . -timeout $(TIMEOUT)m | ||
|
||
## cover: Runs all tests and opens the coverage report in the browser | ||
cover: test | ||
@$(GOCMD) tool cover -html=coverage.txt | ||
|
||
## lint: Runs golangci-lint (configuration at .golangci.yml) and misspell | ||
lint: setup | ||
@echo "Running linters..." | ||
@golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 ./... | ||
@misspell ./... | ||
|
||
## ci: Runs steup build, test, fmt, lint | ||
ci: setup build test fmt lint | ||
|
||
## clean: Runs go clean | ||
clean: | ||
@echo "Cleaning..." | ||
@$(GOCMD) clean | ||
|
||
## todo: Shows all TODO strings with line numbers | ||
todo: | ||
@grep -I -R -n TODO * --exclude=Makefile | ||
|
||
## run: Runs go run | ||
run: build | ||
@$(GOCMD) run ${TARGET} | ||
|
||
## help: Prints this help message | ||
help: | ||
@echo "Usage:" | ||
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /' |
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,9 @@ | ||
module github.com/drpaneas/romie | ||
module romie | ||
|
||
go 1.15 | ||
|
||
require ( | ||
github.com/client9/misspell v0.3.4 | ||
github.com/golangci/golangci-lint v1.31.0 | ||
golang.org/x/tools v0.0.0-20201001230009-b5b87423c93b // indirect | ||
) |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// +build tools | ||
|
||
package tools | ||
|
||
import ( | ||
// Import golangci-lint | ||
_ "github.com/golangci/golangci-lint/cmd/golangci-lint" | ||
// Import misspell | ||
_ "github.com/client9/misspell/cmd/misspell" | ||
) |