Skip to content

Commit b6eab4f

Browse files
committed
chore: add Makefile and linters configuration
1 parent 4dced3d commit b6eab4f

File tree

4 files changed

+127
-0
lines changed

4 files changed

+127
-0
lines changed

.golangci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
run:
2+
timeout: 5m
3+
modules-download-mode: readonly
4+
5+
linters:
6+
enable:
7+
- errorlint
8+
- errcheck
9+
- gofmt
10+
- goimports
11+
- gosec
12+
- gosimple
13+
- govet
14+
- ineffassign
15+
- misspell
16+
- revive
17+
- staticcheck
18+
- typecheck
19+
- unconvert
20+
- unused
21+
22+
issues:
23+
exclude-use-default: false
24+
# mempool and indexer code is borrowed from Tendermint
25+
exclude-dirs:
26+
- mempool
27+
- state/indexer
28+
- state/txindex
29+
- third_party
30+
include:
31+
- EXC0012 # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments
32+
- EXC0014 # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments
33+
34+
linters-settings:
35+
gosec:
36+
excludes:
37+
- G115
38+
revive:
39+
rules:
40+
- name: package-comments
41+
disabled: true
42+
- name: duplicated-imports
43+
severity: warning
44+
- name: exported
45+
arguments:
46+
- disableStutteringCheck
47+
48+
goimports:
49+
local-prefixes: github.com/rollkit

.markdownlint.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
default: true
2+
MD010:
3+
code_blocks: false
4+
MD013: false
5+
MD024:
6+
allow_different_nesting: true

.yamllint.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
# Built from docs https://yamllint.readthedocs.io/en/stable/configuration.html
3+
extends: default
4+
5+
rules:
6+
# 120 chars should be enough, but don't fail if a line is longer
7+
line-length:
8+
max: 120
9+
level: warning

Makefile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Define pkgs, run, and cover vairables for test so that we can override them in
2+
# the terminal more easily.
3+
pkgs := $(shell go list ./...)
4+
run := .
5+
count := 1
6+
7+
## help: Show this help message
8+
help: Makefile
9+
@echo " Choose a command run in "$(PROJECTNAME)":"
10+
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
11+
.PHONY: help
12+
13+
## clean: clean testcache
14+
clean:
15+
@echo "--> Clearing testcache"
16+
@go clean --testcache
17+
.PHONY: clean
18+
19+
## cover: generate to code coverage report.
20+
cover:
21+
@echo "--> Generating Code Coverage"
22+
@go install github.com/ory/go-acc@latest
23+
@go-acc -o coverage.txt $(pkgs)
24+
.PHONY: cover
25+
26+
## deps: Install dependencies
27+
deps:
28+
@echo "--> Installing dependencies"
29+
@go mod download
30+
# @make proto-gen
31+
@go mod tidy
32+
.PHONY: deps
33+
34+
## lint: Run linters golangci-lint and markdownlint.
35+
lint: vet
36+
@echo "--> Running golangci-lint"
37+
@golangci-lint run
38+
@echo "--> Running markdownlint"
39+
@markdownlint --config .markdownlint.yaml '**/*.md'
40+
@echo "--> Running yamllint"
41+
@yamllint --no-warnings . -c .yamllint.yml
42+
43+
.PHONY: lint
44+
45+
## fmt: Run fixes for linters. Currently only markdownlint.
46+
fmt:
47+
@echo "--> Formatting markdownlint"
48+
@markdownlint --config .markdownlint.yaml '**/*.md' -f
49+
@echo "--> Formatting go"
50+
@golangci-lint run --fix
51+
.PHONY: fmt
52+
53+
## vet: Run go vet
54+
vet:
55+
@echo "--> Running go vet"
56+
@go vet $(pkgs)
57+
.PHONY: vet
58+
59+
## test: Running unit tests
60+
test: vet
61+
@echo "--> Running unit tests"
62+
@go test -v -race -covermode=atomic -coverprofile=coverage.txt $(pkgs) -run $(run) -count=$(count)
63+
.PHONY: test

0 commit comments

Comments
 (0)