-
Notifications
You must be signed in to change notification settings - Fork 15
202 lines (197 loc) · 6.77 KB
/
java-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
name: Java CI
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
JAVA: '21'
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project-path: [
'api',
'carts',
'catalogue',
'events',
'fulfillment',
'functions/newsletter-subscription',
'orders',
'payment',
'user',
'assets'
]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2.1.4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1.1.2
with:
distribution: 'graalvm'
java-version: ${{ env.JAVA }}
- name: Build and test
working-directory: src/${{ matrix.project-path }}
run: |
if [ -f "mvnw" ]; then
./mvnw test --no-transfer-progress
elif [ -f "gradlew" ]; then
./gradlew check --no-daemon --continue
fi
env:
TESTCONTAINERS_RYUK_DISABLED: true
build-docker-compose-test-images:
if: success()
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project-path: [
'api',
'carts',
'catalogue',
'fulfillment',
'orders',
'payment',
'user',
'assets'
]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2.1.4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1.1.22
with:
distribution: 'graalvm'
java-version: ${{ env.JAVA }}
- name: Login to OCIR
uses: docker/login-action@v1
with:
registry: phx.ocir.io
username: ${{ secrets.OCI_USERNAME }}
password: ${{ secrets.OCI_TOKEN }}
#
# Build GraalVM docker image with SHA as tag for later use in docker-compose test job
- name: Build docker & push image - GraalVM
working-directory: src/${{ matrix.project-path }}
run: |
if [ -f "mvnw" ]; then
# Install only the `lib` module to the local repository so it can be used for building the `app` image
./mvnw install -Drevision=$GITHUB_SHA -pl -app,-aws,-oci
./mvnw deploy -Dpackaging=docker -Djib.from.image=ghcr.io/graalvm/native-image-community:21 -Ddocker.image.suffix=graalvm -Drevision=$GITHUB_SHA --no-transfer-progress -pl app
elif [ -f "gradlew" ]; then
./gradlew :app:dockerPush -Pversion=$GITHUB_SHA --no-daemon
fi
docker-compose-test:
if: success()
needs: build-docker-compose-test-images
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- name: Login to OCIR
uses: docker/login-action@v1
with:
registry: phx.ocir.io
username: ${{ secrets.OCI_USERNAME }}
password: ${{ secrets.OCI_TOKEN }}
logout: false
- name: Setup stack
working-directory: deploy/complete/docker-compose
run: |
#
# Configure higher timeouts
export DOCKER_CLIENT_TIMEOUT=120
export COMPOSE_HTTP_TIMEOUT=120
#
# Generate override docker compose so we use latest build docker images
grep -B 1 -e "services:" -e 'graalvm' docker-compose.yml | sed -E "s/(.*):(.*):(.*)/\1:\2:$GITHUB_SHA/g" | grep -v -e '--' > docker-compose.override.yml
cat docker-compose.override.yml
docker-compose pull
docker-compose up -d --renew-anon-volumes --force-recreate --remove-orphans
docker-compose ps
#
# wait 10 seconds to let the containers initalize
sleep 10
docker-compose logs
- name: Run test
working-directory: src/load
run: |
docker build -t mushop/load:latest .
docker run --net=host mushop/load:latest -h localhost:81 -c 5 -r 60
- name: Cleanup stack
if: ${{ always() }}
working-directory: deploy/complete/docker-compose
run: |
docker-compose down -t 300
docker volume prune -f
docker image prune -f
push-docker-images:
if: success() && github.event_name == 'push'
needs: docker-compose-test
runs-on: self-hosted
strategy:
fail-fast: false
matrix:
project-path: [
'api',
'carts',
'catalogue',
'events',
'fulfillment',
'functions/newsletter-subscription',
'orders',
'payment',
'user',
'assets'
]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2.1.4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1.1.22
with:
distribution: 'graalvm'
java-version: ${{ env.JAVA }}
- name: Login to OCIR
uses: docker/login-action@v1
with:
registry: phx.ocir.io
username: ${{ secrets.OCI_USERNAME }}
password: ${{ secrets.OCI_TOKEN }}
logout: false
- name: Push docker image - GraalVM Native Image
working-directory: src/${{ matrix.project-path }}
run: |
if [ -f "mvnw" ]; then
# Install only the `lib` module to the local repository so it can be used for building `app`, `aws` and `oci` GraalVM images
./mvnw install -pl -app,-aws,-oci
# Build and deploy `app`, `aws` and `oci` GraalVM images
./mvnw deploy -Dpackaging=docker -Djib.from.image=phx.ocir.io/oraclelabs/micronaut-showcase/mushop/base/native-image-community:21 -Ddocker.image.suffix=graalvm --no-transfer-progress -pl app
./mvnw deploy -Dpackaging=docker -Djib.from.image=phx.ocir.io/oraclelabs/micronaut-showcase/mushop/base/native-image-community:21 -Ddocker.image.suffix=graalvm --no-transfer-progress -pl aws
./mvnw deploy -Dpackaging=docker -Djib.from.image=phx.ocir.io/oraclelabs/micronaut-showcase/mushop/base/native-image-community:21 -Ddocker.image.suffix=graalvm --no-transfer-progress -pl oci
elif [ -f "gradlew" ]; then
./gradlew dockerPush --no-daemon
fi
- name: Cleanup images
if: ${{ always() }}
run: docker image prune -a -f