From 6524843765988027ce34f37dba73c71a01b82d4a Mon Sep 17 00:00:00 2001 From: erabii Date: Tue, 18 Jul 2023 22:02:47 +0300 Subject: [PATCH] Fix issue with balanced tests (#1384) --- .../action.yaml | 30 ++++++++++++++----- .github/workflows/maven.yaml | 1 + 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml index 13414b29..4093ab1a 100644 --- a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml +++ b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml @@ -90,7 +90,7 @@ runs: max_test_time_as_int=$(printf "%.0f\n" "$max_test_time") echo "max test time : $max_test_time_as_int" - number_of_instances=$(( $sum_of_all_tests_as_int / $max_test_time_as_int )) + number_of_instances=${NUMBER_OF_JOBS} echo "number of instances $number_of_instances" average_time_per_instance=$(( sum_of_all_tests_as_int / number_of_instances )) @@ -133,6 +133,15 @@ runs: echo "current index : ${CURRENT_INDEX}" tests_to_run_in_current_index=$tests_to_take_in_current_iteration echo "time of tests in current index : $sum" + + # this can be the case when we delete some tests in some PR for example + # the previous cache will contain more tests then we currently have, so some + # matrix instances will have no tests to run + if [[ "$sum" -eq "0" ]]; then + echo "no tests to run in current index, most probably this PR removed some tests" + tests_to_run_in_current_index='none' + fi + fi done @@ -188,13 +197,18 @@ runs: unset IFS for i in "${sliced_array[@]}"; do - filename="${i}.txt" - echo "searching for filename: ${filename}" - file=$(find . -name "${filename}") - echo "found file: ${file}" - result=$(cat "${file}" | grep 'elapsed' | awk '{print $12, $13}') - - echo "run test: ${i} in : ${result}" >> /tmp/test_times_${{ env.CURRENT_INDEX }}.txt + + # can be present in the last index as 'none,testA,testB' + if [[ "$i" -eq "none" ]]; then + echo "skipping 'none'" + else + filename="${i}.txt" + echo "searching for filename: ${filename}" + file=$(find . -name "${filename}") + echo "found file: ${file}" + result=$(cat "${file}" | grep 'elapsed' | awk '{print $12, $13}') + echo "run test: ${i} in : ${result}" >> /tmp/test_times_${{ env.CURRENT_INDEX }}.txt + fi done fi diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml index b9fd2b50..65802dcf 100644 --- a/.github/workflows/maven.yaml +++ b/.github/workflows/maven.yaml @@ -123,6 +123,7 @@ jobs: SEGMENT_DOWNLOAD_TIMEOUT_MINS: 30 # only run this one if there is a previous cache of test times if: needs.build.outputs.test_times_cache_present == 'true' + timeout-minutes: 60 strategy: fail-fast: true