-
Notifications
You must be signed in to change notification settings - Fork 0
203 lines (181 loc) · 6.35 KB
/
pr-build.yaml
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
name: pr-build
on:
pull_request:
types:
- opened
- synchronize
- reopened
permissions: {}
jobs:
lint-chart:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 #v3.5
with:
version: v3.4.0
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: 3.7
- name: Set up chart-testing
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
- name: Run chart-testing (lint)
run: ct lint --target-branch=master --chart-dirs chart --check-version-increment=false
lint:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
- name: Setup Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: 1.22.3
- name: fmt
run: make fmt
- name: vet
run: make vet
- name: lint
run: make lint
- name: Check if working tree is dirty
run: |
if [[ $(git diff --stat) != '' ]]; then
git --no-pager diff
echo 'run make test and commit changes'
exit 1
fi
build:
runs-on: ubuntu-latest
outputs:
profiles: ${{ steps.profiles.outputs.profiles }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
- name: Setup Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: 1.22.3
- name: Run tests
run: make test
- name: Build binary
run: make build
- name: Send go coverage report
uses: shogo82148/actions-goveralls@785c9d68212c91196d3994652647f8721918ba11 # v1.9.0
with:
path-to-profile: coverage.out
- name: Check if working tree is dirty
run: |
if [[ $(git diff --stat) != '' ]]; then
git --no-pager diff
echo 'run make test and commit changes'
exit 1
fi
- name: Build container image
run: |
make docker-build
- name: Create image tarball
run: |
docker save ghcr.io/doodlescheduling/saml-exporter:latest --output exporter-container.tar
- name: Upload image
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: exporter-container
path: exporter-container.tar
- id: profiles
name: Determine test profiles
run: |
profiles=$(ls config/tests/cases | jq -R -s -c 'split("\n")[:-1]')
echo $profiles
echo "profiles=$profiles" >> $GITHUB_OUTPUT
test-chart:
runs-on: ubuntu-latest
needs:
- build
- lint-chart
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 #v3.5
with:
version: v3.4.0
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: 3.7
- name: Set up chart-testing
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
- name: Create kind cluster
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0
- name: Download exporter container
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: exporter-container
path: /tmp
- name: Load image
run: |
docker load --input /tmp/exporter-container.tar
docker tag ghcr.io/doodlescheduling/saml-exporter:latest ghcr.io/doodlescheduling/saml-exporter:0.0.0
docker image ls -a
kind load docker-image ghcr.io/doodlescheduling/saml-exporter:0.0.0 --name chart-testing
- name: Run chart-testing (install)
run: ct install --target-branch=master --chart-dirs chart
e2e-tests:
runs-on: ubuntu-latest
needs:
- build
strategy:
matrix:
profile: ${{ fromJson(needs.build.outputs.profiles) }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
- name: Download exporter container
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: exporter-container
path: /tmp
- name: Load image
run: |
docker load --input /tmp/exporter-container.tar
docker image ls -a
- name: Setup Kubernetes
uses: engineerd/setup-kind@aa272fe2a7309878ffc2a81c56cfe3ef108ae7d0 #v0.5.0
with:
version: v0.17.0
- name: Setup Kustomize
uses: imranismail/setup-kustomize@2ba527d4d055ab63514ba50a99456fc35684947f # v2.1.0
- name: Run test
run: |
make kind-test TEST_PROFILE=${{ matrix.profile }}
- name: Debug failure
if: failure()
run: |
kubectl -n saml-system get pods
kubectl -n saml-system get pods -o yaml
kubectl -n kube-system get pods
kubectl -n saml-system logs deploy/saml-exporter