Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
122 lines (105 loc) · 3.11 KB
/
Copy pathTaskfile.yml
File metadata and controls
122 lines (105 loc) · 3.11 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
version: '3'
vars:
BIN_DIR: ./bin
CLI_BIN: '{{.BIN_DIR}}/argus'
GO: go
MODULE: github.com/sentiolabs/argus
VERSION:
sh: git describe --tags --always --dirty 2>/dev/null || echo dev
COMMIT:
sh: git rev-parse --short HEAD 2>/dev/null || echo none
BUILD_DATE:
sh: date -u '+%Y-%m-%dT%H:%M:%SZ'
LDFLAGS: >-
-s -w
-X {{.MODULE}}/cmd.Version={{.VERSION}}
-X {{.MODULE}}/cmd.Commit={{.COMMIT}}
-X {{.MODULE}}/cmd.BuildDate={{.BUILD_DATE}}
tasks:
default:
desc: Show available tasks
cmds:
- task --list
silent: true
build:
desc: Build the argus binary into ./bin
cmds:
- mkdir -p {{.BIN_DIR}}
- '{{.GO}} build -ldflags="{{.LDFLAGS}}" -o {{.CLI_BIN}} .'
run:
desc: Build and run argus sync in dry-run mode
cmds:
- task: build
- '{{.CLI_BIN}} sync --dry-run'
test:
desc: Run unit tests with race detection and coverage
cmds:
- '{{.GO}} test -race -cover ./...'
test:verbose:
desc: Run unit tests with verbose output
cmds:
- '{{.GO}} test -race -cover -v ./...'
test:coverage:
desc: Run unit tests and write an HTML coverage report
cmds:
- '{{.GO}} test -race -coverprofile=coverage.out ./...'
- '{{.GO}} tool cover -html=coverage.out -o coverage.html'
- 'echo "Coverage report: coverage.html"'
lint:
desc: Run golangci-lint
cmds:
- golangci-lint run
lint:fix:
desc: Run golangci-lint with auto-fix
cmds:
- golangci-lint run --fix
fmt:
desc: Format Go sources
cmds:
- '{{.GO}} fmt ./...'
release:snapshot:
desc: Build a release snapshot locally with goreleaser (no tag required)
cmds:
- goreleaser release --snapshot --clean
check:versions:
desc: Assert mise.toml and go.mod agree on the Go version
silent: true
cmds:
- cmd: |
mise_go="$(grep -E '^go[[:space:]]*=' mise.toml | head -1 | sed -E 's/.*"([^"]+)".*/\1/')"
mod_go="$(grep -E '^go ' go.mod | head -1 | awk '{print $2}')"
if [ -z "$mise_go" ] || [ -z "$mod_go" ]; then
echo "ERROR: could not read Go version (mise.toml='$mise_go' go.mod='$mod_go')" >&2
exit 1
fi
if [ "$mise_go" != "$mod_go" ]; then
echo "ERROR: Go version mismatch: mise.toml=$mise_go, go.mod=$mod_go" >&2
echo "Update mise.toml to match go.mod." >&2
exit 1
fi
echo "Go version aligned: $mod_go"
verify:
desc: Build, then validate the argus config
cmds:
- task: build
- '{{.CLI_BIN}} config validate'
version:
desc: Build, then print version information
cmds:
- task: build
- '{{.CLI_BIN}} version'
install:
desc: Install argus into GOPATH/bin with version ldflags
cmds:
- '{{.GO}} install -ldflags="{{.LDFLAGS}}" .'
clean:
desc: Remove build artifacts and coverage reports
cmds:
- rm -rf {{.BIN_DIR}} dist
- rm -f coverage.out coverage.html
ci:
desc: Run the local CI pipeline (version guard, tests, lint)
cmds:
- task: check:versions
- task: test
- task: lint