diff --git a/.github/workflows/test-integrations.yml b/.github/workflows/test-integrations.yml index 36f33c015..731045d8c 100644 --- a/.github/workflows/test-integrations.yml +++ b/.github/workflows/test-integrations.yml @@ -155,17 +155,24 @@ jobs: # multiplied by 8 based on these values: # envoy-version: ["1.22.11", "1.23.8", "1.24.6", "1.25.4"] # xds-target: ["server", "client"] - TOTAL_RUNNERS: 3 + TOTAL_RUNNERS: 4 JQ_SLICER: '[ inputs ] | [_nwise(length / $runnercount | floor)]' run: | + NUM_RUNNERS=$TOTAL_RUNNERS + NUM_DIRS=$(find ./test/integration/connect/envoy -maxdepth 1 -type d | wc -l) + if [ "$NUM_DIRS" -lt "$NUM_RUNNERS" ]; then + echo "TOTAL_RUNNERS is larger than the number of tests/packages to split." + NUM_RUNNERS=$NUM_DIRS + fi + # fix issue where test splitting calculation generates 1 more split than TOTAL_RUNNERS. + NUM_RUNNERS=$((NUM_RUNNERS-1)) { echo -n "envoy-matrix=" find ./test/integration/connect/envoy -maxdepth 1 -type d -print0 \ | xargs -0 -n 1 basename \ - | jq --raw-input --argjson runnercount "$TOTAL_RUNNERS" "$JQ_SLICER" \ + | jq --raw-input --argjson runnercount "$NUM_RUNNERS" "$JQ_SLICER" \ | jq --compact-output 'map(join("|"))' } >> "$GITHUB_OUTPUT" - cat "$GITHUB_OUTPUT" envoy-integration-test: runs-on: ${{ fromJSON(needs.setup.outputs.compute-xl) }} @@ -261,18 +268,25 @@ jobs: - name: Generate Compatibility Job Matrix id: set-matrix env: - TOTAL_RUNNERS: 5 + TOTAL_RUNNERS: 6 JQ_SLICER: '[ inputs ] | [_nwise(length / $runnercount | floor)]' run: | cd ./test/integration/consul-container + NUM_RUNNERS=$TOTAL_RUNNERS + NUM_DIRS=$(find ./test -maxdepth 2 -type d | wc -l) + if [ "$NUM_DIRS" -lt "$NUM_RUNNERS" ]; then + echo "TOTAL_RUNNERS is larger than the number of tests/packages to split." + NUM_RUNNERS=$NUM_DIRS + fi + # fix issue where test splitting calculation generates 1 more split than TOTAL_RUNNERS. + NUM_RUNNERS=$((NUM_RUNNERS-1)) { echo -n "compatibility-matrix=" find ./test -maxdepth 2 -type d -print0 | xargs -0 -n 1 \ | grep -v util | grep -v upgrade \ - | jq --raw-input --argjson runnercount "$TOTAL_RUNNERS" "$JQ_SLICER" \ + | jq --raw-input --argjson runnercount "$NUM_RUNNERS" "$JQ_SLICER" \ | jq --compact-output 'map(join(" "))' } >> "$GITHUB_OUTPUT" - cat "$GITHUB_OUTPUT" compatibility-integration-test: runs-on: ${{ fromJSON(needs.setup.outputs.compute-xl) }} needs: @@ -359,17 +373,24 @@ jobs: - name: Generate Updgrade Job Matrix id: set-matrix env: - TOTAL_RUNNERS: 4 + TOTAL_RUNNERS: 5 JQ_SLICER: '[ inputs ] | [_nwise(length / $runnercount | floor)]' run: | cd ./test/integration/consul-container/test/upgrade + NUM_RUNNERS=$TOTAL_RUNNERS + NUM_DIRS=$(go test ./... -list=. -json | jq -r '.Output | select (. !=null) | select(. | startswith("Test")) | gsub("[\\n\\t]"; "")' | wc -l) + if [ "$NUM_DIRS" -lt "$NUM_RUNNERS" ]; then + echo "TOTAL_RUNNERS is larger than the number of tests/packages to split." + NUM_RUNNERS=$NUM_DIRS + fi + # fix issue where test splitting calculation generates 1 more split than TOTAL_RUNNERS. + NUM_RUNNERS=$((NUM_RUNNERS-1)) { echo -n "upgrade-matrix=" go test ./... -list=. -json | jq -r '.Output | select (. !=null) | select(. | startswith("Test")) | gsub("[\\n\\t]"; "")' \ - | jq --raw-input --argjson runnercount "$TOTAL_RUNNERS" "$JQ_SLICER" \ + | jq --raw-input --argjson runnercount "$NUM_RUNNERS" "$JQ_SLICER" \ | jq --compact-output 'map(join("|"))' } >> "$GITHUB_OUTPUT" - cat "$GITHUB_OUTPUT" upgrade-integration-test: runs-on: ${{ fromJSON(needs.setup.outputs.compute-xl) }}