-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yml
110 lines (93 loc) · 2.41 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
# https://taskfile.dev
version: '3'
includes:
os: ./Taskfile_{{OS}}.yml
vars:
GIT_BRANCH:
sh: git rev-parse --abbrev-ref HEAD
GIT_COMMIT:
sh: git log -n 1 --format=%h
GIT_TAG:
sh: "git tag --points-at HEAD"
PACKAGE: github.com/endorama/devid
BIN_FILENAME: devid-{{.GIT_TAG}}-{{OS}}-{{ARCH}}{{exeExt}}
tasks:
default:
cmds:
- task: run
build:dev:
cmds:
- |
go build -ldflags="
-X {{.PACKAGE}}/internal/version.version={{.VERSION}}
-X {{.PACKAGE}}/internal/version.commit={{.GIT_COMMIT}}{{.GIT_DIRTY}}"
vars:
VERSION: "{{.GIT_BRANCH}}"
GIT_DIRTY:
sh: "[[ -z $(git status --porcelain) ]] || echo '-dirty'"
build:release:
desc: Build the project for release
cmds:
- |
go build -ldflags="-s -w
-X {{.PACKAGE}}/internal/version.version={{.GIT_TAG}}
-X {{.PACKAGE}}/internal/version.commit={{.GIT_COMMIT}}" \
-o {{.BIN_FILENAME}}
- task: "os:checksum"
- ./{{.BIN_FILENAME}} version
check:release:
desc: Perform multiple checks to ensure app is releaseable
cmds:
- task: deps
- task: go-imports
- task: fmt:check
- task: lint
- task: tests
deps:
desc: Vendor mod dependencies
cmds:
- go mod tidy
- go mod verify
deps:update:
desc: update all deps to latest version
cmds:
- echo "{{.mods}}" | xargs go get -u
vars:
mods:
sh: ag "\t" go.mod --no-color --no-numbers | ag --invert-match "indirect" | cut -d" " -f 1 | tr -d "\t" | sort
go-imports:
desc: Perform goimports
cmds:
- goimports -w -local {{.PACKAGE}} *.go cmd internal plugins test
fmt:
desc: Format go code
cmds:
- go fmt ./...
fmt:check:
desc: Check that all go files are properly formatted
cmds:
- test -z $(gofmt -l .)
lint:
desc: Lint go code
cmds:
- golangci-lint run
run:
desc: Build and run the web app
cmds:
- go run . {{.CLI_ARGS}}
env:
DEVID_PERSONAS_LOCATION: ./test/
tests:
desc: Run entire testsuite
cmds:
- go test -race {{.TEST_OPTS}} ./...
tests:coverage:
desc: Run entire testsuite
cmds:
- task: tests
vars:
TEST_OPTS: -covermode=atomic -coverprofile=coverage.out
tests:single:
desc: Run a single test, specify with RUN
cmds:
- go test -v ./... -run {{.RUN}}