-
Notifications
You must be signed in to change notification settings - Fork 14
96 lines (88 loc) · 4.18 KB
/
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
# Copyright 2021, 2023 Oracle Corporation and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at
# https://oss.oracle.com/licenses/upl.
name: CI Build
on:
workflow_dispatch:
schedule:
- cron: "0 4 * * *"
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '21'
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
env:
MAVEN_OPTS: -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.count=3
run: mvn -B install -DskipTests --file pom.xml
- name: Push container images
env:
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: |
echo $REGISTRY_PASSWORD | docker login ghcr.io -u $REGISTRY_USER --password-stdin
mvn -B package --file pom.xml -Pcontainer -DskipTests
docker push ghcr.io/oracle/coherence-helidon-sockshop-carts:latest
docker push ghcr.io/oracle/coherence-helidon-sockshop-catalog:latest
docker push ghcr.io/oracle/coherence-helidon-sockshop-orders:latest
docker push ghcr.io/oracle/coherence-helidon-sockshop-payment:latest
docker push ghcr.io/oracle/coherence-helidon-sockshop-shipping:latest
docker push ghcr.io/oracle/coherence-helidon-sockshop-users:latest
if: github.event_name == 'push'
- name: Test Against Kind
env:
KIND_IMAGE: kindest/node:v1.24.7@sha256:577c630ce8e509131eab1aea12c022190978dd2f745aac5eb1fe65c0807eb315
run: |
echo "====== Starting kind using ${KIND_IMAGE} ======"
kind create cluster --name sockshop --wait 10m --image ${KIND_IMAGE}
echo "====== Build latest images ======"
export sock_image_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
mvn -B package --file pom.xml -Pcontainer -DskipTests
echo "====== Loading generated images into kind ... ======"
for name in carts orders catalog shipping users payment
do
kind load docker-image ghcr.io/oracle/coherence-helidon-sockshop-${name}:${sock_image_version} --name sockshop
kind load docker-image ghcr.io/oracle/coherence-helidon-sockshop-${name}:latest --name sockshop
done
echo "====== Creating Sockshop Namespace ======"
kubectl create namespace sockshop
echo "====== Deploying Operator ======"
kubectl apply -f https://github.com/oracle/coherence-operator/releases/download/v3.4.0/coherence-operator.yaml
kubectl rollout status deployment coherence-operator-controller-manager -n coherence --timeout=180s
echo "====== Deploying Sockshop ======"
kubectl apply -k k8s/coherence --namespace sockshop
echo "====== Waiting 30 seconds to ensure the pods are at least created... ======"
sleep 30
for pod in carts-0 orders-0 catalog-0 shipping-0 users-0 payment-0
do
kubectl -n sockshop wait --for condition=ready --timeout 30s pod/${pod}
done
echo "====== Success ======"
kubectl delete -k k8s/coherence --namespace sockshop
kubectl delete -f https://github.com/oracle/coherence-operator/releases/download/v3.4.0/coherence-operator.yaml
kubectl delete ns sockshop
- name: Dump logs on failure
if: failure() # This step runs only if the previous step failed
run: |
echo "====== Dumping logs for all pods in the namespace: ======"
for pod in $(kubectl get pods --namespace sockshop -o jsonpath='{.items[*].metadata.name}'); do
echo "Logs for pod: $pod"
kubectl logs "$pod" --namespace sockshop || echo "Failed to get logs for $pod"
done