-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathTaskfile.yml
181 lines (164 loc) · 6.11 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
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}}'
TIMESTAMP: # Timestamp used for any build artifacts.
# MacOS' man page isn't helpful. https://man7.org/linux/man-pages/man1/date.1.html
# Roughly ISO 8601
sh: date -u '+%Y-%m-%dT%T:%SZ'
COMMIT: # The commit to bake into any build artifacts.
sh: git rev-parse HEAD
# Version stamps for baking into build artifacts and use as tags.
# `git describe --dirty` can generate 1 of 4 outputs:
# 1. v0.0.0 - HEAD is tagged as v0.0.0 and no changes are in the index.
# 2. v0.0.0-dirty - HEAD is tagged as v0.0.0 and there are changes in the index.
# 3. v0.0.0-<N>-g<commit> - HEAD is at <commit> which is N commits away from v0.0.0; no changes in index.
# 4. v0.0.0-<N>-g<commit>-dirty - HEAD is at <commit> which is N commits away from v0.0.0; changes in index.
# `--tags` is required to match tags with `/`'s in them which we have due to go modules' tagging conventions.
# `--match` is used to target tags that apply to a specific module.
# `--always` is a fallback to print out the commit if no tag is found.
# `sed` is used to trim off the qualifying parts of the tag so we just get the "version".
OPERATOR_VERSION:
sh: git describe --dirty --tags --match 'v*' --match 'operator/v*' | sed 's#^operator/##'
OPERATOR_CHART_VERSION:
# NB: OPERATOR_CHART_VERSION is currently only used for the operator chart's nightly releases.
sh: git describe --dirty --tags --match 'charts/operator/v*' --always | sed 's#^charts/operator/##'
includes:
build: taskfiles/build.yml
charts: taskfiles/charts.yml
ci: taskfiles/ci.yml
dev: taskfiles/dev.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:operator
build:image:
aliases:
- build:images
cmds:
- task: build:operator-image
vars:
CLI_ARGS: '--load {{.CLI_ARGS}}'
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: build:image
- kind load docker-image localhost/redpanda-operator:dev
- task: test:unit
vars:
GO_TEST_RUNNER:
ref: .GO_TEST_RUNNER
CLI_ARGS: '{{.CLI_ARGS}} -run "^TestAcceptance" -timeout 35m -tags acceptance'