forked from CrunchyData/postgres-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (172 loc) · 7.07 KB
/
test.yaml
File metadata and controls
193 lines (172 loc) · 7.07 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
name: Tests
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
go-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.x
- run: make check
- run: make check-generate
kubernetes-api:
runs-on: ubuntu-latest
needs: [go-test]
strategy:
fail-fast: false
matrix:
kubernetes: ["1.19.2"] # TODO(benjaminjb)(issue sc-11672): bump to 1.20.2 or higher after we update controller-runtime
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with: { go-version: 1.x }
- run: go mod download
- run: ENVTEST_K8S_VERSION="${KUBERNETES#default}" make check-envtest
env:
KUBERNETES: "${{ matrix.kubernetes }}"
GO_TEST: go test --coverprofile 'envtest.coverage' --coverpkg ./internal/...
# Upload coverage to GitHub
- run: gzip envtest.coverage
- uses: actions/upload-artifact@v3
with:
name: "~coverage~kubernetes-api=${{ matrix.kubernetes }}"
path: envtest.coverage.gz
retention-days: 1
kubernetes-k3d:
runs-on: ubuntu-latest
needs: [go-test]
strategy:
fail-fast: false
matrix:
kubernetes: [latest, v1.20]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with: { go-version: 1.x }
- name: Start k3s
uses: ./.github/actions/k3d
with:
k3s-channel: "${{ matrix.kubernetes }}"
prefetch-images: |
registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi8-13.6-1
registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:ubi8-2.38-0
registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:ubi8-1.16-2
- run: make createnamespaces check-envtest-existing
env:
PGO_TEST_TIMEOUT_SCALE: 1.2
GO_TEST: go test --coverprofile 'envtest-existing.coverage' --coverpkg ./internal/...
# Upload coverage to GitHub
- run: gzip envtest-existing.coverage
- uses: actions/upload-artifact@v3
with:
name: "~coverage~kubernetes-k3d=${{ matrix.kubernetes }}"
path: envtest-existing.coverage.gz
retention-days: 1
kuttl-k3d:
runs-on: ubuntu-latest
needs: [go-test]
strategy:
fail-fast: false
matrix:
kubernetes: [latest]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with: { go-version: 1.x }
- name: Start k3s
uses: ./.github/actions/k3d
with:
k3s-channel: "${{ matrix.kubernetes }}"
prefetch-images: |
registry.developers.crunchydata.com/crunchydata/crunchy-pgadmin4:ubi8-4.30-2
registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:ubi8-2.38-2
registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:ubi8-1.16-4
registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi8-14.4-0
registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi8-14.4-3.1-0
- run: go mod download
- name: Build coverage executable
run: |
make build-postgres-operator \
GO_BUILD='go test -c --tags main_with_coverage --trimpath --coverpkg ./internal/...' \
PGO_VERSION='${{ github.sha }}-coverage'
# Start a Docker container with the working directory mounted.
- name: Start PGO
run: |
kubectl apply --server-side -k ./config/namespace
kubectl apply --server-side -k ./config/dev
hack/create-kubeconfig.sh postgres-operator pgo
docker run --detach --network host --read-only \
--volume "$(pwd):/mnt" --workdir '/mnt' --env 'PATH=/mnt/bin' \
--env 'KUBECONFIG=hack/.kube/postgres-operator/pgo' \
--env 'RELATED_IMAGE_PGADMIN=registry.developers.crunchydata.com/crunchydata/crunchy-pgadmin4:ubi8-4.30-2' \
--env 'RELATED_IMAGE_PGBACKREST=registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:ubi8-2.38-2' \
--env 'RELATED_IMAGE_PGBOUNCER=registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:ubi8-1.16-4' \
--env 'RELATED_IMAGE_POSTGRES_14=registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi8-14.4-0' \
--env 'RELATED_IMAGE_POSTGRES_14_GIS_3.1=registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi8-14.4-3.1-0' \
--name 'postgres-operator' ubuntu \
postgres-operator --test.coverprofile 'kuttl.coverage'
- run: make tools/kuttl
- run: make generate-kuttl
env:
KUTTL_PG_VERSION: '14'
KUTTL_POSTGIS_VERSION: '3.1'
KUTTL_PSQL_IMAGE: 'registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi8-14.4-0'
- run: |
make check-kuttl && exit
failed=$?
echo '::group::PGO logs'; docker logs 'postgres-operator'; echo '::endgroup::'
exit $failed
env:
KUTTL_TEST: hack/tools/kuttl test --test='(cluster-start|pgbackrest-restore|pgbouncer)' --timeout=180 --parallel=1
- name: Stop PGO
run: docker stop 'postgres-operator' || true
# Upload coverage to GitHub
- run: gzip kuttl.coverage
- uses: actions/upload-artifact@v3
with:
name: "~coverage~kuttl-k3d=${{ matrix.kubernetes }}"
path: kuttl.coverage.gz
retention-days: 1
coverage-report:
if: ${{ success() || contains(needs.*.result, 'success') }}
runs-on: ubuntu-latest
needs:
- kubernetes-api
- kubernetes-k3d
- kuttl-k3d
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with: { go-version: 1.x }
- uses: actions/download-artifact@v3
with: { path: download }
# Combine the coverage profiles by taking the mode line from any one file
# and the data from all files. Write a list of functions with less than
# 100% coverage to the job summary, and upload a complete HTML report.
- name: Generate report
run: |
gunzip --keep download/*/*.gz
( sed -e '1q' download/*/*.coverage
tail -qn +2 download/*/*.coverage ) > total.coverage
go tool cover --func total.coverage -o total-coverage.txt
go tool cover --html total.coverage -o total-coverage.html
awk < total-coverage.txt '
END { print "<details><summary>Total Coverage: <code>" $3 " " $2 "</code></summary>" }
' >> "${GITHUB_STEP_SUMMARY}"
sed < total-coverage.txt -e '/100.0%/d' -e "s,$(go list -m)/,," | column -t | awk '
NR == 1 { print "\n\n```" } { print } END { if (NR > 0) print "```\n\n"; print "</details>" }
' >> "${GITHUB_STEP_SUMMARY}"
# Upload coverage to GitHub
- run: gzip total-coverage.html
- uses: actions/upload-artifact@v3
with:
name: coverage-report=html
path: total-coverage.html.gz
retention-days: 15