-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
138 lines (123 loc) · 3.21 KB
/
Taskfile.yaml
File metadata and controls
138 lines (123 loc) · 3.21 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# This is a Taskfile. See https://taskfile.dev
# `brew install go-task` to install task runner or `go install github.com/go-task/task/v3/cmd/task@latest`
# `task --list` to list all tasks
# `task <taskname>` to run a task
version: '3'
vars:
GIT_COMMIT:
sh: git rev-parse HEAD
GIT_SHA:
sh: git rev-parse --short HEAD
GIT_BRANCH:
sh: git branch --show-current
LDFLAGS: >-
-X github.com/hilli/go-kef-w2/cmd/kefw2/cmd.Version=dev-{{.GIT_SHA}}
-X github.com/hilli/go-kef-w2/cmd/kefw2/cmd.GitCommit={{.GIT_COMMIT}}
-X github.com/hilli/go-kef-w2/cmd/kefw2/cmd.GitBranch={{.GIT_BRANCH}}
-X github.com/hilli/go-kef-w2/cmd/kefw2/cmd.BuildDate={{now | date "2006-01-02T15:04:05Z07:00"}}
tasks:
build:
desc: Build binaries
cmds:
- go build -ldflags='-s -w {{.LDFLAGS}}' -o bin/kefw2{{exeExt}} cmd/kefw2/kefw2.go
aliases: [b]
sources:
- cmd/kefw2/**/*.go
- kefw2/*.go
generates:
- bin/kefw2
vars:
GIT_COMMIT:
sh: git log -n 1 --format=%h
complete:
desc: Generate bash/zsh completion script
aliases: [c]
cmds:
- bin/kefw2 completion bash > {{.SHELL_COMP_PREFIX}}/share/bash-completion/completions/kefw2
- bin/kefw2 completion zsh > {{.SHELL_COMP_PREFIX}}/share/zsh-completions/_kefw2
sources:
- cmd/kefw2/**/*.go
- kefw2/*.go
- Taskfile.yaml
generates:
- "{{.SHELL_COMP_PREFIX}}/share/bash-completion/completions/kefw2"
- "{{.SHELL_COMP_PREFIX}}/share/zsh-completions/_kefw2"
vars:
SHELL_COMP_PREFIX:
sh: |
if [ "$(type brew)" ]; then
brew --prefix
else
mkdir -p share/bash-completion/completions
mkdir -p share/zsh-completions
echo .
fi
run:
desc: Run kefw2
aliases: [r]
cmds:
- go run -ldflags='{{.LDFLAGS}}' cmd/kefw2/kefw2.go {{.CLI_ARGS}}
all:
desc: Run all tasks (lint, build, test, complete)
aliases: [a]
silent: true
cmds:
- task lint
- task build
- task test
- task complete
clean:
desc: Clean up
aliases: [x]
silent: true
cmds:
- rm -rf bin
- rm -rf share
- rm -f coverage.out coverage.html
release-test:
desc: Run gorelease snapshot
cmds:
- goreleaser build --snapshot --clean
sources:
- cmd/kefw2/**/*.go
- kefw2/*.go
- Taskfile.yaml
lint:
desc: Run golangci-lint
aliases: [l]
cmds:
- golangci-lint run ./...
lint:fix:
desc: Run golangci-lint with auto-fix
aliases: [lf]
cmds:
- golangci-lint run --fix ./...
lint:verbose:
desc: Run golangci-lint with verbose output
aliases: [lv]
cmds:
- golangci-lint run -v ./...
test:
desc: Run tests
aliases: [t]
cmds:
- go test ./...
test:coverage:
desc: Run tests with coverage
aliases: [tc]
cmds:
- go test -coverprofile=coverage.out ./...
- go tool cover -html=coverage.out -o coverage.html
generates:
- coverage.out
- coverage.html
check:
desc: Run all checks (lint + test)
aliases: [ck]
cmds:
- task: lint
- task: test
includes:
docs:
taskfile: ./docs/Taskfile.yaml
dir: ./docs