forked from project-openubl/searchpe
-
Notifications
You must be signed in to change notification settings - Fork 0
312 lines (289 loc) · 11.3 KB
/
ci.yml
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
name: CI
on:
push:
branches-ignore:
- "dependabot/**"
paths-ignore:
- "README.md"
pull_request:
paths-ignore:
- "README.md"
merge_group: { }
jobs:
jvm-tests:
name: JVM Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: maven
- name: Maven
run: mvn verify
native-tests:
name: Native Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: maven
- name: Build with Maven
run: mvn verify -Dquarkus.native.container-build=true -P native
ui-tests:
name: UI Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Build
working-directory: application/src/main/webapp
run: |
npm install
npm run build
- name: Test
working-directory: application/src/main/webapp
run: npm run test -- --coverage --watchAll=false
application-container:
name: Application container
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: maven
- name: Build container image
run: |
mvn -U -B package --file pom.xml -DskipTests \
-Dquarkus.native.container-build=true \
-Dquarkus.container-image.push=false \
-Dquarkus.container-image.build=true \
-Dquarkus.container-image.registry=localhost:5000 \
-Dquarkus.container-image.group="" \
-Dquarkus.container-image.name=searchpe \
-Dquarkus.container-image.tag=0.0.0 \
-P native,ui \
-pl application
- name: Save container image
run: docker save -o searchpe-application-container-image.tar localhost:5000/searchpe:0.0.0
- name: Upload container image
uses: actions/upload-artifact@v3
with:
name: artifacts
path: searchpe-application-container-image.tar
operator-container:
name: Operator container
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: maven
- name: Build container image
run: |
mvn -U -B package --file pom.xml -DskipTests \
-Dquarkus.native.container-build=true \
-Dquarkus.container-image.push=false \
-Dquarkus.container-image.build=true \
-Dquarkus.container-image.registry=localhost:5000 \
-Dquarkus.container-image.group="" \
-Dquarkus.container-image.name=searchpe-operator \
-Dquarkus.container-image.tag=0.0.0 \
-P native \
-pl operator
- name: Save container image
run: docker save -o searchpe-operator-container-image.tar localhost:5000/searchpe-operator:0.0.0
- name: Upload container image
uses: actions/upload-artifact@v3
with:
name: artifacts
path: searchpe-operator-container-image.tar
catalog-container:
name: Catalog container
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: maven
- name: Setup OLM CLIs
run: |
export ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac)
export OS=$(uname | awk '{print tolower($0)}')
# Opm
export OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-registry/releases/download/v1.26.2
curl -LO ${OPERATOR_SDK_DL_URL}/${OS}-${ARCH}-opm
chmod +x ${OS}-${ARCH}-opm && sudo mv ${OS}-${ARCH}-opm /usr/local/bin/opm
- name: Setup other tools
run: |
sudo apt-get install -y groovy
- name: Build container image
run: |
mvn -U -B package --file pom.xml -DskipTests \
-Dquarkus.native.container-build=false \
-Dquarkus.container-image.push=false \
-Dquarkus.container-image.build=false \
-Dquarkus.container-image.registry=localhost:5000 \
-Dquarkus.container-image.group="" \
-Dquarkus.container-image.name=searchpe-operator \
-Dquarkus.operator-sdk.bundle.package-name=searchpe-operator \
-Dquarkus.operator-sdk.bundle.channels=alpha \
-Dquarkus.application.version=0.0.0 \
-Dquarkus.kubernetes.image-pull-policy=if-not-present \
-Dquarkus.kubernetes.env.vars.operator-searchpe-image=localhost:5000/searchpe:0.0.0 \
-Dquarkus.kubernetes.env.vars.operator-searchpe-image-pull-policy=IfNotPresent \
-pl operator
groovy scripts/enrichCSV.groovy operator/target/bundle/searchpe-operator/manifests/searchpe-operator.clusterserviceversion.yaml 0.0.0
sed -i "/ annotations: ''/d" ./operator/target/bundle/searchpe-operator/manifests/searchpe-operator.clusterserviceversion.yaml
- name: Init local Registry
run: |
docker run -d -p 5000:5000 --name registry registry:2
sleep 5
- name: Create bundle image
run: |
# Bundle
BUNDLE_IMAGE=localhost:5000/searchpe-operator-bundle:0.0.0
docker build -t $BUNDLE_IMAGE -f operator/target/bundle/searchpe-operator/bundle.Dockerfile operator/target/bundle/searchpe-operator
docker push $BUNDLE_IMAGE
# Catalog
CATALOG_IMAGE=localhost:5000/searchpe-operator-catalog:0.0.0
opm index add --bundles $BUNDLE_IMAGE --tag $CATALOG_IMAGE --use-http --build-tool docker
# Save container images
docker save -o searchpe-bundle-container-image.tar $BUNDLE_IMAGE
docker save -o searchpe-catalog-container-image.tar $CATALOG_IMAGE
- name: Upload container image
uses: actions/upload-artifact@v3
with:
name: artifacts
path: |
searchpe-bundle-container-image.tar
searchpe-catalog-container-image.tar
ui-e2e-tests:
needs: [ application-container, operator-container, catalog-container ]
name: UI E2E Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- uses: actions/download-artifact@v3
- name: Load and config images
run: |
docker load -i artifacts/searchpe-application-container-image.tar
docker load -i artifacts/searchpe-operator-container-image.tar
docker load -i artifacts/searchpe-bundle-container-image.tar
docker load -i artifacts/searchpe-catalog-container-image.tar
- name: Setup Minikube
uses: manusa/[email protected]
with:
minikube version: v1.28.0
kubernetes version: v1.25.3
start args: --insecure-registry "10.0.0.0/24" --addons=registry,ingress
github token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure Minikube
run: |
# Install OLM
curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.22.0/install.sh | bash -s v0.22.0
# Load images
minikube image load localhost:5000/searchpe:0.0.0
minikube image load localhost:5000/searchpe-operator:0.0.0
minikube image load localhost:5000/searchpe-operator-bundle:0.0.0
minikube image load localhost:5000/searchpe-operator-catalog:0.0.0
# Push images to internal registry
docker push localhost:5000/searchpe:0.0.0
docker push localhost:5000/searchpe-operator:0.0.0
docker push localhost:5000/searchpe-operator-bundle:0.0.0
docker push localhost:5000/searchpe-operator-catalog:0.0.0
- name: Install Searchpe operator
run: |
kubectl create ns openubl
# Create custom catalog
kubectl create -f scripts/searchpe-operator.yaml
kubectl get pods -n olm --selector=olm.catalogSource=searchpe-catalog-source
# Verify subscription
kubectl get csv -n olm
- name: Install Postgresql Operator
run: |
kubectl create -f https://operatorhub.io/install/postgresql.yaml
PHASE=""
while [ "$PHASE" != "Succeeded" ]
do
PHASE=$(kubectl get csv -n operators -o jsonpath="{$.items[*].status.phase}")
echo "Waiting for postgresql csv. Current phase=$PHASE"
sleep 10;
done
- name: Install DB
run: |
kubectl -n openubl apply -f scripts/postgresql.yaml
POD_COUNT=0
while [ $POD_COUNT -le 3 ]
do
POD_COUNT=$(kubectl get pods -n openubl -o name | wc -l)
echo "Waiting for pods to exists. Current count=$POD_COUNT"
sleep 10;
done
echo "Resources exists, now wait for them to be ready"
kubectl wait pods -l "postgres-operator.crunchydata.com/data"="pgbackrest" -n openubl --for condition=Ready --timeout=-1s
kubectl wait pods -l "postgres-operator.crunchydata.com/data"="postgres" -n openubl --for condition=Ready --timeout=-1s
- name: Install Searchpe
run: |
kubectl -n openubl apply -f scripts/searchpe.yaml
sleep 10;
kubectl wait pods --selector "app.kubernetes.io/name"="searchpe" -n openubl --for condition=Ready --timeout=-1s
external_ip=""
while [[ -z $external_ip ]]
do
external_ip=$(kubectl get ingress searchpe-searchpe-ingress --template="{{range.status.loadBalancer.ingress}}{{.ip}}{{end}}" -n openubl);
echo "Waiting for end point...current=$external_ip"
sleep 10;
done
echo "End point ready: $external_ip"
export endpoint=$(minikube ip);
echo "CYPRESS_BASE_URL=https://$endpoint" >> $GITHUB_ENV
- name: Cypress run
uses: cypress-io/github-action@v5
with:
working-directory: application/src/main/webapp
record: false
browser: chrome
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v3
if: failure()
with:
name: container-screenshots
path: application/src/main/webapp/cypress/screenshots
- uses: actions/upload-artifact@v3
if: always()
with:
name: container-videos
path: application/src/main/webapp/cypress/videos
# helm-tests:
# name: Helm Tests
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-java@v3
# with:
# java-version: 17
# distribution: temurin
# cache: maven
# - uses: azure/setup-helm@v3
# - name: Helm
# run: |
# mvn process-resources
# helm lint application/target/helm/