-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yaml
145 lines (126 loc) · 4.07 KB
/
Taskfile.yaml
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
139
140
141
142
143
144
145
# This file can be run with the `task` utility: https://taskfile.dev/
version: '3'
dotenv: ['.env', '.env.local']
vars:
NPM_EXEC: 'bunx'
APP_VERSION_FILE: './lib/globals/version.go'
ENTRY_FILENAME: './main.go'
BUILD_OUTPUT_DIR: './dist'
BINARY_FILENAME: 'zeget'
DIST_TARGET_FILE: '{{.BUILD_OUTPUT_DIR}}/{{.BINARY_FILENAME}}'
GIT_COMMIT:
sh: git log -n 1 --format=%h
GOLANGCILINT_CMD_DIRS:
sh: find . -name "*.go" -printf '%h\n' | sort -u | egrep -v '^.$' | egrep -v 'tools/|test/' | tr '\n' ' ' | awk -F'|' '{ print $1 }'
tasks:
mod:
desc: Downloads and tidy Go modules
cmds:
- go mod download
- go mod tidy
test:
desc: Runs tests
cmds:
- go test -coverprofile coverprofile.out -v ./app ./lib/**
coverage:
desc: Runs tests with coverage profiling
cmds:
- go test -coverprofile coverprofile.out -v ./lib/** ./app
fmt:
desc: Formats source code & documentation
cmds:
- gofmt -l -w ./main.go ./lib/** ./app
- '{{.NPM_EXEC}} markdownlint-cli2 --fix ./*.md'
- '{{.NPM_EXEC}} markdownlint-cli2 --fix ./man/*.md'
- '{{.NPM_EXEC}} prettier --write ./*.yaml ./*.yml .github/workflows/*.yml'
build:
desc: Builds binary
preconditions:
- task: mod
- task: prepare-dist-folder
sources:
- ./lib/**/*.go
- ./app/*.go
generates:
- '{{.DIST_TARGET_FILE}}'
cmds:
- go build -trimpath -ldflags="-s -w -X main.Version={{.VERSION}}-{{.GIT_COMMIT}}" -o {{.DIST_TARGET_FILE}} {{.ENTRY_FILENAME}}
build-docs:
desc: Builds documentation
preconditions:
- which pandoc
sources:
- man/zeget.md
generates:
- zeget.1
cmds:
- pandoc man/zeget.md -s -t man -o zeget.1
build-all:
desc: Builds everything
cmds:
- task build
- task build-docs
clean:
desc: Removes all artifacts
cmds:
- task: clean-coverage
- task: clean-build
clean-build:
desc: Cleans up build artifacts
preconditions:
- test -d {{.BUILD_OUTPUT_DIR}}
- test -f {{.DIST_TARGET_FILE}}
cmds:
- rm -f {{.DIST_TARGET_FILE}}
- rm test/zeget.1 || true
- rm test/{fd,micro,nvim,pandoc,rg.exe} || true
lint:
desc: 'Lints the code with golangci-lint and optionally: actionlint, shellcheck, typos'
preconditions:
- which golangci-lint
cmds:
- golangci-lint run
- which actionlint >/dev/null && actionlint || echo "actionlint not found, skipping..."
- which shellcheck >/dev/null && shellcheck ./.custom-hooks/* || echo "shellcheck not found, skipping..."
- which typos >/dev/null && typos -v || echo "typos not found, skipping..."
update-version-file:
cmds:
- printf "package globals\n\nvar Version = \"$(go run tools/build-version.go)+src\"" > {{.APP_VERSION_FILE}}
prepare-dist-folder:
desc: Prepares dist folder
silent: true
internal: true
cmds:
- mkdir -p {{.BUILD_OUTPUT_DIR}}
status:
- test -d {{.BUILD_OUTPUT_DIR}}
ginkgo-clean:
desc: Removes all gingko-generated bootstrap files
label: ginkgo
ignore_error: true
cmds:
- sh -c '/bin/ls -1 lib | xargs printf "cd lib/%s && rm ./*_suite_test.go; cd ../..;\n " | bash'
ginkgo-bootstrap:
desc: Bootstraps ginkgo suites
label: ginkgo
ignore_error: true
generates:
- ./*_suite_test.go
- ./lib/**/*_suite_test.go
- ./app/app_suite_test.go
cmds:
- gingko bootstrap
- sh -c '/bin/ls -1 lib | xargs printf "cd lib/%s && ginkgo bootstrap; cd ../..;\n " | bash'
- sh -c 'cd app && ginkgo bootstrap; cd ..'
# remove all coverageprofile.out files:
clean-coverage:
desc: Removes all coverageprofile.out files
cmds:
- find . -name 'coverage*.out' -delete
autobuild:
interactive: true
desc: Watches for changes and automatically rebuilds the project binary, displays a minimal system notification on start/finish
preconditions:
- which watchexec
cmds:
- watchexec --exts go --fs-events create,modify,remove -N --debounce 300 -w ./app -w ./lib -- task build -f