-
Notifications
You must be signed in to change notification settings - Fork 1
301 lines (288 loc) · 10.8 KB
/
Copy pathci.yml
File metadata and controls
301 lines (288 loc) · 10.8 KB
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
# Flexmodel CI/CD Pipeline
# Runs tests for all modules, then builds and pushes Docker images.
# Deploys to production on push to main.
name: Run Tests
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
# ============================================================
# Test Jobs (run in parallel)
# ============================================================
functions-runtime-test:
name: functions-runtime tests (Deno)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: "2.8.3"
- name: Cache Deno dependencies
uses: actions/cache@v5
with:
path: |
~/.cache/deno
~/.deno
key: ${{ runner.os }}-deno-${{ hashFiles('flexmodel-functions-runtime/deno.json', 'flexmodel-functions-runtime/src/**/*.ts') }}
restore-keys: |
${{ runner.os }}-deno-
- name: Run Deno tests
working-directory: flexmodel-functions-runtime
run: deno test --allow-all --unstable-worker-options
engine-test:
name: Engine tests (Java)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up JDK 25
uses: actions/setup-java@v5
with:
java-version: '25'
distribution: 'temurin'
cache: 'maven'
cache-dependency-path: '**/pom.xml'
- name: Configure Maven settings
env:
GITHUB_USERNAME: cjbi
MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }}
run: |
mkdir -p ~/.m2
cp .github/settings.xml ~/.m2/settings.xml
- name: Run engine tests
run: mvn -B test -pl flexmodel-engine
server-test:
name: Server tests (Java)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
submodules: 'recursive'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up JDK 25
uses: actions/setup-java@v5
with:
java-version: '25'
distribution: 'temurin'
cache: 'maven'
cache-dependency-path: '**/pom.xml'
- name: Configure Maven settings
env:
GITHUB_USERNAME: cjbi
MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }}
run: |
mkdir -p ~/.m2
cp .github/settings.xml ~/.m2/settings.xml
- name: Run server tests
# continue-on-error: some tests have known failures (see AGENTS.md)
continue-on-error: true
run: mvn -B test -pl flexmodel-server -am
ui-e2e-test:
name: UI E2E tests (Playwright)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
submodules: 'recursive'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Node
uses: actions/setup-node@v5
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: 'flexmodel-ui/package-lock.json'
- name: Install dependencies
working-directory: flexmodel-ui
run: npm ci
- name: Install Playwright browser
working-directory: flexmodel-ui
run: npx playwright install --with-deps chromium
- name: Run E2E tests
working-directory: flexmodel-ui
env:
CI: 'true'
run: npx playwright test
continue-on-error: true
- name: Upload Playwright report
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: flexmodel-ui/playwright-report/
retention-days: 14
- name: Upload Playwright traces
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: playwright-traces
path: flexmodel-ui/test-results/
retention-days: 7
# ============================================================
# Build & Push Jobs (require corresponding tests to pass)
# ============================================================
push-server-image:
name: Push server docker image
needs: [ engine-test, server-test ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
submodules: 'recursive'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up JDK 25
uses: actions/setup-java@v5
with:
java-version: '25'
distribution: 'temurin'
cache: 'maven'
cache-dependency-path: '**/pom.xml'
- name: Configure Maven settings
env:
GITHUB_USERNAME: cjbi
MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }}
run: |
mkdir -p ~/.m2
cp .github/settings.xml ~/.m2/settings.xml
- name: Build and push server image
run: |
VERSION=$(cat VERSION | tr -d '[:space:]')
BUILD_VERSION="${VERSION}.${{ github.run_number }}"
FULL_VERSION="${BUILD_VERSION}-$(git rev-parse --short HEAD)"
mvn -B -Dmaven.test.skip=true clean package -pl flexmodel-server -am \
-Dflexmodel.version=${BUILD_VERSION} \
-Dquarkus.container-image.build=true \
-Dquarkus.container-image.push=true \
-Dquarkus.container-image.image=cjbi/flexmodel-server:${BUILD_VERSION} \
-Dquarkus.container-image.additional-tags=latest,${VERSION},${FULL_VERSION},sha-${{ github.sha }} \
-Dquarkus.container-image.username=${{ secrets.DOCKER_USERNAME }} \
-Dquarkus.container-image.password=${{ secrets.DOCKER_PASSWORD }}
push-server-native-image:
name: Push server native docker image
needs: [ engine-test, server-test ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
submodules: 'recursive'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up JDK 25
uses: actions/setup-java@v5
with:
java-version: '25'
distribution: 'temurin'
cache: 'maven'
cache-dependency-path: '**/pom.xml'
- name: Build and push server native image
run: |
VERSION=$(cat VERSION | tr -d '[:space:]')
BUILD_VERSION="${VERSION}.${{ github.run_number }}"
FULL_VERSION="${BUILD_VERSION}-$(git rev-parse --short HEAD)"
mvn -B -Dmaven.test.skip=true clean package -Pnative -pl flexmodel-server -am \
-Dflexmodel.version=${BUILD_VERSION} \
-Dquarkus.container-image.build=true \
-Dquarkus.container-image.push=true \
-Dquarkus.container-image.image=cjbi/flexmodel-server-native:${BUILD_VERSION} \
-Dquarkus.container-image.additional-tags=latest,${VERSION},${FULL_VERSION},sha-${{ github.sha }} \
-Dquarkus.container-image.username=${{ secrets.DOCKER_USERNAME }} \
-Dquarkus.container-image.password=${{ secrets.DOCKER_PASSWORD }}
push-functions-runtime-image:
name: Push functions-runtime docker image
needs: [ functions-runtime-test ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Read version
id: version
run: |
VERSION=$(cat VERSION | tr -d '[:space:]')
echo "tag=${VERSION}.${{ github.run_number }}" >> $GITHUB_OUTPUT
echo "ver=${VERSION}" >> $GITHUB_OUTPUT
echo "full=${VERSION}.${{ github.run_number }}-${{ github.sha }}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push functions-runtime image
uses: docker/build-push-action@v7
with:
context: flexmodel-functions-runtime
push: true
tags: |
cjbi/flexmodel-functions-runtime:latest
cjbi/flexmodel-functions-runtime:${{ steps.version.outputs.ver }}
cjbi/flexmodel-functions-runtime:${{ steps.version.outputs.tag }}
cjbi/flexmodel-functions-runtime:${{ steps.version.outputs.full }}
cjbi/flexmodel-functions-runtime:sha-${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
push-ui-image:
name: Push UI docker image
needs: [ ui-e2e-test ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
submodules: 'recursive'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Read version
id: version
run: |
VERSION=$(cat VERSION | tr -d '[:space:]')
echo "tag=${VERSION}.${{ github.run_number }}" >> $GITHUB_OUTPUT
echo "ver=${VERSION}" >> $GITHUB_OUTPUT
echo "full=${VERSION}.${{ github.run_number }}-${{ github.sha }}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push UI image
uses: docker/build-push-action@v7
with:
context: flexmodel-ui
push: true
tags: |
cjbi/flexmodel-ui:latest
cjbi/flexmodel-ui:${{ steps.version.outputs.ver }}
cjbi/flexmodel-ui:${{ steps.version.outputs.tag }}
cjbi/flexmodel-ui:${{ steps.version.outputs.full }}
cjbi/flexmodel-ui:sha-${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
# deploy:
# name: Deploy to production
# runs-on: ubuntu-latest
# needs: [ push-server-image, push-functions-runtime-image, push-ui-image ]
# steps:
# - uses: actions/checkout@v5
# - name: Read version
# id: version
# run: echo "tag=$(cat VERSION | tr -d '[:space:]').${{ github.run_number }}" >> $GITHUB_OUTPUT
# - name: Deploy Docker Image
# uses: appleboy/ssh-action@master
# env:
# IMAGE_TAG: ${{ steps.version.outputs.tag }}
# with:
# host: ${{ secrets.HOST }}
# username: ${{ secrets.SSH_USER }}
# port: ${{ secrets.SSH_PORT }}
# key: ${{ secrets.SSH_KEY }}
# envs: IMAGE_TAG
# command_timeout: 10m
# script: |
# cd /opt/flexmodel-quickstarts/docker-compose
# docker pull cjbi/flexmodel-server:${IMAGE_TAG}
# docker pull cjbi/flexmodel-functions-runtime:${IMAGE_TAG}
# docker pull cjbi/flexmodel-ui:${IMAGE_TAG}
# docker tag cjbi/flexmodel-server:${IMAGE_TAG} cjbi/flexmodel-server:latest
# docker tag cjbi/flexmodel-functions-runtime:${IMAGE_TAG} cjbi/flexmodel-functions-runtime:latest
# docker tag cjbi/flexmodel-ui:${IMAGE_TAG} cjbi/flexmodel-ui:latest
# docker-compose up -d
# echo "Deployed version ${IMAGE_TAG}"