-
Notifications
You must be signed in to change notification settings - Fork 50
278 lines (268 loc) · 9.61 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
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java#publishing-using-gradle
name: doughnut CI
on:
push:
branches:
- main
env:
ARTIFACT: "doughnut"
VERSION: "0.0.1-SNAPSHOT"
GCS_BUCKET: "dough-01"
MYSQL_UT_DB: "doughnut_test"
MYSQL_E2E_DB: "doughnut_e2e_test"
MYSQL_DB_USER: ${{ secrets.DBUSER }}
MYSQL_DB_PASSWORD: ${{ secrets.DBPASSWORD }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GCP_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }}
GITHUB_FOR_ISSUES_API_TOKEN: ${{ secrets.GH_ISSUES_API_TOKEN }}
OPENAI_API_TOKEN: ${{ secrets.OPENAI_API_TOKEN }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
jobs:
Lint-N-Backend-Generated-Types-For-Frontend:
name: Linting & Types Gen for Frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/setup_jdk_with_cache
with:
java_version: ${{ vars.JAVA_VERSION }}
- uses: ./.github/setup_nodejs
with:
node_version: ${{ vars.NODE_VERSION }}
pnpm_version: ${{ vars.PNPM_VERSION }}
- run: bash -c ./assert_generated_type_script_up_to_date.sh
- run: pnpm lint:all
Backend-unit-tests:
name: Backend Unit tests
runs-on: ${{ vars.RUNNER }}
steps:
- uses: actions/checkout@v4
- name: Setup MySQL DB Server
uses: ./.github/mysql_db
with:
mysql_version: ${{ vars.MYSQL_VERSION }}
mysql_db_host_port: ${{ vars.MYSQL_PORT }}
mysql_db_container_port: ${{ vars.MYSQL_PORT }}
mysql_db_instance: ${{ env.MYSQL_UT_DB }}
mysql_db_user: ${{ env.MYSQL_DB_USER }}
mysql_db_password: ${{ env.MYSQL_DB_PASSWORD }}
- uses: ./.github/setup_jdk_with_cache
with:
java_version: ${{ vars.JAVA_VERSION }}
- run: backend/gradlew -p backend migrateTestDB -Dspring.profiles.active=test
- run: backend/gradlew -p backend test -Dspring.profiles.active=test --parallel
Frontend-unit-tests:
name: Frontend Unit tests
runs-on: ${{ vars.RUNNER }}
env:
FRONTEND_UT_CONSOLE_OUTPUT_AS_FAILURE: true
steps:
- uses: actions/checkout@v4
- uses: ./.github/setup_nodejs
with:
node_version: ${{ vars.NODE_VERSION }}
pnpm_version: ${{ vars.PNPM_VERSION }}
- run: pnpm frontend:test
Package-artifacts:
name: Package backend & frontend artifacts for deployment
runs-on: ${{ vars.RUNNER }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/setup_jdk_with_cache
with:
java_version: ${{ vars.JAVA_VERSION }}
- uses: ./.github/setup_nodejs
with:
node_version: ${{ vars.NODE_VERSION }}
pnpm_version: ${{ vars.PNPM_VERSION }}
- name: Compile & transform frontend assets for bundling with Backend
run: pnpm frontend:build
- name: Build application jar artifact
run: backend/gradlew -p backend build -x test -Dspring.profiles.active=prod --build-cache --parallel
- uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT }}-${{ env.VERSION }}.jar
path: backend/build/libs/${{ env.ARTIFACT }}-${{ env.VERSION }}.jar
E2E-tests:
name: End-to-End tests with Database
runs-on: ${{ vars.RUNNER }}
strategy:
matrix:
spec:
- |
e2e_test/features/a*/**
- |
e2e_test/features/b*/**
e2e_test/features/c*/**
e2e_test/features/f*/**
e2e_test/features/l*/**
e2e_test/features/m*/**
- |
e2e_test/features/n*/**
- |
e2e_test/features/r*/**
- |
e2e_test/features/t*/**
e2e_test/features/u*/**
- |
e2e_test/features/w*/**
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_TOKEN }}
- uses: ./.github/mysql_db
with:
mysql_version: ${{ vars.MYSQL_VERSION }}
mysql_db_host_port: ${{ vars.MYSQL_PORT }}
mysql_db_container_port: ${{ vars.MYSQL_PORT }}
mysql_db_instance: ${{ env.MYSQL_E2E_DB }}
mysql_db_user: ${{ env.MYSQL_DB_USER }}
mysql_db_password: ${{ env.MYSQL_DB_PASSWORD }}
- name: Setup JDK with cache
uses: ./.github/setup_jdk_with_cache
with:
java_version: ${{ vars.JAVA_VERSION }}
- uses: ./.github/setup_nodejs
with:
node_version: ${{ vars.NODE_VERSION }}
pnpm_version: ${{ vars.PNPM_VERSION }}
- uses: cypress-io/github-action@v6
with:
browser: chrome
config-file: e2e_test/config/ci.ts
build: pnpm frontend:build
start: pnpm run-p -clnr sut start:mb
wait-on: "http://127.0.0.1:9081/api/healthcheck"
wait-on-timeout: 150
spec: ${{ matrix.spec }}
env:
GITHUB_FOR_ISSUES_API_TOKEN: ${{ env.GITHUB_FOR_ISSUES_API_TOKEN }}
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: e2e_test/screenshots
Deploy:
name: GCP MIG Rolling Update Deploy
runs-on: ${{ vars.RUNNER }}
needs:
[
Lint-N-Backend-Generated-Types-For-Frontend,
Backend-unit-tests,
Frontend-unit-tests,
Package-artifacts,
E2E-tests,
]
steps:
- uses: actions/checkout@v4
- uses: ./.github/gcloud_auth_n_sdk
with:
credentials_json: ${{ env.GCP_CREDENTIALS }}
- name: Upload production application jar to Google Cloud Storage
uses: actions/download-artifact@v4
with:
name: ${{ env.ARTIFACT }}-${{ env.VERSION }}.jar
- uses: google-github-actions/upload-cloud-storage@v2
with:
path: ./${{ env.ARTIFACT }}-${{ env.VERSION }}.jar
destination: ${{ env.GCS_BUCKET }}/backend_app_jar
- name: Perform rolling replace to GCP MIG doughnut-app-group
run: infra/gcp/scripts/perform-rolling-replace-app-mig.sh
Notify-on-failure:
name: Single slack/discord notification on CI/CD failure
runs-on: ${{ vars.RUNNER }}
needs:
[
Lint-N-Backend-Generated-Types-For-Frontend,
Backend-unit-tests,
Frontend-unit-tests,
Package-artifacts,
E2E-tests,
Deploy,
]
if: always()
steps:
- uses: technote-space/workflow-conclusion-action@v3
- uses: 8398a7/action-slack@v3
if: env.WORKFLOW_CONCLUSION == 'failure'
with:
status: failure
fields: repo,commit,message,author,action,workflow,eventName
# - uses: nobrayner/discord-webhook@v1
# if: env.WORKFLOW_CONCLUSION == 'failure'
# with:
# github-token: ${{ env.GITHUB_TOKEN }}
# discord-webhook: ${{ env.DISCORD_WEBHOOK_URL }}
# mobile-unit-test:
# runs-on: ${{ vars.RUNNER }}
# steps:
# - uses: actions/checkout@v4
# - uses: subosito/flutter-action@v2
# with:
# flutter-version: ${{ vars.FLUTTER_VERSION }}
# - run: flutter pub get
# working-directory: ./doughnut_mobile
# - run: flutter test
# working-directory: ./doughnut_mobile
# drive_ios:
# strategy:
# matrix:
# device:
# - "iPhone 15"
# fail-fast: false
# runs-on: ${{ vars.RUNNER }}
# steps:
# - name: List Simulators
# run: xcrun xctrace list devices
# - name: Start Simulator
# run: xcrun simctl boot "${{ matrix.device }}"
# - uses: actions/checkout@v4
# - uses: ./.github/starting_backend_actions
# with:
# java_version: ${{ vars.JAVA_VERSION }}
# pnpm_version: ${{ vars.PNPM_VERSION }}
# mysql_version: ${{ vars.MYSQL_VERSION }}
# mysql_db_host_port: ${{ vars.MYSQL_PORT }}
# mysql_db_container_port: ${{ vars.MYSQL_PORT }}
# dbuser: ${{ secrets.DBUSER }}
# dbpassword: ${{ secrets.DBPASSWORD }}
# db_url: ${{ secrets.CI_E2E_DB_URL }}
# - uses: ./.github/mobile_actions
# with:
# flutter-version: ${{ vars.FLUTTER_VERSION }}
# - run: dart test_driver/app_test.dart
# working-directory: ./doughnut_mobile
# drive_android:
# runs-on: ${{ vars.RUNNER }}
# #creates a build matrix for your jobs
# strategy:
# #set of different configurations of the virtual environment.
# matrix:
# api-level: [34]
# steps:
# - uses: actions/checkout@v4
# - uses: ./.github/starting_backend_actions
# with:
# java_version: ${{ vars.JAVA_VERSION }}
# pnpm_version: ${{ vars.PNPM_VERSION }}
# mysql_version: ${{ vars.MYSQL_VERSION }}
# mysql_db_host_port: ${{ vars.MYSQL_PORT }}
# mysql_db_container_port: ${{ vars.MYSQL_PORT }}
# dbuser: ${{ secrets.DBUSER }}
# dbpassword: ${{ secrets.DBPASSWORD }}
# db_url: ${{ secrets.CI_E2E_DB_URL }}
# - uses: ./.github/mobile_actions
# with:
# flutter-version: ${{ vars.FLUTTER_VERSION }}
# - name: Run Flutter Driver tests
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: ${{ matrix.api-level }}
# script: |
# cd ./doughnut_mobile && dart test_driver/app_test.dart