@@ -1009,18 +1009,39 @@ jobs:
1009
1009
needs : setup
1010
1010
outputs :
1011
1011
matrix : ${{ steps.set-matrix.outputs.matrix }}
1012
+ cypress_batch_count : ${{ steps.set-batch-count.outputs.cypress_batch_count }}
1013
+ python_batch_count : ${{ steps.set-batch-count.outputs.python_batch_count }}
1012
1014
steps :
1015
+ - id : set-batch-count
1016
+ # Tests are split simply to ensure the configured number of batches for parallelization. This may need some
1017
+ # increase as a new tests added increase the duration where an additional parallel batch helps.
1018
+ # python_batch_count is used to split pytests in the smoke-test (batches of actual test functions)
1019
+ # cypress_batch_count is used to split the collection of cypress test specs into batches.
1020
+ run : |
1021
+ echo "cypress_batch_count=11" >> "$GITHUB_OUTPUT"
1022
+ echo "python_batch_count=5" >> "$GITHUB_OUTPUT"
1023
+
1013
1024
- id : set-matrix
1025
+ # For m batches for python and n batches for cypress, we need a test matrix of python x m + cypress x n.
1026
+ # while the github action matrix generation can handle these two parts individually, there isnt a way to use the
1027
+ # two generated matrices for the same job. So, produce that matrix with scripting and use the include directive
1028
+ # to add it to the test matrix.
1014
1029
run : |
1015
- if [ '${{ needs.setup.outputs.frontend_only }}' == 'true' ]; then
1016
- echo 'matrix=["cypress_suite1","cypress_rest"]' >> "$GITHUB_OUTPUT"
1017
- elif [ '${{ needs.setup.outputs.ingestion_only }}' == 'true' ]; then
1018
- echo 'matrix=["no_cypress_suite0","no_cypress_suite1"]' >> "$GITHUB_OUTPUT"
1019
- elif [[ '${{ needs.setup.outputs.backend_change }}' == 'true' || '${{ needs.setup.outputs.smoke_test_change }}' == 'true' ]]; then
1020
- echo 'matrix=["no_cypress_suite0","no_cypress_suite1","cypress_suite1","cypress_rest"]' >> "$GITHUB_OUTPUT"
1021
- else
1022
- echo 'matrix=[]' >> "$GITHUB_OUTPUT"
1030
+ python_batch_count=${{ steps.set-batch-count.outputs.python_batch_count }}
1031
+ python_matrix=$(printf "{\"test_strategy\":\"pytests\",\"batch\":\"0\",\"batch_count\":\"$python_batch_count\"}"; for ((i=1;i<python_batch_count;i++)); do printf ",{\"test_strategy\":\"pytests\", \"batch_count\":\"$python_batch_count\",\"batch\":\"%d\"}" $i; done)
1032
+
1033
+ cypress_batch_count=${{ steps.set-batch-count.outputs.cypress_batch_count }}
1034
+ cypress_matrix=$(printf "{\"test_strategy\":\"cypress\",\"batch\":\"0\",\"batch_count\":\"$cypress_batch_count\"}"; for ((i=1;i<cypress_batch_count;i++)); do printf ",{\"test_strategy\":\"cypress\", \"batch_count\":\"$cypress_batch_count\",\"batch\":\"%d\"}" $i; done)
1035
+
1036
+ includes=''
1037
+ if [[ "${{ needs.setup.outputs.frontend_only }}" == 'true' ]]; then
1038
+ includes=$cypress_matrix
1039
+ elif [ "${{ needs.setup.outputs.ingestion_only }}" == 'true' ]; then
1040
+ includes=$python_matrix
1041
+ elif [[ "${{ needs.setup.outputs.backend_change }}" == 'true' || "${{ needs.setup.outputs.smoke_test_change }}" == 'true' ]]; then
1042
+ includes="$python_matrix,$cypress_matrix"
1023
1043
fi
1044
+ echo "matrix={\"include\":[$includes] }" >> "$GITHUB_OUTPUT"
1024
1045
1025
1046
smoke_test :
1026
1047
name : Run Smoke Tests
@@ -1041,8 +1062,7 @@ jobs:
1041
1062
]
1042
1063
strategy :
1043
1064
fail-fast : false
1044
- matrix :
1045
- test_strategy : ${{ fromJson(needs.smoke_test_matrix.outputs.matrix) }}
1065
+ matrix : ${{ fromJson(needs.smoke_test_matrix.outputs.matrix) }}
1046
1066
if : ${{ always() && !failure() && !cancelled() && needs.smoke_test_matrix.outputs.matrix != '[]' }}
1047
1067
steps :
1048
1068
- name : Free up disk space
@@ -1218,6 +1238,8 @@ jobs:
1218
1238
CYPRESS_RECORD_KEY : ${{ secrets.CYPRESS_RECORD_KEY }}
1219
1239
CLEANUP_DATA : " false"
1220
1240
TEST_STRATEGY : ${{ matrix.test_strategy }}
1241
+ BATCH_COUNT : ${{ matrix.batch_count }}
1242
+ BATCH_NUMBER : ${{ matrix.batch }}
1221
1243
run : |
1222
1244
echo "$DATAHUB_VERSION"
1223
1245
./gradlew --stop
@@ -1228,25 +1250,25 @@ jobs:
1228
1250
if : failure()
1229
1251
run : |
1230
1252
docker ps -a
1231
- TEST_STRATEGY="-${{ matrix.test_strategy }}"
1253
+ TEST_STRATEGY="-${{ matrix.test_strategy }}-${{ matrix.batch }} "
1232
1254
source .github/scripts/docker_logs.sh
1233
1255
- name : Upload logs
1234
1256
uses : actions/upload-artifact@v3
1235
1257
if : failure()
1236
1258
with :
1237
- name : docker-logs-${{ matrix.test_strategy }}
1259
+ name : docker-logs-${{ matrix.test_strategy }}-${{ matrix.batch }}
1238
1260
path : " docker_logs/*.log"
1239
1261
retention-days : 5
1240
1262
- name : Upload screenshots
1241
1263
uses : actions/upload-artifact@v3
1242
1264
if : failure()
1243
1265
with :
1244
- name : cypress-snapshots-${{ matrix.test_strategy }}
1266
+ name : cypress-snapshots-${{ matrix.test_strategy }}-${{ matrix.batch }}
1245
1267
path : smoke-test/tests/cypress/cypress/screenshots/
1246
1268
- uses : actions/upload-artifact@v3
1247
1269
if : always()
1248
1270
with :
1249
- name : Test Results (smoke tests) ${{ matrix.test_strategy }}
1271
+ name : Test Results (smoke tests) ${{ matrix.test_strategy }} ${{ matrix.batch }}
1250
1272
path : |
1251
1273
**/build/reports/tests/test/**
1252
1274
**/build/test-results/test/**
0 commit comments