-
Notifications
You must be signed in to change notification settings - Fork 3
238 lines (230 loc) · 12.7 KB
/
build_and_test.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
name: Build and test
on:
pull_request:
push:
branches:
- 'master'
concurrency:
# https://docs.github.com/en/actions/using-jobs/using-concurrency
# The latest queued workflow is preferred; the ones already in progress get cancelled
# Workflows on master branch shouldn't be cancelled, that's why they are identified by commit SHA
group: ${{ github.ref == 'refs/heads/master' && format('{0}-{1}', github.workflow, github.sha) || format('{0}-{1}', github.workflow, github.ref) }}
cancel-in-progress: true
jobs:
calculate_build_flags:
name: Detect build flags for modules
runs-on: ubuntu-latest
outputs:
api-gateway: ${{ steps.calculate-dependencies.outputs.api-gateway }}
authentication-service: ${{ steps.calculate-dependencies.outputs.authentication-service }}
save-agent: ${{ steps.calculate-dependencies.outputs.save-agent }}
save-api: ${{ steps.calculate-dependencies.outputs.save-api }}
save-api-cli: ${{ steps.calculate-dependencies.outputs.save-api-cli }}
save-backend: ${{ steps.calculate-dependencies.outputs.save-backend }}
save-cloud-common: ${{ steps.calculate-dependencies.outputs.save-cloud-common }}
cosv-backend: ${{ steps.calculate-dependencies.outputs.cosv-backend }}
cosv-frontend: ${{ steps.calculate-dependencies.outputs.cosv-frontend }}
save-demo: ${{ steps.calculate-dependencies.outputs.save-demo }}
save-demo-agent: ${{ steps.calculate-dependencies.outputs.save-demo-agent }}
save-demo-cpg: ${{ steps.calculate-dependencies.outputs.save-demo-cpg }}
save-frontend: ${{ steps.calculate-dependencies.outputs.save-frontend }}
frontend-common: ${{ steps.calculate-dependencies.outputs.frontend-common }}
save-orchestrator: ${{ steps.calculate-dependencies.outputs.save-orchestrator }}
save-orchestrator-common: ${{ steps.calculate-dependencies.outputs.save-orchestrator-common }}
save-preprocessor: ${{ steps.calculate-dependencies.outputs.save-preprocessor }}
test-analysis-core: ${{ steps.calculate-dependencies.outputs.test-analysis-core }}
test-utils: ${{ steps.calculate-dependencies.outputs.test-utils }}
steps:
- id: checkout
if: ${{ github.event_name == 'push' }}
uses: actions/checkout@v4
with:
fetch-depth: 2
- id: git-changed-files
uses: tj-actions/changed-files@v42
with:
files_yaml: |
root_gradle:
- '*.gradle.kts'
- gradle.properties
- gradle/**
- buildSrc/**
api-gateway:
- api-gateway/**
authentication-service:
- authentication-service/**
save-agent:
- save-agent/**
save-api:
- save-api/**
save-api-cli:
- save-api-cli/**
save-backend:
- save-backend/**
save-cloud-common:
- save-cloud-common/**
cosv-backend:
- cosv-backend/**
cosv-frontend:
- cosv-frontend/**
save-demo:
- save-demo/**
save-demo-agent:
- save-demo-agent/**
save-demo-cpg:
- save-demo-cpg/**
save-frontend:
- save-frontend/**
frontend-common:
- frontend-common/**
save-orchestrator:
- save-orchestrator/**
save-orchestrator-common:
- save-orchestrator-common/**
save-preprocessor:
- save-preprocessor/**
test-analysis-core:
- test-analysis-core/**
test-utils:
- test-utils/**
- id: calculate-dependencies
run: |
set -x
all=$(( ${{ steps.git-changed-files.outputs.root_gradle_all_changed_files_count }} ))
save_cloud_common=$(( $all + ${{ steps.git-changed-files.outputs.save-cloud-common_all_changed_files_count }} ))
frontend_common=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.frontend-common_all_changed_files_count }} ))
save_orchestrator_common=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.save-orchestrator-common_all_changed_files_count }} ))
authentication_service=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.authentication-service_all_changed_files_count }} ))
save_api=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.save-api_all_changed_files_count }} ))
cosv_backend=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.cosv-backend_all_changed_files_count }} ))
test_analysis_core=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.test-analysis-core_all_changed_files_count }} ))
test_utils=$(( ${{ steps.git-changed-files.outputs.test-utils_all_changed_files_count }} ))
api_gateway=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.api-gateway_all_changed_files_count }} ))
save_agent=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.save-agent_all_changed_files_count }} ))
save_api_cli=$(( $save_cloud_common + $save_api + ${{ steps.git-changed-files.outputs.save-api-cli_all_changed_files_count }} ))
save_backend=$(( $save_cloud_common + $authentication_service + $test_analysis_core + $cosv_backend + $test_utils + ${{ steps.git-changed-files.outputs.save-backend_all_changed_files_count }} ))
cosv_frontend=$(( $save_cloud_common + $frontend_common + ${{ steps.git-changed-files.outputs.cosv-frontend_all_changed_files_count }} ))
save_demo=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.save-demo_all_changed_files_count }} ))
save_demo_agent=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.save-demo-agent_all_changed_files_count }} ))
save_demo_cpg=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.save-demo-cpg_all_changed_files_count }} ))
save_frontend=$(( $save_cloud_common + $frontend_common + ${{ steps.git-changed-files.outputs.save-frontend_all_changed_files_count }} ))
save_orchestrator=$(( $save_cloud_common + $save_orchestrator_common + $test_utils + ${{ steps.git-changed-files.outputs.save-orchestrator_all_changed_files_count }} ))
save_preprocessor=$(( $save_cloud_common + $test_utils + ${{ steps.git-changed-files.outputs.save-preprocessor_all_changed_files_count }} ))
echo "api-gateway=$api_gateway" >> "$GITHUB_OUTPUT"
echo "authentication-service=$authentication_service" >> "$GITHUB_OUTPUT"
echo "save-agent=$save_agent" >> "$GITHUB_OUTPUT"
echo "save-api=$save_api" >> "$GITHUB_OUTPUT"
echo "save-api-cli=$save_api_cli" >> "$GITHUB_OUTPUT"
echo "save-backend=$save_backend" >> "$GITHUB_OUTPUT"
echo "save-cloud-common=$save_cloud_common" >> "$GITHUB_OUTPUT"
echo "cosv-backend=$cosv_backend" >> "$GITHUB_OUTPUT"
echo "cosv-frontend=$cosv_frontend" >> "$GITHUB_OUTPUT"
echo "save-demo=$save_demo" >> "$GITHUB_OUTPUT"
echo "save-demo-agent=$save_demo_agent" >> "$GITHUB_OUTPUT"
echo "save-demo-cpg=$save_demo_cpg" >> "$GITHUB_OUTPUT"
echo "save-frontend=$save_frontend" >> "$GITHUB_OUTPUT"
echo "frontend-common=$frontend_common" >> "$GITHUB_OUTPUT"
echo "save-orchestrator=$save_orchestrator" >> "$GITHUB_OUTPUT"
echo "save-orchestrator-common=$save_orchestrator_common" >> "$GITHUB_OUTPUT"
echo "save-preprocessor=$save_preprocessor" >> "$GITHUB_OUTPUT"
echo "test-analysis-core=$test_analysis_core" >> "$GITHUB_OUTPUT"
echo "test-utils=$test_utils" >> "$GITHUB_OUTPUT"
build_save-cloud-common:
name: 'Build and test (save-cloud-common)'
needs: [ calculate_build_flags ]
uses: ./.github/workflows/build_and_test_reusable.yml
with:
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.save-cloud-common > 0 }}
module: save-cloud-common
gradle-cache-read-only: ${{ github.ref != 'refs/heads/master' && github.event_name != 'pull_request' }}
build_save-orchestrator-common:
name: 'Build and test (save-orchestrator-common)'
needs: [ calculate_build_flags, build_save-cloud-common ]
uses: ./.github/workflows/build_and_test_reusable.yml
with:
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.save-orchestrator-common > 0 }}
module: save-orchestrator-common
gradle-cache-read-only: ${{ github.ref != 'refs/heads/master' && github.event_name != 'pull_request' }}
build_frontend-common:
name: 'Build and test (frontend-common)'
needs: [ calculate_build_flags, build_save-orchestrator-common ]
uses: ./.github/workflows/build_and_test_reusable.yml
with:
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.frontend-common > 0 }}
module: frontend-common
gradle-cache-read-only: ${{ github.ref != 'refs/heads/master' && github.event_name != 'pull_request' }}
build_all:
name: 'Build and test'
needs: [ calculate_build_flags, build_frontend-common ]
strategy:
fail-fast: false
matrix:
module: [
'api-gateway',
'authentication-service',
'save-agent',
'save-api',
'save-api-cli',
'save-backend',
'cosv-backend',
'cosv-frontend',
'save-demo',
'save-demo-agent',
'save-demo-cpg',
'save-frontend',
'save-orchestrator',
'save-preprocessor',
'test-analysis-core',
'test-utils'
]
include:
- module: api-gateway
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.api-gateway > 0 }}
- module: authentication-service
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.authentication-service > 0 }}
- module: save-agent
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.save-agent > 0 }}
- module: save-api
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.save-api > 0 }}
- module: save-api-cli
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.save-api-cli > 0 }}
- module: save-demo-cpg
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.save-demo-cpg > 0 }}
- module: save-backend
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.save-backend > 0 }}
- module: cosv-backend
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.cosv-backend > 0 }}
- module: cosv-frontend
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.cosv-frontend > 0 }}
- module: save-demo
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.save-demo > 0 }}
- module: save-demo-agent
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.save-demo-agent > 0 }}
- module: save-demo-cpg
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.save-demo-cpg > 0 }}
- module: save-frontend
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.save-frontend > 0 }}
- module: save-orchestrator
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.save-orchestrator > 0 }}
- module: save-preprocessor
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.save-preprocessor > 0 }}
- module: test-analysis-core
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.test-analysis-core > 0 }}
- module: test-utils
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.test-utils > 0 }}
uses: ./.github/workflows/build_and_test_reusable.yml
with:
do-build: ${{ matrix.do-build }}
module: ${{ matrix.module }}
gradle-cache-read-only: ${{ github.ref != 'refs/heads/master' }}
build_and_test_with_code_coverage:
name: Build, test and upload code coverage
needs: [ build_all ]
runs-on: ubuntu-latest
steps:
- name: Download gradle reports
uses: actions/download-artifact@v4
- name: Code coverage report
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false