-
Notifications
You must be signed in to change notification settings - Fork 7
/
Taskfile.yml
126 lines (107 loc) · 2.75 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
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
version: "3"
vars:
TARGET: e-dnevnik-bot
TARGET_contrib: random_delete_test
GIT_LAST_TAG:
sh: git describe --abbrev=0 --tags 2>/dev/null || echo latest
GIT_HEAD_COMMIT:
sh: git rev-parse --short HEAD 2>/dev/null || echo unknown
GIT_TAG_COMMIT:
sh: git rev-parse --short {{.GIT_LAST_TAG}} 2>/dev/null || echo unknown
GIT_MODIFIED1:
sh: git diff {{.GIT_HEAD_COMMIT}} {{.GIT_TAG_COMMIT}} --quiet 2>/dev/null || echo .dev
GIT_MODIFIED2:
sh: git diff --quiet 2>/dev/null || echo .dirty
GIT_MODIFIED:
sh: echo "{{.GIT_MODIFIED1}}{{.GIT_MODIFIED2}}"
BUILD_DATE:
sh: date -u '+%Y-%m-%dT%H:%M:%SZ'
env:
CGO_ENABLED: 0
tasks:
default:
cmds:
- task: update
- task: build
update:
cmds:
- go get -u
- go mod tidy
update-contrib:
cmds:
- for: [contrib/delete_entries, contrib/random_delete_test]
task: update-dir
vars:
DIR: '{{.ITEM}}'
update-dir:
dir: '{{.DIR}}'
cmds:
- echo "Updating {{.DIR}}"
- go get -u
- go mod tidy
update-major:
cmds:
- gomajor list
fmt:
cmds:
- go mod tidy
- gci write .
- gofumpt -l -w .
- betteralign -apply ./...
fmt-contrib:
dir: contrib/random_delete_test
cmds:
- gci write .
- gofumpt -l -w .
- betteralign -apply ./...
build:
cmds:
- task: fmt
- go build -trimpath -pgo=auto -ldflags="-s -w -extldflags '-static' -X main.GitTag={{.GIT_LAST_TAG}} -X main.GitCommit={{.GIT_HEAD_COMMIT}} -X main.GitDirty={{.GIT_MODIFIED}} -X main.BuildTime={{.BUILD_DATE}}" -o {{.TARGET}}
build-contrib:
dir: contrib/random_delete_test
cmds:
- task: update-contrib
- task: fmt-contrib
- go build -trimpath -pgo=auto -ldflags="-s -w -extldflags '-static'" -o {{.TARGET_contrib}}
build-debug:
env:
CGO_ENABLED: 1
cmds:
- task: update
- task: fmt
- go build -ldflags="-X main.GitTag={{.GIT_LAST_TAG}} -X main.GitCommit={{.GIT_HEAD_COMMIT}} -X main.GitDirty={{.GIT_MODIFIED}} -X main.BuildTime={{.BUILD_DATE}}" -race -o {{.TARGET}}
lint:
cmds:
- task: fmt
- golangci-lint run --timeout 5m
lint-nil:
cmds:
- task: fmt
- nilaway ./...
tools:
cmds:
- task: gofumpt
- task: gci
- task: betteralign
release:
cmds:
- echo "Uses Github Actions"
gci:
internal: true
status:
- which gci
cmds:
- go install github.com/daixiang0/gci@latest
gofumpt:
internal: true
status:
- which gofumpt
cmds:
- go install mvdan.cc/gofumpt@latest
betteralign:
internal: true
status:
- which betteralign
cmds:
- go install github.com/dkorunic/betteralign/cmd/betteralign@latest