Repository navigation
286 lines (254 loc) · 10.3 KB
/
Copy pathtest.yml
File metadata and controls
286 lines (254 loc) · 10.3 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
name: Test
on:
push:
branches:
- main
pull_request:
jobs:
test:
runs-on: ubuntu-latest
env:
CGO_ENABLED: 1
steps:
- name: Checkout code
uses: actions/checkout@v6.1.0
with:
# TestNewSpecsHaveVersions reads the previous release tag.
fetch-depth: 0
- name: Free disk space if low
uses: $/.github/actions/free-disk-space-if-low
- name: Install Go
uses: $/.github/actions/setup-go
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libzmq3-dev
- name: Install Task
uses: $/.github/actions/setup-task
- name: Deps
run: task deps && git diff HEAD -- go.mod go.sum && git diff-index HEAD --exit-code
- name: Test
run: task test
# Generates the reference docs with every component and lints every config
# snippet. A job of its own, so it runs alongside the unit tests.
docs:
runs-on: ubuntu-latest
env:
CGO_ENABLED: 1
steps:
- name: Checkout code
uses: actions/checkout@v6.1.0
with:
# TestNewSpecsHaveVersions reads the release tags.
fetch-depth: 0
- name: Free disk space if low
uses: $/.github/actions/free-disk-space-if-low
- name: Install Go
uses: $/.github/actions/setup-go
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libzmq3-dev
- name: Install Task
uses: $/.github/actions/setup-task
- name: Docs
run: CGO_ENABLED=1 TAGS=x_benthos_extra task docs
- name: Check that task docs left tracked files unchanged
run: test -z "$(git ls-files --others --modified --exclude-standard)" || { >&2 echo "task docs changed tracked files, such as internal/plugins/info.csv. Run 'CGO_ENABLED=1 TAGS=x_benthos_extra task docs' and commit the result (see docs/README.md)."; git status --short >&2; exit 1; }
# The docs check below builds the docs site with this tree.
- name: Upload the generated docs
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4.6.2
with:
name: connect-docs-head
path: docs/modules
retention-days: 7
# The same tree at the PR's merge base, so the docs check can list the
# published pages this PR changes. Generated here rather than taken from a
# main build: main may have moved on since the PR branched.
docs-base:
if: >-
github.event_name == 'pull_request' &&
!github.event.pull_request.draft &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
env:
CGO_ENABLED: 1
steps:
- name: Checkout code
uses: actions/checkout@v6.1.0
with:
fetch-depth: 0
# The docs job builds the merge commit GitHub made for this PR, so build
# its first parent: the exact base that merge commit was made from. The
# merge base of the branch would also pull in every docs change that
# reached main after the branch was cut, and pull_request.base.sha can lag
# the commit GitHub actually merged into.
- name: Check out the base of the merge commit
run: |
if [ "$(git rev-list --parents -n 1 HEAD | wc -w)" -ne 3 ]; then
echo "::error::HEAD is not a two-parent merge commit in this checkout"
exit 1
fi
git checkout --quiet HEAD^1
# Pull requests only restore, so this job restores the main cache for CGO_ENABLED=1. Both test and docs save
# to that key, so it holds the build of whichever job finished first.
- name: Install Go
uses: $/.github/actions/setup-go
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libzmq3-dev
- name: Generate the reference docs
run: go run -tags x_benthos_extra ./cmd/tools/docs_gen
- name: Upload the generated docs
uses: actions/upload-artifact@v4.6.2
with:
name: connect-docs-base
path: docs/modules
retention-days: 7
# Whether this PR changes the generated docs at all. When it doesn't, it
# can't change or break a published page, so docs-check is skipped.
docs-changed:
needs: [docs, docs-base]
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.compare.outputs.changed }}
steps:
- uses: actions/download-artifact@v4.3.0
with:
name: connect-docs-head
path: head
- uses: actions/download-artifact@v4.3.0
with:
name: connect-docs-base
path: base
- name: Compare the generated docs with the merge base
id: compare
run: |
if diff -rq base head > diff.txt; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "The generated docs are identical to the merge base's, so the docs check is skipped." >> "$GITHUB_STEP_SUMMARY"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "$(wc -l < diff.txt) generated files differ from the merge base."
fi
# Builds the Connect docs with this PR's generated tree and checks the
# result: Antora errors, broken anchors, and unconverted markup on the
# pages the PR changes block. When the PR changes a published page, it
# comments with the changed pages and a preview link, and asks the docs
# team to review. See docs/README.md.
docs-check:
needs: [docs, docs-base, docs-changed]
if: needs.docs-changed.outputs.changed == 'true'
permissions:
contents: read
id-token: write
statuses: write
pull-requests: write
uses: redpanda-data/docs-extensions-and-macros/.github/workflows/connect-docs-check.yml@560c4301d2f98c2e5e158daa70fa2d3760859bda # v5.55.0
with:
docs_artifact: connect-docs-head
base_docs_artifact: connect-docs-base
aws_region: ${{ vars.RP_AWS_CRED_REGION }}
aws_role_name_prefix: ${{ vars.RP_AWS_CRED_BASE_ROLE_NAME }}
secrets:
aws_cred_account_id: ${{ secrets.RP_AWS_CRED_ACCOUNT_ID }}
golangci-lint:
runs-on: ubuntu-latest
env:
CGO_ENABLED: 0
steps:
- name: Checkout code
uses: actions/checkout@v6.1.0
- name: Install Go
uses: $/.github/actions/setup-go
- name: Set version env variables
run: cat .versions >> $GITHUB_ENV
- name: Lint
uses: golangci/golangci-lint-action@v9.3.0
with:
version: "v${{env.GOLANGCI_LINT_VERSION}}"
args: "--timeout=30m cmd/... internal/... public/..."
skip-cache: true
skip-save-cache: true
test-benchmarking:
# The benchmarking harness lives in standalone Go modules
# (benchmarking/aws and benchmarking/aws/cleanup-lambda) so its AWS SDK
# deps stay out of the published root module — which also makes it
# invisible to the root `task test` / lint / tidy checks above. This job
# is its gate: tests, tidy drift, and lint for both modules.
runs-on: ubuntu-latest
env:
CGO_ENABLED: 0
steps:
- name: Checkout code
uses: actions/checkout@v6.1.0
# Use a separate cache key. With the default key (root go.sum), this job saves first, and test and
# golangci-lint then restore a cache without the root module's build output.
- name: Install Go
uses: actions/setup-go@v6.5.0
with:
go-version-file: 'benchmarking/aws/go.mod'
cache-dependency-path: 'benchmarking/aws/**/go.sum'
- name: Deps
run: |
(cd benchmarking/aws && go mod tidy)
(cd benchmarking/aws/cleanup-lambda && go mod tidy)
git diff HEAD -- 'benchmarking/aws/go.*' 'benchmarking/aws/cleanup-lambda/go.*'
git diff-index HEAD --exit-code -- 'benchmarking/aws/go.*' 'benchmarking/aws/cleanup-lambda/go.*'
# -race because the code under test is genuinely concurrent (workload
# goroutine, mid-run emit loop, mutex-guarded fakes). It needs cgo, so
# these two steps override the job-level CGO_ENABLED=0 (which the lint
# steps below still want).
- name: Test benchmarking/aws
working-directory: benchmarking/aws
env:
CGO_ENABLED: 1
run: go test -race -timeout 8m -shuffle=on ./...
- name: Test cleanup-lambda
working-directory: benchmarking/aws/cleanup-lambda
env:
CGO_ENABLED: 1
run: go test -race -timeout 8m -shuffle=on ./...
- name: Set version env variables
run: cat .versions >> $GITHUB_ENV
- name: Lint benchmarking/aws
uses: golangci/golangci-lint-action@v9.3.0
with:
version: "v${{env.GOLANGCI_LINT_VERSION}}"
args: "--timeout=15m"
working-directory: benchmarking/aws
skip-cache: true
skip-save-cache: true
- name: Lint cleanup-lambda
uses: golangci/golangci-lint-action@v9.3.0
with:
version: "v${{env.GOLANGCI_LINT_VERSION}}"
args: "--timeout=15m"
working-directory: benchmarking/aws/cleanup-lambda
skip-cache: true
skip-save-cache: true
test-push-to-gcp-ar:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6.1.0
- name: Set up test packages
run: |
touch /tmp/test.rpm
touch /tmp/test.deb
- name: Mock gcloud CLI
run: |
printf '#!/bin/bash\necho "gcloud $*"\n' \
| sudo tee /usr/local/bin/gcloud > /dev/null
sudo chmod +x /usr/local/bin/gcloud
- name: Test RPM GA — routed to redpanda-yum
run: |
out=$(./resources/scripts/push_pkg_to_gcp_ar.sh /tmp/test.rpm 1.0.0)
echo "$out"
echo "$out" | grep -q "artifacts yum upload redpanda-yum"
- name: Test RPM RC — routed to redpanda-unstable-yum
run: |
out=$(./resources/scripts/push_pkg_to_gcp_ar.sh /tmp/test.rpm 1.0.0-rc1)
echo "$out"
echo "$out" | grep -q "artifacts yum upload redpanda-unstable-yum"
- name: Test DEB — routed to redpanda-apt
run: |
out=$(./resources/scripts/push_pkg_to_gcp_ar.sh /tmp/test.deb 1.0.0)
echo "$out"
echo "$out" | grep -q "artifacts apt upload redpanda-apt"