-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathTaskfile.yml
More file actions
117 lines (100 loc) · 2.71 KB
/
Taskfile.yml
File metadata and controls
117 lines (100 loc) · 2.71 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
version: "3"
env:
INSTALL_DIR: "/usr/local/bin"
IMAGE_TAG: "gatecheck:latest"
tasks:
build:
desc: "Build the gatecheck binary"
vars:
BUILD_DATE: '{{dateInZone "2006-01-02T15:04:05Z" now "UTC"}}'
CLI_VERSION:
sh: git describe --tags || git rev-parse --short HEAD || "v0.0.0-unknown"
GIT_COMMIT:
sh: git rev-parse HEAD
GIT_DESCRIPTION:
sh: git log -1 --pretty=%B
cmds:
- mkdir -p bin
- go build -ldflags="-X 'main.cliVersion={{.CLI_VERSION}}' -X 'main.gitCommit={{.GIT_COMMIT}}' -X 'main.buildDate={{.BUILD_DATE}}' -X 'main.gitDescription={{.GIT_DESCRIPTION}}'" -o ./bin ./cmd/gatecheck
sources:
- cmd/**/*
- pkg/**/*
- go.*
generates:
- bin/gatecheck
install:
desc: "Install the gatecheck binary"
prompt: 'Install gatecheck binary to {{joinPath .INSTALL_DIR "gatecheck"}} ...Continue?'
deps:
- build
cmds:
- cp ./bin/gatecheck {{joinPath .INSTALL_DIR "gatecheck"}}
sources:
- ./bin/gatecheck
generates:
- '{{joinPath .INSTALL_DIR "gatecheck"}}'
uninstall:
desc: "Uninstall the gatecheck binary"
prompt: 'Will remove binary {{joinPath .INSTALL_DIR "gatecheck"}}'
cmds:
- rm '{{joinPath .INSTALL_DIR "gatecheck"}}'
test:
desc: "Run unit tests with coverage"
cmds:
- go test -cover ./...
lint:
desc: "Run golangci-lint in view-only mode"
cmds:
- golangci-lint run
fix:
desc: "Fix linting errors and format code"
cmds:
- golangci-lint run --fix
format:
desc: "Check code formatting"
cmds:
- |
if [ -n "$(gofmt -l .)" ]; then
gofmt -d .
exit 1
fi
coverage:
desc: "Generate test coverage"
cmds:
- go test -coverprofile=coverage.out ./...
open-coverage:
desc: "Open coverage report in browser"
deps: [coverage]
cmds:
- go tool cover -html=coverage.out
dependencies:
desc: "Download dependencies"
cmds:
- go mod download
upgrade:
desc: "Upgrade package dependencies"
preconditions:
- sh: git diff --quiet && git diff --cached --quiet
msg: "Repository is dirty, commit changes before upgrading."
cmds:
- go get -u ./...
- go mod tidy
serve-docs:
desc: "Serve documentation locally"
cmds:
- mdbook serve
all:
desc: "Run format, test, and build"
deps: [format, test, build]
release-snapshot:
desc: "Create a snapshot release"
cmds:
- goreleaser release --snapshot --rm-dist
release:
desc: "Create a release"
cmds:
- goreleaser release --rm-dist
clean:
desc: "Clean up build artifacts"
cmds:
- rm -rf ./bin coverage.out