-
Notifications
You must be signed in to change notification settings - Fork 34
400 lines (343 loc) · 17.3 KB
/
Copy path_CI_coverage.yml
File metadata and controls
400 lines (343 loc) · 17.3 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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
name: Run Code Coverage
on:
workflow_call:
inputs:
container-name:
required: true
type: string
description: "Unique name for docker container"
docker-compose-path:
required: true
type: string
description: "Path to check-in docker-compose.yml"
source-ref:
required: true
type: string
description: "Github reference for source code"
target-ref:
required: true
type: string
description: "Github reference for target code"
secrets:
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
NEO4J_USER:
required: true
NEO4J_PASS:
required: true
FACELESS_AUTHKEY:
required: true
FACELESS_NAME:
required: true
outputs:
target_cpp_coverage:
description: "The C++ Coverage for target"
value: ${{ jobs.target_coverage_job.outputs.target_cpp_value }}
target_py_coverage:
description: "The Python Coverage for target"
value: ${{ jobs.target_coverage_job.outputs.target_py_value }}
source_cpp_coverage:
description: "The C++ Coverage for source"
value: ${{ jobs.coverage_job.outputs.source_cpp_value }}
source_py_coverage:
description: "The Python Coverage for source"
value: ${{ jobs.coverage_job.outputs.source_py_value }}
source_prev_cpp_coverage:
description: "The C++ Coverage for source"
value: ${{ jobs.coverage_job.outputs.source_old_cpp_value }}
source_prev_py_coverage:
description: "The Python Coverage for source"
value: ${{ jobs.coverage_job.outputs.source_old_py_value }}
coverage_value_updated:
description: "Whether coverage for source has changed"
value: ${{ jobs.coverage_job.outputs.coverage_value_updated }}
permissions: read-all
jobs:
target_coverage_job:
name: Target Coverage
runs-on: ubuntu-latest
env:
TARGET_BRANCH_REF: ${{ inputs.target-ref }}
outputs:
target_cpp_value: ${{ steps.target_values.outputs.cpp }}
target_py_value: ${{ steps.target_values.outputs.py }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
ref: ${{ env.TARGET_BRANCH_REF }}
fetch-depth: 0
- name: Get Target Coverage Values
id: target_values
run: |
echo "cpp=$(cat .github/coverage/cpp.develop.coverage_value.txt || echo 0.00)" >> $GITHUB_OUTPUT
echo "py=$(cat .github/coverage/python.develop.coverage_value.txt || echo 0.00)" >> $GITHUB_OUTPUT
coverage_job:
name: Run Coverage
needs: [target_coverage_job]
runs-on: ubuntu-latest
env:
AWS_API_PORT: 9000
AWS_CONSOLE_PORT: 9001
SOURCE_CONTAINER_NAME: ${{ inputs.container-name }}
SOURCE_CONTAINER_TAG: "vdms:${{ inputs.container-name }}"
NEO4J_CONTAINER_NAME: ${{ inputs.container-name }}_neo4j
NEO_TEST_PORT: 7687
CHECKIN_DOCKERFILE: ${{ inputs.docker-compose-path }}
DOCKER_ARTIFACT_DIR: "Docker_artifacts"
SOURCE_BRANCH_REF: ${{ inputs.source-ref }}
outputs:
source_cpp_value: ${{ steps.report_coverage.outputs.source_coverage_cpp }}
source_py_value: ${{ steps.report_coverage.outputs.source_coverage_py }}
source_old_cpp_value: ${{ steps.report_coverage.outputs.source_old_cpp_value }}
source_old_py_value: ${{ steps.report_coverage.outputs.source_old_py_value }}
coverage_value_updated: ${{ steps.report_coverage.outputs.cov_changed }}
coverage_test_status: ${{ steps.report_coverage.outputs.coverage_test_status }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: true
- run: mkdir -p ${{ env.DOCKER_ARTIFACT_DIR }}
- name: Variables for Testing
shell: bash
id: test_params
run: |
set -x
# Get an open port btwn 50000 and 59999 for vdms local port
vdms_local_test_port=$(comm -23 <(seq 50000 59999 | sort) <(ss -Htan | awk '{print $4}' | cut -d':' -f2 | sort -u))
echo "VDMS_LOCAL_TEST_PORT=$(echo "$vdms_local_test_port" | shuf | head -n 1)" >> $GITHUB_OUTPUT
# Get an open port btwn 65000 and 65535 for neo4j
neo4j_test_port=$(comm -23 <(seq 65000 65535 | sort) <(ss -Htan | awk '{print $4}' | cut -d':' -f2 | sort -u) | shuf | head -n 1)
# echo "NEO_TEST_PORT=${neo4j_test_port}" >> $GITHUB_OUTPUT
# Copy old local develop coverage files
mv ${GITHUB_WORKSPACE}/.github/coverage/cpp.develop.coverage_report.txt ${GITHUB_WORKSPACE}/.github/coverage/cpp.old-develop.coverage_report.txt
mv ${GITHUB_WORKSPACE}/.github/coverage/cpp.develop.coverage_value.txt ${GITHUB_WORKSPACE}/.github/coverage/cpp.old-develop.coverage_value.txt
mv ${GITHUB_WORKSPACE}/.github/coverage/python.develop.coverage_report.txt ${GITHUB_WORKSPACE}/.github/coverage/python.old-develop.coverage_report.txt
mv ${GITHUB_WORKSPACE}/.github/coverage/python.develop.coverage_value.txt ${GITHUB_WORKSPACE}/.github/coverage/python.old-develop.coverage_value.txt
- name: Start Check-in Container
shell: bash
id: checkin_start
env:
VDMS_TEST_PORT: ${{ steps.test_params.outputs.VDMS_LOCAL_TEST_PORT }}
run: |
cd ${GITHUB_WORKSPACE}/.github/scripts
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \
AWS_API_PORT=${{ env.AWS_API_PORT }} \
AWS_CONSOLE_PORT=${{ env.AWS_CONSOLE_PORT }} \
AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \
NEO4J_CONTAINER_NAME=${{ env.NEO4J_CONTAINER_NAME }} \
NEO4J_ENDPOINT=neo4j://neo4j:${{ env.NEO_TEST_PORT }} \
NEO4J_PASS=${{ secrets.NEO4J_PASS }} \
NEO4J_USER=${{ secrets.NEO4J_USER }} \
NEO_TEST_PORT=${{ env.NEO_TEST_PORT }} \
SOURCE_CONTAINER_NAME=${{ env.SOURCE_CONTAINER_NAME }} \
VDMS_TEST_PORT=${{ env.VDMS_TEST_PORT }} \
docker compose up -d --build
sleep 15
# Save Image tag
VDMS_TAG_STR="vdms:${{ env.SOURCE_CONTAINER_NAME }}"
echo "$VDMS_TAG_STR"
echo "VDMS_TAG=${VDMS_TAG_STR}" >> $GITHUB_OUTPUT
# Commands for neo4j tests
COMMON_ARGS="--neo4j_username ${{ secrets.NEO4J_USER }} --neo4j_password ${{ secrets.NEO4J_PASS }} --neo4j_port ${{ env.NEO_TEST_PORT }}"
S3_ARGS="--minio_port ${{ env.AWS_API_PORT }} --minio_console_port ${{ env.AWS_CONSOLE_PORT }} -u ${{ secrets.AWS_ACCESS_KEY_ID }} -p ${{ secrets.AWS_SECRET_ACCESS_KEY }}"
CMD_STR_e2e_str="./run_all_tests.py --type_of_test neo --test_name 'Neo4JE2ETest.*' ${S3_ARGS} ${COMMON_ARGS} --neo4j_endpoint neo4j://neo4j:${{ env.NEO_TEST_PORT}}"
echo "CMD_STR_e2e=${CMD_STR_e2e_str}" >> $GITHUB_OUTPUT
CMD_STR_OpsIO_str="./run_all_tests.py --type_of_test neo --test_name 'OpsIOCoordinatorTest.*' ${S3_ARGS} ${COMMON_ARGS} --neo4j_endpoint neo4j://neo4j:${{ env.NEO_TEST_PORT }}"
echo "CMD_STR_OpsIO=${CMD_STR_OpsIO_str}" >> $GITHUB_OUTPUT
CMD_STR_bkend_str="./run_all_tests.py --type_of_test neo --test_name 'Neo4jBackendTest.*' ${COMMON_ARGS} --neo4j_endpoint neo4j://neo4j:${{ env.NEO_TEST_PORT }}"
echo "CMD_STR_bkend=${CMD_STR_bkend_str}" >> $GITHUB_OUTPUT
CMD_STR_hndle_str="./run_neo4j_tests.sh -t Neo4JHandlerTest ${S3_ARGS} ${COMMON_ARGS} -e neo4j://neo4j:${{ env.NEO_TEST_PORT}}"
echo "CMD_STR_hndle_str=${CMD_STR_hndle_str}" >> $GITHUB_OUTPUT
- name: Runner cleanup
run: |
# Check prior to Cleanup
echo "Pre-cleanup space:"
df -h
# Remove Java (JDKs)
sudo rm -rf /usr/lib/jvm
# Remove .NET SDKs
sudo rm -rf /usr/share/dotnet
# Remove Swift toolchain
sudo rm -rf /usr/share/swift
# Remove Haskell (GHC)
sudo rm -rf /usr/local/.ghcup
# Remove Julia
sudo rm -rf /usr/local/julia*
# Remove Android SDKs
sudo rm -rf /usr/local/lib/android
# Remove Chromium (optional if not using for browser tests)
sudo rm -rf /usr/local/share/chromium
# Remove Microsoft/Edge and Google Chrome builds
sudo rm -rf /opt/microsoft /opt/google
# Remove Azure CLI
sudo rm -rf /opt/az
# Remove PowerShell
sudo rm -rf /usr/local/share/powershell
# Remove CodeQL and other toolcaches
sudo rm -rf /opt/hostedtoolcache
docker system prune -af || true
docker builder prune -af || true
# Check
echo "Post-cleanup space:"
df -h
- name: Run Neo4J Tests
shell: bash
env:
CMD_STR_bkend: ${{ steps.checkin_start.outputs.CMD_STR_bkend }}
CMD_STR_e2e: ${{ steps.checkin_start.outputs.CMD_STR_e2e }}
CMD_STR_OpsIO: ${{ steps.checkin_start.outputs.CMD_STR_OpsIO }}
CMD_STR_hdnlr: ${{ steps.checkin_start.outputs.CMD_STR_hndle_str }}
VDMS_TEST_PORT: ${{ steps.test_params.outputs.VDMS_LOCAL_TEST_PORT }}
run: |
cd ${GITHUB_WORKSPACE}/.github/scripts
# E2E Test
echo "${{ env.CMD_STR_e2e }}"
docker exec -w /vdms/tests ${{ env.SOURCE_CONTAINER_NAME }} bash -c "python ${{ env.CMD_STR_e2e }}"
docker kill ${{ env.NEO4J_CONTAINER_NAME }} || true
sleep 15
# Restart Neo4j
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \
AWS_API_PORT=${{ env.AWS_API_PORT }} \
AWS_CONSOLE_PORT=${{ env.AWS_CONSOLE_PORT }} \
AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \
NEO4J_CONTAINER_NAME=${{ env.NEO4J_CONTAINER_NAME }} \
NEO4J_ENDPOINT=neo4j://neo4j:${{ env.NEO_TEST_PORT }} \
NEO4J_PASS=${{ secrets.NEO4J_PASS }} \
NEO4J_USER=${{ secrets.NEO4J_USER }} \
NEO_TEST_PORT=${{ env.NEO_TEST_PORT }} \
SOURCE_CONTAINER_NAME=${{ env.SOURCE_CONTAINER_NAME }} \
VDMS_TEST_PORT=${{ env.VDMS_TEST_PORT }} \
docker compose up -d neo4j
sleep 30
# Ops IO Test
echo "${{ env.CMD_STR_OpsIO }}"
docker exec -w /vdms/tests ${{ env.SOURCE_CONTAINER_NAME }} bash -c "python ${{ env.CMD_STR_OpsIO }}"
docker kill ${{ env.NEO4J_CONTAINER_NAME }} || true
sleep 15
# Restart Neo4j
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \
AWS_API_PORT=${{ env.AWS_API_PORT }} \
AWS_CONSOLE_PORT=${{ env.AWS_CONSOLE_PORT }} \
AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \
NEO4J_CONTAINER_NAME=${{ env.NEO4J_CONTAINER_NAME }} \
NEO4J_ENDPOINT=neo4j://neo4j:${{ env.NEO_TEST_PORT }} \
NEO4J_PASS=${{ secrets.NEO4J_PASS }} \
NEO4J_USER=${{ secrets.NEO4J_USER }} \
NEO_TEST_PORT=${{ env.NEO_TEST_PORT }} \
SOURCE_CONTAINER_NAME=${{ env.SOURCE_CONTAINER_NAME }} \
VDMS_TEST_PORT=${{ env.VDMS_TEST_PORT }} \
docker compose up -d neo4j
sleep 30
# Handler Test
echo "${{ env.CMD_STR_hdnlr }}"
docker exec -w /vdms/tests ${{ env.SOURCE_CONTAINER_NAME }} bash -c "${{ env.CMD_STR_hdnlr }}"
docker kill ${{ env.NEO4J_CONTAINER_NAME }} || true
sleep 15
- name: Run Remaining Tests
shell: bash
id: cov_value
run: |
# Run tests
docker exec -w / ${{ env.SOURCE_CONTAINER_NAME }} bash -c "./run_coverage_cpp.sh && ./run_coverage_py.sh"
# C++ results as variables
docker cp ${{ env.SOURCE_CONTAINER_NAME }}:/vdms/tests/coverage_report/cpp.new.coverage_report.txt ${GITHUB_WORKSPACE}/.github/coverage/cpp.new.coverage_report.txt
docker cp ${{ env.SOURCE_CONTAINER_NAME }}:/vdms/tests/coverage_report/cpp.new.coverage_value.txt ${GITHUB_WORKSPACE}/.github/coverage/cpp.new.coverage_value.txt
echo "coverage_value_cpp=$(cat ${GITHUB_WORKSPACE}/.github/coverage/cpp.new.coverage_value.txt)" >> $GITHUB_ENV
echo "pr_dev_value_cpp=$(cat ${GITHUB_WORKSPACE}/.github/coverage/cpp.old-develop.coverage_value.txt)" >> $GITHUB_ENV
# Python results as variables
docker cp ${{ env.SOURCE_CONTAINER_NAME }}:/vdms/tests/coverage_report/python.new.coverage_report.txt ${GITHUB_WORKSPACE}/.github/coverage/python.new.coverage_report.txt || true
docker cp ${{ env.SOURCE_CONTAINER_NAME }}:/vdms/tests/coverage_report/python.new.coverage_value.txt ${GITHUB_WORKSPACE}/.github/coverage/python.new.coverage_value.txt || true
echo "coverage_value_py=$(cat ${GITHUB_WORKSPACE}/.github/coverage/python.new.coverage_value.txt)" >> $GITHUB_ENV
echo "pr_dev_value_py=$(cat ${GITHUB_WORKSPACE}/.github/coverage/python.old-develop.coverage_value.txt)" >> $GITHUB_ENV
- name: Print out the logs
shell: bash
id: print_out_logs
if: ${{ always() }}
run: |
echo "print pip version"
docker exec ${{ env.SOURCE_CONTAINER_NAME }} pip -V || true
echo "Python version"
docker exec ${{ env.SOURCE_CONTAINER_NAME }} python --version || true
echo "Python3 version"
docker exec ${{ env.SOURCE_CONTAINER_NAME }} python3 --version || true
echo "Print out the logs"
echo "tests_stderr_log:"
docker exec ${{ env.SOURCE_CONTAINER_NAME }} cat /tmp/tests_output_dir/tests_stderr_log.log || true
echo "tests_stdout_log:"
docker exec ${{ env.SOURCE_CONTAINER_NAME }} cat /tmp/tests_output_dir/tests_stdout_log.log || true
echo "tls_stderr_log:"
docker exec ${{ env.SOURCE_CONTAINER_NAME }} cat /tmp/tests_output_dir/tls_stderr_log.log || true
echo "tls_stdout_log:"
docker exec ${{ env.SOURCE_CONTAINER_NAME }} cat /tmp/tests_output_dir/tls_stdout_log.log || true
echo "udf_local_stderr_log:"
docker exec ${{ env.SOURCE_CONTAINER_NAME }} cat /tmp/tests_output_dir/udf_local_stderr_log.log || true
echo "udf_local_stdout_log:"
docker exec ${{ env.SOURCE_CONTAINER_NAME }} cat /tmp/tests_output_dir/udf_local_stdout_log.log || true
echo "udf_server_stderr_log:"
docker exec ${{ env.SOURCE_CONTAINER_NAME }} cat /tmp/tests_output_dir/udf_server_stderr_log.log || true
echo "udf_server_stdout_log:"
docker exec ${{ env.SOURCE_CONTAINER_NAME }} cat /tmp/tests_output_dir/udf_server_stdout_log.log || true
echo "vdms_stderr_log:"
docker exec ${{ env.SOURCE_CONTAINER_NAME }} cat /tmp/tests_output_dir/vdms_stderr_log.log || true
echo "vdms_stdout_log:"
docker exec ${{ env.SOURCE_CONTAINER_NAME }} cat /tmp/tests_output_dir/vdms_stdout_log.log || true
echo "End of Print out the logs..."
- name: Docker Compose down
shell: bash
id: docker_compose_down
run: |
# Stops containers and removes containers, networks, volumes, and images
cd ${GITHUB_WORKSPACE}/.github/scripts
docker compose down
- name: Report Source Coverage
id: report_coverage
run: |
set -x
did_cov_change='false'
test_status='failed'
if [ "$pr_dev_value_cpp" != "$coverage_value_cpp" ]; then
did_cov_change='true'
fi
if [ "$pr_dev_value_py" != "$coverage_value_py" ]; then
did_cov_change='true'
fi
# If true, in future job, push latest coverage as develop (future target)
echo "cov_changed=${did_cov_change}" >> $GITHUB_OUTPUT
# CPP
if [[ -z $coverage_value_cpp ]]
then
exit 1
fi
echo "Source CPP Coverage: ${coverage_value_cpp}"
echo "source_coverage_cpp=${coverage_value_cpp}" >> $GITHUB_OUTPUT
echo "source_old_cpp_value=${pr_dev_value_cpp}" >> $GITHUB_OUTPUT
# echo "target_coverage_cpp=${target_value_cpp}" >> $GITHUB_OUTPUT
# Python
if [[ -z $coverage_value_py ]]
then
exit 1
fi
test_status='passed'
echo "Source Python Coverage: ${coverage_value_py}"
echo "source_coverage_py=${coverage_value_py}" >> $GITHUB_OUTPUT
echo "source_old_py_value=${pr_dev_value_py}" >> $GITHUB_OUTPUT
# echo "target_coverage_py=${target_value_py}" >> $GITHUB_OUTPUT
echo "coverage_test_status=${test_status}" >> $GITHUB_OUTPUT
- name: Upload New coverage results
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: coverage_artifact
path: .github/coverage/*.new.*.txt
if-no-files-found: error
retention-days: 1
- name: Cleanup Docker Containers
if: ${{ always() }}
run: |
docker kill ${{ env.SOURCE_CONTAINER_NAME }} || true
docker kill ${{ env.SOURCE_CONTAINER_NAME }}_tmp || true
docker kill ${{ env.NEO4J_CONTAINER_NAME }} || true
docker ps -a --filter status=exited --format {{.ID}} | xargs docker rm || true
docker rmi $(docker images | grep '<none>' | awk '{print $3}') || true
docker builder prune -f