forked from CrunchyData/postgres-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (129 loc) · 4.78 KB
/
test.yaml
File metadata and controls
141 lines (129 loc) · 4.78 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
name: Tests
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
go-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
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: [default]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
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@v2
with:
name: "kubernetes-api=${{ matrix.kubernetes }}"
path: envtest.coverage.gz
retention-days: 1
kubernetes-k3d:
if: "${{ github.repository == 'CrunchyData/postgres-operator' }}"
runs-on: ubuntu-latest
needs: [go-test]
strategy:
fail-fast: false
matrix:
kubernetes: [latest, v1.19]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with: { go-version: 1.x }
- name: Install k3d
# Git tag from https://github.com/rancher/k3d/releases or "latest"
env: { K3D_TAG: latest }
run: |
curl --fail --silent https://raw.githubusercontent.com/rancher/k3d/main/install.sh |
TAG="${K3D_TAG#latest}" bash && k3d version | head -n1
- name: Start k3s
# https://rancher.com/docs/k3s/latest/en/upgrades/basic/#release-channels
env: { K3S_CHANNEL: "${{ matrix.kubernetes }}" }
run: k3d cluster create --image="+${K3S_CHANNEL}" --no-lb --timeout=2m --wait
- name: Prefetch container images
run: |
{
echo '"registry.developers.crunchydata.com/crunchydata/crunchy-postgres:centos8-13.5-0"'
echo '"registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:centos8-2.36-0"'
echo '"registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:centos8-1.16-0"'
} |
jq --slurp --arg name 'image-prefetch' --argjson labels '{"name":"image-prefetch"}' '{
apiVersion: "apps/v1", kind: "DaemonSet",
metadata: { name: $name, labels: $labels },
spec: {
selector: { matchLabels: $labels },
template: {
metadata: { labels: $labels },
spec: {
initContainers: to_entries | map({ name: "c\(.key)", command: ["true"], image: .value }),
containers: [{ name: "pause", image: "k8s.gcr.io/pause:3.5" }]
}
}
}
}' |
kubectl create --filename=- && {
kubectl rollout status daemonset.apps/image-prefetch --timeout=90s ||
kubectl describe daemonset.apps/image-prefetch
}
- 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@v2
with:
name: "kubernetes-k3d=${{ matrix.kubernetes }}"
path: envtest-existing.coverage.gz
retention-days: 1
coverage-report:
runs-on: ubuntu-latest
needs:
- kubernetes-api
- kubernetes-k3d
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with: { go-version: 1.x }
- uses: actions/download-artifact@v2
with: { path: download }
# Combine the coverage profiles by taking the mode line from any one file
# and the data from all files. Print a list of functions with less than
# 100% coverage, 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
sed -e '/100.0%/d' -e "s,$(go list -m)/,," total-coverage.txt
awk 'END { print "::notice title=Total Coverage::" $3 " " $2 }' total-coverage.txt
# Upload coverage to GitHub
- run: gzip total-coverage.html
- uses: actions/upload-artifact@v2
with:
name: coverage-report
path: total-coverage.html.gz
retention-days: 15