-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathTaskfile.yml
166 lines (148 loc) · 5.06 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
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
version: '3'
# if a task is referenced multiple times, only run it once
run: once
# configure bash to recursively expand **
shopt: [globstar]
vars:
SRC_DIR:
sh: 'realpath {{default "." .SRC_DIR}}'
BUILD_ROOT:
sh: 'realpath {{default ".build" .BUILD_ROOT}}'
_MOD:
# top level shopt doesn't appear to apply to sh. ** matches symlinks,
# meaning src/go/k8s will list the operator twice, not great for all our
# test scripts. We use grep to filter out anything starting with s. For
# whatever reason, grep resolves to /usr/bin/grep when run in this way so
# -P is out.
sh: shopt -s globstar; dirname $(ls **/go.mod | grep -o '^[^s].*')
PKG: './...'
MOD: '{{default ._MOD .MOD}}'
includes:
build: taskfiles/build.yml
charts: taskfiles/charts.yml
ci: taskfiles/ci.yml
dev: taskfiles/dev.yml
goreleaser: taskfiles/goreleaser.yml
k8s: taskfiles/k8s.yml
tasks:
lint:
desc: "Lint all go code and helm charts"
cmds:
- for:
var: MOD
cmd: cd {{.ITEM}} && golangci-lint run --timeout 28m {{.PKG}} {{.CLI_ARGS}}
- ct lint --chart-dirs ./charts --check-version-increment=false --all
lint-fix:
desc: "equivalent to task lint -- --fix"
cmds:
- task: lint
vars:
CLI_ARGS: "--fix"
mod:tidy:
desc: "Runs go mod tidy on all go modules in this repo"
# This isn't the most accurate check as any new imports in go files may
# require go mod tidy to get re-run. Builds will fail and CI will always
# re-run this task, so some false negatives are acceptable.
sources:
- ./**/go.mod
- ./**/go.sum
cmds:
- for:
var: MOD
cmd: go mod tidy -C {{.ITEM}}
fmt:
desc: "gofumpt all go code"
cmds:
- gofumpt -w ./
generate:
desc: "[re]generate all generated files"
cmds:
- task: mod:tidy
- task: charts:generate
# update-licenses may update licenses/boilerplate.go.txt which is used
# for _some_ of k8s:generate. For simplicity, we just run update-licenses
# twice.
- task: dev:update-licenses
- task: k8s:generate
- task: dev:update-licenses
- task: generate:third-party-licenses-list
- task: generate:changelog
- task: generate:buildkite-pipelines
- nix fmt # Ensure flake.nix has been formatted.
generate:buildkite-pipelines:
deps:
- build:gen
cmds:
- gen pipeline testsuite > .buildkite/testsuite.yml
generate:third-party-licenses-list:
dir: operator
method: checksum
generates:
- ../licenses/third_party.md
sources:
- ./go.mod
- ./go.sum
cmds:
# Our own packages should not be reported as third party license
# The example.com/example depedency is ignored as it's part of the
# gotohelm test suite (visit ./pkg/gotohelm/testdata/src/example/go.mod)
- |
go-licenses report ./... --template ../licenses/third_party.md.tpl \
--ignore buf.build/gen/go/redpandadata \
--ignore example.com/example \
--ignore github.com/redpanda-data/common-go \
--ignore github.com/redpanda-data/console/backend \
--ignore github.com/redpanda-data/redpanda \
--ignore github.com/redpanda-data/redpanda-operator > ../licenses/third_party.md
generate:changelog:
generates:
- charts/*/CHANGELOG.md
- operator/CHANGELOG.md
sources:
- ./.changes/**/*.md
- ./.changes/**/*.yaml
cmds:
- changie merge -u '## Unreleased' # Ensure CHANGELOG.mds are up to date.
build:
cmds:
- task: build:binaries
build:binaries:
cmds:
# TODO(chrisseto): Ditch goreleaser in favor of just go build in task
# files. We're not using it for anything other than an arch build matrix.
- task: goreleaser:build-operator-binaries
build:images:
cmds:
- task: k8s:build-operator-images
test:unit:
desc: "Run all unit tests (~5m)"
vars:
GO_TEST_RUNNER: '{{default "go test" .GO_TEST_RUNNER}}'
cmds:
# NB: xargs is used here in favor of taskfile's for as it allows parent
# tasks to utilizing xargs' templating (%).
- echo "{{.MOD}}" | xargs -t -I % {{.GO_TEST_RUNNER}} -C % {{.CLI_ARGS}} {{.PKG}}
test:integration:
desc: "Run all integration tests (~90m)"
cmds:
- task: test:unit
vars:
GO_TEST_RUNNER:
ref: .GO_TEST_RUNNER
CLI_ARGS: '{{.CLI_ARGS}} -run "^TestIntegration" -timeout 35m -tags integration'
test:acceptance:
desc: "Run all acceptance tests (~90m)"
vars:
GO_TEST_RUNNER: '{{default "go test" .GO_TEST_RUNNER}}'
CLI_ARGS: '{{.CLI_ARGS}} -tags=acceptance -run "^TestAcceptance" -timeout 20m -v'
cmds:
- task: k8s:build-operator-images
- kind delete cluster --name acceptance || true
- kind create cluster --name acceptance
- defer: kind delete cluster --name acceptance
- kind load --name acceptance docker-image localhost/redpanda-operator:dev localhost/configurator:dev
- task: test:unit
vars:
GO_TEST_RUNNER:
ref: .GO_TEST_RUNNER
CLI_ARGS: '{{.CLI_ARGS}} -run "^TestAcceptance" -timeout 35m -tags acceptance'