88 - reopened
99
1010jobs :
11- e2e :
11+ lint-chart :
1212 runs-on : ubuntu-latest
1313 steps :
14+ - name : Harden Runner
15+ uses : step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
16+ with :
17+ egress-policy : audit
18+ - name : Checkout
19+ uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
20+ with :
21+ fetch-depth : 0
22+
23+ - name : Set up Helm
24+ uses : azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
25+ with :
26+ version : v3.4.0
27+
28+ - uses : actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
29+ with :
30+ python-version : 3.7
31+
32+ - name : Set up chart-testing
33+ uses : helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
34+
35+ - name : Run chart-testing (list-changed)
36+ id : list-changed
37+ run : |
38+ changed=$(ct list-changed --target-branch=master --chart-dirs chart)
39+ if [[ -n "$changed" ]]; then
40+ echo "::set-output name=changed::true"
41+ fi
42+ - name : Run chart-testing (lint)
43+ run : ct lint --target-branch=master --chart-dirs chart --check-version-increment=false
44+
45+ fmt :
46+ runs-on : ubuntu-latest
47+ steps :
48+ - name : Harden Runner
49+ uses : step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
50+ with :
51+ egress-policy : audit
1452 - name : Checkout
15- uses : actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
53+ uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
1654 - name : Setup Go
17- uses : actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5 .0
55+ uses : actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1 .0
1856 with :
1957 go-version : 1.20.x
2058 - name : Restore Go cache
21- uses : actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
59+ uses : actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
2260 with :
2361 path : ~/go/pkg/mod
2462 key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
@@ -30,14 +68,68 @@ jobs:
3068 run : make vet
3169 - name : lint
3270 run : make lint
33- - name : test
34- run : make test
71+ - name : Check if working tree is dirty
72+ run : |
73+ if [[ $(git diff --stat) != '' ]]; then
74+ git --no-pager diff
75+ echo 'run <make test> and commit changes'
76+ exit 1
77+ fi
78+
79+ test :
80+ runs-on : ubuntu-latest
81+ strategy :
82+ matrix :
83+ kubernetes-version :
84+ - " 1.25"
85+ - " 1.26"
86+ - " 1.27"
87+ - " 1.28"
88+ steps :
89+ - name : Harden Runner
90+ uses : step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
91+ with :
92+ egress-policy : audit
93+ - name : Checkout
94+ uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
95+ - name : Setup Go
96+ uses : actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
97+ with :
98+ go-version : 1.20.x
99+ - name : Restore Go cache
100+ uses : actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
101+ with :
102+ path : ~/go/pkg/mod
103+ key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
104+ restore-keys : |
105+ ${{ runner.os }}-go-
106+ - name : run test
107+ run : make test ENVTEST_K8S_VERSION=${{ matrix.kubernetes-version }}
108+
109+ build :
110+ runs-on : ubuntu-latest
111+ outputs :
112+ profiles : ${{ steps.profiles.outputs.matrix }}
113+ steps :
114+ - name : Harden Runner
115+ uses : step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
116+ with :
117+ egress-policy : audit
118+ - name : Checkout
119+ uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
120+ - name : Setup Go
121+ uses : actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
122+ with :
123+ go-version : 1.20.x
124+ - name : Restore Go cache
125+ uses : actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
126+ with :
127+ path : ~/go/pkg/mod
128+ key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
129+ restore-keys : |
130+ ${{ runner.os }}-go-
35131 - name : build
36132 run : make build
37- - name : Send go coverage report
38- uses : shogo82148/actions-goveralls@31ee804b8576ae49f6dc3caa22591bc5080e7920 # v1.6.0
39- with :
40- path-to-profile : coverage.out
41133 - name : Check if working tree is dirty
42134 run : |
43135 if [[ $(git diff --stat) != '' ]]; then
@@ -48,24 +140,106 @@ jobs:
48140 - name : Build container image
49141 run : |
50142 make docker-build
143+ - name : Create image tarball
144+ run : |
145+ docker save --output prometheuspatch-controller-container.tar prometheuspatch-controller:latest
146+ - name : Upload image
147+ uses : actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
148+ with :
149+ name : prometheuspatch-controller-container
150+ path : prometheuspatch-controller-container.tar
151+ - id : profiles
152+ name : Determine test profiles
153+ run : |
154+ profiles=$(ls config/tests/cases | jq -R -s -c 'split("\n")[:-1]')
155+ echo $profiles
156+ echo "::set-output name=matrix::$profiles"
157+
158+ e2e-tests :
159+ runs-on : ubuntu-latest
160+ needs :
161+ - build
162+ strategy :
163+ matrix :
164+ profile : ${{ fromJson(needs.build.outputs.profiles) }}
165+ steps :
166+ - name : Harden Runner
167+ uses : step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
168+ with :
169+ egress-policy : audit
170+ - name : Checkout
171+ uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
172+ - name : Setup Go
173+ uses : actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
174+ with :
175+ go-version : 1.20.x
51176 - name : Setup Kubernetes
52177 uses : engineerd/setup-kind@aa272fe2a7309878ffc2a81c56cfe3ef108ae7d0 # v0.5.0
53178 with :
54179 version : v0.17.0
55- - name : Load test image
56- run : kind load docker-image k8sprom-patch-controller:latest
57- - name : Deploy controller
58- run : make deploy
59- - name : Setup prometheus
60- run : bash -e ./scripts/e2e/setup-prometheus.sh
61- - name : Run k8sprom-patch-controller tests
62- run : bash -e ./scripts/e2e/test.sh
180+ - name : Download prometheuspatch-controller container
181+ uses : actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
182+ with :
183+ name : prometheuspatch-controller-container
184+ path : /tmp
185+ - name : Load images
186+ run : |
187+ docker load --input /tmp/prometheuspatch-controller-container.tar
188+ docker image ls -a
189+ - name : Setup Kustomize
190+ uses : imranismail/setup-kustomize@6691bdeb1b0a3286fb7f70fd1423c10e81e5375f # v2.0.0
191+ - name : Run test
192+ run : |
193+ make kind-test TEST_PROFILE=${{ matrix.profile }}
63194 - name : Debug failure
64195 if : failure()
65196 run : |
66197 kubectl -n kube-system describe pods
67- kubectl -n prometheus get pods
68- kubectl -n k8sprom-patch-system describe pods
69- kubectl -n k8sprom-patch-system get all
70- kubectl -n k8sprom-patch-system logs deploy/k8sprom-patch-controller
71- kubectl -n default get prometheuspatchrules -o yaml
198+ kubectl -n prometheuspatch-system describe pods
199+ kubectl -n prometheuspatch-system get all
200+ kubectl -n prometheuspatch-system logs deploy/prometheuspatch-controller
201+ kubectl -n prometheuspatch-system get prometheuspatchrule -o yaml
202+
203+ test-chart :
204+ runs-on : ubuntu-latest
205+ needs :
206+ - build
207+ - lint-chart
208+ steps :
209+ - name : Harden Runner
210+ uses : step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
211+ with :
212+ egress-policy : audit
213+ - name : Checkout
214+ uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
215+ with :
216+ fetch-depth : 0
217+
218+ - name : Set up Helm
219+ uses : azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
220+
221+ - uses : actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
222+ with :
223+ python-version : 3.7
224+
225+ - name : Set up chart-testing
226+ uses : helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
227+
228+ - name : Create kind cluster
229+ uses : helm/kind-action@dda0770415bac9fc20092cacbc54aa298604d140 # v1.8.0
230+
231+ - name : Download prometheuspatch-controller container
232+ uses : actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
233+ with :
234+ name : prometheuspatch-controller-container
235+ path : /tmp
236+
237+ - name : Load image
238+ run : |
239+ docker load --input /tmp/prometheuspatch-controller-container.tar
240+ docker tag prometheuspatch-controller:latest ghcr.io/doodlescheduling/prometheuspatch-controller:v0.0.0
241+ kind load docker-image ghcr.io/doodlescheduling/prometheuspatch-controller:v0.0.0 --name chart-testing
242+ docker image ls -a
243+
244+ - name : Run chart-testing (install)
245+ run : ct install --target-branch=master --chart-dirs chart
0 commit comments