-
Notifications
You must be signed in to change notification settings - Fork 0
235 lines (201 loc) · 5.77 KB
/
tests.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
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
name: unit-and-e2e-tests
on:
push:
branches:
- "**"
paths-ignore:
- "*.md"
- LICENSE
- docker-compose*
- .dockerignore
#- .github/
- .gitignore
- .gitmodules
- docs/
- hack/
- Makefile
- PROJECT
pull_request:
branches:
- "!dependabot/**"
env:
go_version: '1.23'
artifact_name: kubernetes-namespace-permission-manager
artifact_bin_name: kubebuilder
IMG: tagesspiegel/kubernetes-namespace-permission-manager:dev
jobs:
vetting:
name: vetting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
ref: ${{ github.ref }}
- uses: actions/setup-go@v5
with:
go-version: ${{ env.go_version }}
- name: vetting
shell: bash
run: go vet ./...
linting:
name: linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
ref: ${{ github.ref }}
- uses: actions/setup-go@v5
with:
go-version: ${{ env.go_version }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
args: --timeout=3m --issues-exit-code=1 ./...
only-new-issues: true
unit-tests:
name: unit tests
runs-on: ubuntu-latest
needs:
- vetting
- linting
env:
LOG_DIR: logs
FORMATTED_LOG_FOLDER_NAME: ""
steps:
- name: Install go ${{ env.go_version }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.go_version }}
- name: Checkout code
uses: actions/checkout@v4
- name: Run unit tests
run: make test
prepare-bin:
name: prepare-bin
runs-on: ubuntu-latest
needs:
- vetting
- linting
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download binaries
run: |
make kustomize controller-gen envtest
- name: Upload bin directory
uses: actions/upload-artifact@v4
with:
name: ${{ env.artifact_bin_name }}
path: bin/
retention-days: 1
build-temp-image:
name: build docker image
runs-on: ubuntu-latest
needs:
- vetting
- linting
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build image
run: |
make docker-build
- name: Save image
run: |
make docker-save
- name: Upload image
uses: actions/upload-artifact@v4
with:
name: ${{ env.artifact_name }}
path: manager.tar
retention-days: 1
end-to-end-tests:
name: e2e tests
runs-on: ubuntu-latest
needs:
- vetting
- linting
- build-temp-image
- prepare-bin
env:
KUBERNETES_NAMESPACE: kubernetes-namespace-permission-manager-system
strategy:
fail-fast: false
matrix:
kind_node_image:
- kindest/node:v1.30.0
- kindest/node:v1.29.4
- kindest/node:v1.28.9
- kindest/node:v1.27.13
- kindest/node:v1.26.15
steps:
- name: Install go ${{ env.go_version }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.go_version }}
- uses: azure/setup-helm@v4
with:
version: 'latest'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: ${{ env.artifact_name }}
- uses: actions/download-artifact@v4
with:
name: ${{ env.artifact_bin_name }}
path: bin/
- run: |
sudo chown -R $USER:$USER bin/
sudo chmod -R a+rwx bin/
- name: Load image
run: |
make docker-load
- name: Create K8s Kind Cluster
uses: helm/[email protected]
with:
node_image: ${{ matrix.kind_node_image }}
cluster_name: kubernetes-namespace-permission-manager-e2e
- name: Load image into kind cluster
run: |
kind load docker-image ${{ env.IMG }} --name kubernetes-namespace-permission-manager-e2e
- name: Install Prometheus Operator CRDs
run: |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install prometheus-operator-crds prometheus-community/prometheus-operator-crds
- name: Deploy operator
run: |
make install
make deploy
- name: Wait and check operator is running
run: |
sleep 20
kubectl get pods -n ${{ env.KUBERNETES_NAMESPACE }}
- name: Get operator logs
if: always()
run: |
kubectl logs --tail 10000 -n ${{ env.KUBERNETES_NAMESPACE }} $(kubectl get pods -n ${{ env.KUBERNETES_NAMESPACE }} | grep kubernetes-namespace-permission-manager-controller-manager | awk '{print $1}') -c manager
- name: Describe operator pod
if: always()
run: |
kubectl describe pod -n ${{ env.KUBERNETES_NAMESPACE }} $(kubectl get pods -n ${{ env.KUBERNETES_NAMESPACE }} | grep kubernetes-namespace-permission-manager-controller-manager | awk '{print $1}')
- name: Run e2e tests
run: |
make test-e2e
- name: Get operator logs
if: always()
run: |
kubectl logs --tail 10000 -n ${{ env.KUBERNETES_NAMESPACE }} $(kubectl get pods -n ${{ env.KUBERNETES_NAMESPACE }} | grep kubernetes-namespace-permission-manager-controller-manager | awk '{print $1}') -c manager