This repository has been archived by the owner on Mar 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
289 lines (246 loc) · 8.38 KB
/
ci.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
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
287
288
289
---
name: CI
on:
push:
branches:
- main
tags:
- v[0-9]+.[0-9]+.[0-9]+*
pull_request:
permissions:
contents: read
packages: write
checks: write
pull-requests: write
jobs:
check:
name: Check
timeout-minutes: 10
if: github.event_name == 'pull_request'
strategy:
fail-fast: false
matrix:
go-version: [1.21.x]
may-fail: [false]
continue-on-error: ${{ matrix.may-fail }}
runs-on: ubuntu-latest
env:
GOPRIVATE: github.com/percona,github.com/percona/percona-everest-backend,github.com/percona/everest-operator
steps:
- name: Configure git for private modules
env:
ROBOT_TOKEN: ${{ secrets.ROBOT_TOKEN }}
run: git config --global url."https://percona-platform-robot:${ROBOT_TOKEN}@github.com".insteadOf "https://github.com"
- name: Set up Go release
if: matrix.go-version != 'tip'
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Set up Go tip
if: matrix.go-version == 'tip'
run: |
git clone --depth=1 https://go.googlesource.com/go $HOME/gotip
cd $HOME/gotip/src
./make.bash
echo "GOROOT=$HOME/gotip" >> $GITHUB_ENV
echo "$HOME/gotip/bin" >> $GITHUB_PATH
- name: Set GO_VERSION environment variable
run: |
go version
echo "GO_VERSION=$(go version)" >> $GITHUB_ENV
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
lfs: true
ref: ${{ github.event.pull_request.head.sha }}
- name: Enable Go modules cache
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ matrix.os }}-go-${{ matrix.go-version }}-modules-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ matrix.os }}-go-${{ matrix.go-version }}-modules-
- name: Enable Go build cache
uses: actions/cache@v3
with:
path: ~/.cache/go-build
key: ${{ matrix.os }}-go-${{ matrix.go-version }}-build-${{ github.ref }}-${{ hashFiles('**') }}
restore-keys: |
${{ matrix.os }}-go-${{ matrix.go-version }}-build-${{ github.ref }}-
${{ matrix.os }}-go-${{ matrix.go-version }}-build-
- name: Download Go modules
run: go mod download
- name: Install tools
run: make init
- name: Run linters
uses: reviewdog/action-golangci-lint@v2
with:
github_token: ${{ secrets.ROBOT_TOKEN || secrets.GITHUB_TOKEN }}
go_version: ${{ matrix.go-version }}
reporter: github-pr-review
fail_on_error: true
cache: false
golangci_lint_flags: "-c=.golangci.yml"
- name: Check that there are no source code changes
run: |
make format
pushd tools && go mod tidy -v
popd && go mod tidy -v
git status
git diff --exit-code
- name: Run debug commands on failure
if: ${{ failure() }}
run: |
env
go version
go env
pwd
git status
test:
name: Tests
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
go-version: [1.21.x]
env:
GO_VERSION: ${{ matrix.go-version }}
GOPRIVATE: github.com/percona,github.com/percona/percona-everest-backend,github.com/percona/everest-operator
steps:
- name: Configure git for private modules
env:
ROBOT_TOKEN: ${{ secrets.ROBOT_TOKEN }}
run: git config --global url."https://percona-platform-robot:${ROBOT_TOKEN}@github.com".insteadOf "https://github.com"
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go release
if: env.GO_VERSION != 'tip'
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Set up Go tip
if: matrix.go-version == 'tip'
run: |
git clone --depth=1 https://go.googlesource.com/go $HOME/gotip
cd $HOME/gotip/src
./make.bash
echo "GOROOT=$HOME/gotip" >> $GITHUB_ENV
echo "$HOME/gotip/bin" >> $GITHUB_PATH
echo "$GOBIN" >> $GITHUB_PATH
- name: Enable Go modules cache
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-modules-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}-modules-
- name: Download Go modules
run: go mod download
- name: Build
run: make build
- name: Run tests
run: make test-cover
- name: Upload coverage results
uses: codecov/codecov-action@v3
with:
file: cover.out
fail_ci_if_error: false
- name: Run debug commands on failure
if: ${{ failure() }}
run: |
env
go version
go env
pwd
git status
integration_tests:
name: CLI Integration Tests
runs-on: ubuntu-20.04
env:
# no `-mod=readonly` to test PRs made by @dependabot;
# `git diff --exit-code` step below still checks what we need
GOPRIVATE: github.com/percona,github.com/percona/percona-everest-backend,github.com/percona/everest-operator
PERCONA_VERSION_SERVICE_URL: https://check-dev.percona.com/versions/v1
steps:
- name: Configure git for private modules
env:
ROBOT_TOKEN: ${{ secrets.ROBOT_TOKEN }}
run: git config --global url."https://percona-platform-robot:${ROBOT_TOKEN}@github.com".insteadOf "https://github.com"
- name: Set up Go release
uses: percona-platform/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Set GO_VERSION environment variable
run: |
go version
echo "GO_VERSION=$(go version)" >> $GITHUB_ENV
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
lfs: true
ref: ${{ github.event.pull_request.head.sha }}
- name: Enable Go modules cache
uses: percona-platform/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ matrix.os }}-go-${{ matrix.go-version }}-modules-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ matrix.os }}-go-${{ matrix.go-version }}-modules-
- name: Enable Go build cache
uses: percona-platform/cache@v3
with:
path: ~/.cache/go-build
key: ${{ matrix.os }}-go-${{ matrix.go-version }}-build-${{ github.ref }}-${{ hashFiles('**') }}
restore-keys: |
${{ matrix.os }}-go-${{ matrix.go-version }}-build-${{ github.ref }}-
${{ matrix.os }}-go-${{ matrix.go-version }}-build-
- name: Checkout Everest backend repo
uses: actions/checkout@v4
with:
token: ${{ secrets.ROBOT_TOKEN }}
repository: percona/percona-everest-backend
ref: 'main'
path: percona-everest-backend
- name: Run Everest backend
working-directory: percona-everest-backend
run: |
make local-env-up
make run-debug &
- name: Build CLI binary
run: |
make init
make build
- name: Create KIND cluster
uses: helm/[email protected]
- name: Configure git for private modules
env:
ROBOT_TOKEN: ${{ secrets.ROBOT_TOKEN }}
run: git config --global url."https://percona-platform-robot:${ROBOT_TOKEN}@github.com".insteadOf "https://github.com"
- name: Run integration tests
working-directory: cli-tests
id: cli-tests
run: |
make init
make install-operators
make test-cli
- name: Attach the report
if: ${{ always() && steps.cli-tests.outcome != 'skipped' }}
uses: actions/upload-artifact@v3
with:
name: cli-tests-report
path: cli-tests/test-report
integration_tests_flows:
strategy:
fail-fast: false
matrix:
make_target: [
'test-all-operators',
'test-mongo-operator',
'test-pg-operator',
'test-pxc-operator'
]
name: CLI tests
uses: ./.github/workflows/cli-tests.yml
secrets: inherit
with:
make_target: ${{ matrix.make_target }}