/
Taskfile.yml
87 lines (71 loc) · 1.86 KB
/
Taskfile.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# https://taskfile.dev
version: '3'
silent: true
vars:
GO_MODULE: github.com/kazhuravlev/structspec
GO_FILES:
sh: find . -type f -name '*.go' -not -path "./.gocache/*" -not -path "./.go/*" -not -path "_generated.go" | tr "\n" " "
TOOL_BIN_DIR: ./bin/tools
GOBIN:
sh: "echo `pwd`/{{ .TOOL_BIN_DIR }}"
TOOL_LINT_SRC: github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2
TOOL_LINT: ./{{ .TOOL_BIN_DIR }}/golangci-lint
TOOL_OPTIONS_GEN_SRC: github.com/kazhuravlev/options-gen/cmd/options-gen@v0.28.4
TOOL_OPTIONS_GEN: ./{{ .TOOL_BIN_DIR }}/options-gen
tasks:
default:
cmds:
- task --list-all
check:
desc: Run all project checks
cmds:
- echo "- Run all routines"
- task: tidy
- task: tools:install
- task: generate
- task: fmt
- task: lint
- task: install
- task: tests
tidy:
cmds:
- echo "- Tidy"
- go mod tidy
fmt:
desc: Run code formatter
cmds:
- echo "- Format"
- go fmt ./...
tools:install:
desc: Install required tools (into local project dir)
run: once
cmds:
- echo "- Run install tools"
- rm -rf {{ .TOOL_BIN_DIR }}
- mkdir -p {{ .TOOL_BIN_DIR }}
- export GOBIN="{{.GOBIN}}" && go install {{ .TOOL_LINT_SRC }}
- export GOBIN="{{.GOBIN}}" && go install {{ .TOOL_OPTIONS_GEN_SRC }}
generate:
desc: Generate code
env:
SEARCH_BIN_PATH:
sh: "echo `pwd`/{{ .TOOL_BIN_DIR }}:$PATH"
cmds:
- echo "- Generate code"
- PATH=$SEARCH_BIN_PATH && go generate ./...
lint:
desc: Run linter
deps:
- "tools:install"
cmds:
- echo "- Lint"
- "{{ .TOOL_LINT }} run --fix ./..."
install:
run: once
cmds:
- echo "- Install"
- go install ./cmd/structspec
tests:
cmds:
- echo "- Tests"
- go test -race -count 1 ./...