-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathTaskfile.yml
More file actions
200 lines (172 loc) · 7.47 KB
/
Copy pathTaskfile.yml
File metadata and controls
200 lines (172 loc) · 7.47 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
version: "3"
vars:
TARGET: ./cmd/betteralign
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'
GOSENTRY: '{{.GOSENTRY | default "/usr/local/bin/gosentry"}}'
GRAMMAR: '{{.GRAMMAR | default "false"}}'
GRAMMAR_FLAGS: '--use-grammar --grammar=golang-nautilus-grammar.json'
LIBAFL_FLAGS: '{{.LIBAFL_FLAGS | default "--use-libafl --focus-on-new-code=false --catch-races=false --catch-leaks=false"}}{{if eq .GRAMMAR "true"}} {{.GRAMMAR_FLAGS}}{{end}}'
FUZZTIME: '{{.FUZZTIME | default "3600s"}}'
CLEAN: '{{.CLEAN | default "false"}}'
env:
CGO_ENABLED: 0
NEWPATH: "{{.GOPATH}}/bin:{{.PATH}}"
tasks:
default:
desc: Run update + build (default action when invoked as `task` with no args).
cmds:
- task: update
- task: build
update:
desc: Update Go dependencies (go get -u on module + CLI, then go mod tidy).
cmds:
- go get -u
- go get -u ./cmd/betteralign
- go mod tidy
check:
desc: List Go modules that have newer major versions available (via gomajor).
cmds:
- gomajor list
fmt:
desc: Format Go sources with gci (import grouping) and gofumpt (stricter gofmt).
cmds:
- gci write .
- gofumpt -l -w .
generate:
desc: Regenerate match_generated.go (DFA matcher for generated-file comments), then format.
cmds:
- PATH={{.NEWPATH}} rec -import=unicode/utf8 -pkg betteralign -matchstringutf8=reGeneratedBy '^//\s*Code generated by .* DO NOT EDIT\.$$' > match_generated.go
- task: fmt
test:
desc: Run all Go tests with verbose output.
cmds:
- go test -v ./...
build:
desc: Build the betteralign CLI with release ldflags (static, stripped, version-stamped, PGO).
cmds:
- task: generate
- go build -trimpath -pgo=auto -ldflags="-s -w -extldflags '-static' -X main.Version={{.GIT_LAST_TAG}}{{.GIT_MODIFIED}} -X main.Commit={{.GIT_HEAD_COMMIT}} -X main.Date={{.BUILD_DATE}}" -o {{.TARGET}} ./cmd/betteralign
build-debug:
desc: Build with -race and CGO_ENABLED=1 after running update + generate + fmt.
env:
CGO_ENABLED: 1
cmds:
- task: update
- task: generate
- go build -ldflags="-X main.Version={{.GIT_LAST_TAG}}{{.GIT_MODIFIED}} -X main.Commit={{.GIT_HEAD_COMMIT}} -X main.Date={{.BUILD_DATE}}" -race -o {{.TARGET}} ./cmd/betteralign
lint:
desc: Run golangci-lint (5m timeout) after regenerate + format.
cmds:
- task: generate
- golangci-lint run --timeout 5m
release:
desc: Cut a release via goreleaser (parallelism 4).
cmds:
- goreleaser release --clean -p 4
fuzz-optimalorder:
desc: 'Run native FuzzOptimalOrder. Override: task fuzz-optimalorder FUZZTIME=2h (default 3600s). CLEAN=true clears the coverage cache first.'
cmds:
- task: _clean-fuzz
- go test -run='^$' -fuzz=^FuzzOptimalOrder$ -fuzztime={{.FUZZTIME}} .
fuzz-gcsizes:
desc: 'Run native FuzzGCSizes. Override: task fuzz-gcsizes FUZZTIME=2h (default 3600s). CLEAN=true clears the coverage cache first.'
cmds:
- task: _clean-fuzz
- go test -run='^$' -fuzz=^FuzzGCSizes$ -fuzztime={{.FUZZTIME}} .
fuzz-decoratefileidentity:
desc: 'Run native FuzzDecorateFileIdentity. Override: task fuzz-decoratefileidentity FUZZTIME=2h (default 3600s). CLEAN=true clears the coverage cache first.'
cmds:
- task: _clean-fuzz
- go test -run='^$' -fuzz=^FuzzDecorateFileIdentity$ -fuzztime={{.FUZZTIME}} ./internal/dstmin
fuzz-decoratefilereorder:
desc: 'Run native FuzzDecorateFileReorder. Override: task fuzz-decoratefilereorder FUZZTIME=2h (default 3600s). CLEAN=true clears the coverage cache first.'
cmds:
- task: _clean-fuzz
- go test -run='^$' -fuzz=^FuzzDecorateFileReorder$ -fuzztime={{.FUZZTIME}} ./internal/dstmin
fuzz-decoratefilereorderall:
desc: 'Run native FuzzDecorateFileReorderAll. Override: task fuzz-decoratefilereorderall FUZZTIME=2h (default 3600s). CLEAN=true clears the coverage cache first.'
cmds:
- task: _clean-fuzz
- go test -run='^$' -fuzz=^FuzzDecorateFileReorderAll$ -fuzztime={{.FUZZTIME}} ./internal/dstmin
fuzz-commentrun:
desc: 'Run native FuzzCommentRun. Override: task fuzz-commentrun FUZZTIME=2h (default 3600s). CLEAN=true clears the coverage cache first.'
cmds:
- task: _clean-fuzz
- go test -run='^$' -fuzz=^FuzzCommentRun$ -fuzztime={{.FUZZTIME}} ./internal/dstmin
fuzz-generatedbymatcher:
desc: 'Run native FuzzGeneratedByMatcher. Override: task fuzz-generatedbymatcher FUZZTIME=2h (default 3600s). CLEAN=true clears the coverage cache first.'
cmds:
- task: _clean-fuzz
- go test -run='^$' -fuzz=^FuzzGeneratedByMatcher$ -fuzztime={{.FUZZTIME}} .
afl-fuzz-optimalorder:
desc: 'Run FuzzOptimalOrder under gosentry/LibAFL (runs until Ctrl+C).'
env:
CGO_ENABLED: 1
cmds:
- task: _clean-fuzz-sentry
- '{{.GOSENTRY}} test -run=''^$'' -fuzz=^FuzzOptimalOrder$ {{.LIBAFL_FLAGS}} .'
afl-fuzz-gcsizes:
desc: 'Run FuzzGCSizes under gosentry/LibAFL (runs until Ctrl+C).'
env:
CGO_ENABLED: 1
cmds:
- task: _clean-fuzz-sentry
- '{{.GOSENTRY}} test -run=''^$'' -fuzz=^FuzzGCSizes$ {{.LIBAFL_FLAGS}} .'
afl-fuzz-decoratefileidentity:
desc: 'Run FuzzDecorateFileIdentity under gosentry/LibAFL (runs until Ctrl+C).'
env:
CGO_ENABLED: 1
cmds:
- task: _clean-fuzz-sentry
- '{{.GOSENTRY}} test -run=''^$'' -fuzz=^FuzzDecorateFileIdentity$ {{.LIBAFL_FLAGS}} ./internal/dstmin'
afl-fuzz-decoratefilereorder:
desc: 'Run FuzzDecorateFileReorder under gosentry/LibAFL (runs until Ctrl+C).'
env:
CGO_ENABLED: 1
cmds:
- task: _clean-fuzz-sentry
- '{{.GOSENTRY}} test -run=''^$'' -fuzz=^FuzzDecorateFileReorder$ {{.LIBAFL_FLAGS}} ./internal/dstmin'
afl-fuzz-decoratefilereorderall:
desc: 'Run FuzzDecorateFileReorderAll under gosentry/LibAFL (runs until Ctrl+C).'
env:
CGO_ENABLED: 1
cmds:
- task: _clean-fuzz-sentry
- '{{.GOSENTRY}} test -run=''^$'' -fuzz=^FuzzDecorateFileReorderAll$ {{.LIBAFL_FLAGS}} ./internal/dstmin'
afl-fuzz-commentrun:
desc: 'Run FuzzCommentRun under gosentry/LibAFL (runs until Ctrl+C).'
env:
CGO_ENABLED: 1
cmds:
- task: _clean-fuzz-sentry
- '{{.GOSENTRY}} test -run=''^$'' -fuzz=^FuzzCommentRun$ {{.LIBAFL_FLAGS}} ./internal/dstmin'
afl-fuzz-generatedbymatcher:
desc: 'Run FuzzGeneratedByMatcher under gosentry/LibAFL (runs until Ctrl+C).'
env:
CGO_ENABLED: 1
cmds:
- task: _clean-fuzz-sentry
- '{{.GOSENTRY}} test -run=''^$'' -fuzz=^FuzzGeneratedByMatcher$ {{.LIBAFL_FLAGS}} .'
_clean-fuzz:
internal: true
desc: Clear the Go fuzz coverage cache only when CLEAN=true (preserves corpus by default).
cmds:
- '{{if eq .CLEAN "true"}}go clean -fuzzcache{{else}}true{{end}}'
_clean-fuzz-sentry:
internal: true
desc: Clear the gosentry fuzz coverage cache only when CLEAN=true (preserves corpus by default).
cmds:
- '{{if eq .CLEAN "true"}}{{.GOSENTRY}} clean -fuzzcache{{else}}true{{end}}'