This repository has been archived by the owner on Sep 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
164 lines (133 loc) · 4.61 KB
/
ci_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
name: CI-Tests
on:
push:
branches:
- main
- v[0-9]+.[0-9]+
pull_request:
branches:
- main
- v[0-9]+.[0-9]+
defaults:
run:
shell: bash
jobs:
verify-and-unit-tests:
name: Run verify and unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for all tags and branches
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
- name: Verify modules
run: go mod verify
- name: Verify format
run: |
make fmt
git diff --exit-code
- name: Verify manifests
run: |
make manifests
git diff --exit-code
- name: Verify imported manifests
run: |
make import-manifests
git diff --exit-code
- name: Verify bindata
run: |
make verify-bindata
- name: Unit and Integration Tests
run: make test
e2e-tests:
name: Run e2e tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for all tags and branches
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
- name: Download binaries
run: |
make download-binaries
- name: Create K8s KinD Cluster
run: |
kind version
make test-cluster
- name: Build and Push Test Container Image to KIND node
run: |
make docker-build IMG=localhost:5000/gatekeeper-operator:$GITHUB_SHA
kind load docker-image localhost:5000/gatekeeper-operator:$GITHUB_SHA
- name: E2E Tests
run: |
make deploy-ci NAMESPACE=mygatekeeper IMG=localhost:5000/gatekeeper-operator:$GITHUB_SHA
kubectl -n mygatekeeper wait deployment/gatekeeper-operator-controller --for condition=Available --timeout=90s
kubectl -n mygatekeeper logs deployment/gatekeeper-operator-controller -c manager -f > operator.log &
make test-e2e NAMESPACE=mygatekeeper
kubectl delete --wait namespace mygatekeeper
- name: Debug
if: ${{ failure() }}
run: |
echo "::group::Operator Logs"
cat operator.log
echo "::endgroup::"
gatekeeper-e2e-tests:
name: Run gatekeeper e2e tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: gatekeeper-operator
strategy:
matrix:
NAMESPACE: ["gatekeeper-system"]
steps:
- uses: actions/checkout@v3
with:
path: gatekeeper-operator
fetch-depth: 0 # Fetch all history for all tags and branches
- uses: actions/setup-go@v3
with:
go-version-file: gatekeeper-operator/go.mod
- name: Download binaries
run: |
make download-binaries
- name: Create K8s KinD Cluster
run: |
kind version
make test-cluster
- name: Build and Push Test Container Image to KIND node
run: |
make docker-build IMG=localhost:5000/gatekeeper-operator:$GITHUB_SHA
kind load docker-image localhost:5000/gatekeeper-operator:$GITHUB_SHA
- name: Set Up Environment Variables
run: |
GATEKEEPER_VERSION=$(awk '/^GATEKEEPER_VERSION/ {print $3}' Makefile)
echo "GATEKEEPER_VERSION=${GATEKEEPER_VERSION}" >> ${GITHUB_ENV}
# Checkout a local copy of Gatekeeper to use its bats e2e tests.
- name: Checkout Gatekeeper to verify imported manifests
uses: actions/checkout@v3
with:
repository: open-policy-agent/gatekeeper
ref: ${{ env.GATEKEEPER_VERSION }}
path: gatekeeper
fetch-depth: 0 # Fetch all history for all tags and branches
# TODO: gatekeeper-operator does not --log-mutations nor --mutation-annotations
- name: Remove unhandled gatekeeper bats tests
run: |
sed -i -e '67,71d;80,83d' /home/runner/work/gatekeeper-operator/gatekeeper-operator/gatekeeper/test/bats/test.bats
- name: Gatekeeper E2E Tests
run: |
make download-binaries
make deploy-ci NAMESPACE=${{ matrix.NAMESPACE }} IMG=localhost:5000/gatekeeper-operator:$GITHUB_SHA
kubectl -n ${{ matrix.NAMESPACE }} wait deployment/gatekeeper-operator-controller --for condition=Available --timeout=90s
make test-gatekeeper-e2e
export PATH=$PWD/ci-tools/bin:$PATH
cd ../gatekeeper
test/externaldata/dummy-provider/scripts/generate-tls-certificate.sh
docker build -t dummy-provider:test -f test/externaldata/dummy-provider/Dockerfile test/externaldata/dummy-provider
kind load docker-image --name kind dummy-provider:test
make test-e2e GATEKEEPER_NAMESPACE=${{ matrix.NAMESPACE }} ENABLE_MUTATION_TESTS=1