-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
156 lines (150 loc) · 5.05 KB
/
Copy pathTaskfile.yml
File metadata and controls
156 lines (150 loc) · 5.05 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
# https://taskfile.dev
version: "3"
env:
CGO_ENABLED: "0"
vars:
GOLANGCI_LINT_VERSION: 2.13.2
GOVULNCHECK_VERSION: 1.7.0
MARKDOWNLINT_VERSION: 0.23.3
GREMLINS_VERSION: 0.6.0
FUZZTIME: 30s
COVERAGE_FLOOR: 95
# A clean openai/codex checkout, for the Codex parity oracle.
CODEX_REPO: '{{.CODEX_REPO | default (print .HOME "/projects/codex-repo")}}'
ORACLE: '{{.ROOT_DIR}}/bin/codex-apply-patch'
tasks:
install:gofumpt:
status:
- which gofumpt
preconditions:
- sh: which go
msg: "please, install go"
cmds:
# https://github.com/mvdan/gofumpt
- go install mvdan.cc/gofumpt@latest
install:golangci-lint:
status:
- test -f ./bin/golangci-lint
- ./bin/golangci-lint --version | grep -F '{{.GOLANGCI_LINT_VERSION}}'
cmds:
# https://golangci-lint.run/welcome/install/#binaries
- >
curl -sSfL
https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh
| sh -s -- -b ./bin v{{.GOLANGCI_LINT_VERSION}}
install:govulncheck:
status:
- which govulncheck
- "govulncheck --version | grep -Fx 'Scanner: govulncheck@v{{.GOVULNCHECK_VERSION}}'"
cmds:
- go install golang.org/x/vuln/cmd/govulncheck@v{{.GOVULNCHECK_VERSION}}
install:gremlins:
status:
- test -f ./bin/gremlins
cmds:
- GOBIN={{.ROOT_DIR}}/bin go install github.com/go-gremlins/gremlins/cmd/gremlins@v{{.GREMLINS_VERSION}}
format:
desc: run all code formatters
cmds:
- task: install:gofumpt
- gofumpt -w .
- go mod edit -fmt
- go mod tidy
lint:golangci-lint:
cmds:
- task: install:golangci-lint
- ./bin/golangci-lint run --timeout 120s
lint:govulncheck:
cmds:
- task: install:govulncheck
- govulncheck ./...
lint:mod:
desc: check that go.mod is tidy
cmds:
- go mod tidy -diff
lint:markdown:
preconditions:
- sh: which npx
msg: "please, install node"
cmds:
- npx --yes markdownlint-cli2@{{.MARKDOWNLINT_VERSION}} "**/*.md"
lint:
desc: run all linters
cmds:
- task: lint:golangci-lint
- task: lint:govulncheck
- task: lint:mod
- task: lint:markdown
test:
desc: run all tests with the race detector, including the recorded Codex parity corpus
env:
CGO_ENABLED: "1" # the race detector needs cgo
cmds:
- go test {{ .CLI_ARGS | default "-race -count=1 -cover -timeout 300s ./..." }}
test:cover:
desc: write coverage.out, print coverage per function, and fail below COVERAGE_FLOOR
cmds:
- go test -count=1 -coverprofile=coverage.out ./...
- go tool cover -func=coverage.out
- >
go tool cover -func=coverage.out | awk -v floor={{.COVERAGE_FLOOR}}
'/^total:/ { sub("%", "", $3); if ($3 + 0 < floor) { print "coverage " $3 "% is below " floor "%"; exit 1 } }'
fuzz:
desc: run each fuzz target for FUZZTIME (for example FUZZTIME=5m)
cmds:
- for: [FuzzStrict, FuzzCodex, FuzzApplyFiles]
cmd: go test -run '^$' -fuzz '^{{.ITEM}}$' -fuzztime {{.FUZZTIME}} .
mutation:
desc: run mutation testing and list surviving mutants to review (no threshold)
cmds:
- task: install:gremlins
- ./bin/gremlins unleash --workers 8 --timeout-coefficient 5 .
bench:
desc: run the benchmarks
cmds:
- go test -run '^$' -bench . -benchmem .
doc:
desc: print the package documentation as pkg.go.dev will show it
cmds:
- go doc -all .
parity:oracle:
desc: build the Codex apply_patch binary from CODEX_REPO as the parity oracle
preconditions:
- sh: test -d {{.CODEX_REPO}}/codex-rs/apply-patch
msg: "set CODEX_REPO to an openai/codex checkout"
- sh: which cargo
msg: "please, install rust"
cmds:
- >
cd {{.CODEX_REPO}}/codex-rs &&
CARGO_NET_GIT_FETCH_WITH_CLI=true CARGO_TARGET_DIR={{.ROOT_DIR}}/bin/codex-target
cargo build --locked --release -p codex-apply-patch --bin apply_patch
- cp {{.ROOT_DIR}}/bin/codex-target/release/apply_patch {{.ORACLE}}
- git -C {{.CODEX_REPO}} rev-parse HEAD > {{.ORACLE}}.commit
parity:record:
desc: rebuild the oracle and rewrite testdata/codex-parity.json from it
cmds:
- task: parity:oracle
- CODEX_APPLY_PATCH_BIN={{.ORACLE}} CODEX_REPO={{.CODEX_REPO}} go test -count=1 -run '^TestCodexParity$' -update .
parity:live:
desc: compare fresh generated cases with the oracle (PARITY_CASES, PARITY_SEED)
preconditions:
- sh: test -x {{.ORACLE}}
msg: "run task parity:oracle first"
cmds:
- CODEX_APPLY_PATCH_BIN={{.ORACLE}} go test -count=1 -run '^TestCodexParityLive$' -v -timeout 30m .
parity:upstream:
desc: pull the latest openai/codex into CODEX_REPO, re-record, and show what changed
cmds:
- git -C {{.CODEX_REPO}} pull --ff-only
- task: parity:record
- git diff --stat -- testdata/codex-parity.json
all:
desc: run all code formatters, linters, and tests
cmds:
- task: format
- task: lint
- task: test
default:
cmds:
- task: all