22# SPDX-License-Identifier: MIT
33
44name : PR Test
5+ permissions :
6+ id-token : write
7+ contents : read
58env :
69 TERRAFORM_AWS_ASSUME_ROLE : ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }}
710 TERRAFORM_AWS_ASSUME_ROLE_DURATION : 14400 # 4 hours
@@ -118,7 +121,12 @@ jobs:
118121 if : needs.CheckLabel.outputs.should_run == 'true'
119122 runs-on : ubuntu-latest
120123 outputs :
121- ec2_linux_matrix : ${{ steps.set-matrix.outputs.ec2_linux_matrix }}
124+ ec2_linux_matrix_0 : ${{ steps.paginate-matrix.outputs.ec2_linux_matrix_0 }}
125+ ec2_linux_matrix_1 : ${{ steps.paginate-matrix.outputs.ec2_linux_matrix_1 }}
126+ ec2_linux_matrix_2 : ${{ steps.paginate-matrix.outputs.ec2_linux_matrix_2 }}
127+ ec2_linux_matrix_3 : ${{ steps.paginate-matrix.outputs.ec2_linux_matrix_3 }}
128+ ec2_linux_matrix_4 : ${{ steps.paginate-matrix.outputs.ec2_linux_matrix_4 }}
129+ ec2_linux_matrix_page_count : ${{ steps.paginate-matrix.outputs.ec2_linux_matrix_page_count }}
122130 ec2_selinux_matrix : ${{ steps.set-matrix.outputs.ec2_selinux_matrix }}
123131
124132 steps :
@@ -149,15 +157,39 @@ jobs:
149157 MATRIX=$(jq -c -r '@json' filtered_matrix_selinux.json)
150158 echo "ec2_selinux_matrix=$MATRIX" >> $GITHUB_OUTPUT
151159
160+ - name : Paginate ec2_linux_matrix
161+ id : paginate-matrix
162+ run : |
163+ # GitHub Actions matrix limit is 256 jobs per workflow run.
164+ # Use 200 per page for headroom. Up to 5 pages supported (1000 tests).
165+ # The ec2_linux_matrix is @json-encoded (double-encoded), so decode first.
166+ PAGE_SIZE=200
167+ FULL_MATRIX=$(echo '${{ steps.set-matrix.outputs.ec2_linux_matrix }}' | jq -r '.')
168+ TOTAL=$(echo "$FULL_MATRIX" | jq 'length')
169+ PAGE_COUNT=$(( (TOTAL + PAGE_SIZE - 1) / PAGE_SIZE ))
170+
171+ if [ "$PAGE_COUNT" -gt 5 ]; then
172+ echo "::error::ec2_linux_matrix has $TOTAL entries requiring $PAGE_COUNT pages, but only 5 are supported. Add more static page slots."
173+ exit 1
174+ fi
175+
176+ echo "ec2_linux total=$TOTAL pages=$PAGE_COUNT"
177+ echo "ec2_linux_matrix_page_count=${PAGE_COUNT}" >> "$GITHUB_OUTPUT"
178+
179+ for (( i=0; i<PAGE_COUNT; i++ )); do
180+ START=$(( i * PAGE_SIZE ))
181+ PAGE=$(echo "$FULL_MATRIX" | jq -c ".[$START:$START+$PAGE_SIZE]" | jq -c -r '@json')
182+ echo "ec2_linux_matrix_${i}=${PAGE}" >> "$GITHUB_OUTPUT"
183+ done
152184
153185 - name : Echo test plan matrix
154186 run : |
155- echo "ec2_linux_matrix: ${{ steps.set -matrix.outputs.ec2_linux_matrix }}"
187+ echo "ec2_linux_matrix pages : ${{ steps.paginate -matrix.outputs.ec2_linux_matrix_page_count }}"
156188 echo "ec2_selinux_matrix: ${{ steps.set-matrix.outputs.ec2_selinux_matrix }}"
157189
158190
159- EC2LinuxIntegrationTest :
160- name : ' EC2LinuxTests'
191+ EC2LinuxIntegrationTest-0 :
192+ name : ' EC2LinuxTests-0 '
161193 needs : [ CheckLabel, GenerateTestMatrix, OutputEnvVariables, StartLocalStack, BuildAndUpload ]
162194 if : needs.CheckLabel.outputs.should_run == 'true'
163195 uses : ./.github/workflows/ec2-integration-test.yml
@@ -167,8 +199,100 @@ jobs:
167199 with :
168200 build_id : ${{ github.sha }}
169201 test_dir : terraform/ec2/linux
170- job_id : ec2-linux-integration-test
171- test_props : ${{ needs.GenerateTestMatrix.outputs.ec2_linux_matrix }}
202+ job_id : ec2-linux-integration-test-0
203+ test_props : ${{ needs.GenerateTestMatrix.outputs.ec2_linux_matrix_0 }}
204+ test_repo_name : ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }}
205+ test_repo_url : ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_URL }}
206+ test_repo_branch : ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}
207+ localstack_host : ${{ needs.StartLocalStack.outputs.local_stack_host_name }}
208+ region : us-west-2
209+ terraform_assume_role : ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }}
210+ s3_integration_bucket : ${{ vars.S3_INTEGRATION_BUCKET }}
211+ is_selinux_test : false
212+ secrets : inherit
213+
214+ EC2LinuxIntegrationTest-1 :
215+ name : ' EC2LinuxTests-1'
216+ needs : [ CheckLabel, GenerateTestMatrix, OutputEnvVariables, StartLocalStack, BuildAndUpload ]
217+ if : ${{ needs.CheckLabel.outputs.should_run == 'true' && needs.GenerateTestMatrix.outputs.ec2_linux_matrix_page_count > 1 }}
218+ uses : ./.github/workflows/ec2-integration-test.yml
219+ permissions :
220+ id-token : write
221+ contents : read
222+ with :
223+ build_id : ${{ github.sha }}
224+ test_dir : terraform/ec2/linux
225+ job_id : ec2-linux-integration-test-1
226+ test_props : ${{ needs.GenerateTestMatrix.outputs.ec2_linux_matrix_1 }}
227+ test_repo_name : ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }}
228+ test_repo_url : ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_URL }}
229+ test_repo_branch : ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}
230+ localstack_host : ${{ needs.StartLocalStack.outputs.local_stack_host_name }}
231+ region : us-west-2
232+ terraform_assume_role : ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }}
233+ s3_integration_bucket : ${{ vars.S3_INTEGRATION_BUCKET }}
234+ is_selinux_test : false
235+ secrets : inherit
236+
237+ EC2LinuxIntegrationTest-2 :
238+ name : ' EC2LinuxTests-2'
239+ needs : [ CheckLabel, GenerateTestMatrix, OutputEnvVariables, StartLocalStack, BuildAndUpload ]
240+ if : ${{ needs.CheckLabel.outputs.should_run == 'true' && needs.GenerateTestMatrix.outputs.ec2_linux_matrix_page_count > 2 }}
241+ uses : ./.github/workflows/ec2-integration-test.yml
242+ permissions :
243+ id-token : write
244+ contents : read
245+ with :
246+ build_id : ${{ github.sha }}
247+ test_dir : terraform/ec2/linux
248+ job_id : ec2-linux-integration-test-2
249+ test_props : ${{ needs.GenerateTestMatrix.outputs.ec2_linux_matrix_2 }}
250+ test_repo_name : ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }}
251+ test_repo_url : ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_URL }}
252+ test_repo_branch : ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}
253+ localstack_host : ${{ needs.StartLocalStack.outputs.local_stack_host_name }}
254+ region : us-west-2
255+ terraform_assume_role : ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }}
256+ s3_integration_bucket : ${{ vars.S3_INTEGRATION_BUCKET }}
257+ is_selinux_test : false
258+ secrets : inherit
259+
260+ EC2LinuxIntegrationTest-3 :
261+ name : ' EC2LinuxTests-3'
262+ needs : [ CheckLabel, GenerateTestMatrix, OutputEnvVariables, StartLocalStack, BuildAndUpload ]
263+ if : ${{ needs.CheckLabel.outputs.should_run == 'true' && needs.GenerateTestMatrix.outputs.ec2_linux_matrix_page_count > 3 }}
264+ uses : ./.github/workflows/ec2-integration-test.yml
265+ permissions :
266+ id-token : write
267+ contents : read
268+ with :
269+ build_id : ${{ github.sha }}
270+ test_dir : terraform/ec2/linux
271+ job_id : ec2-linux-integration-test-3
272+ test_props : ${{ needs.GenerateTestMatrix.outputs.ec2_linux_matrix_3 }}
273+ test_repo_name : ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }}
274+ test_repo_url : ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_URL }}
275+ test_repo_branch : ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}
276+ localstack_host : ${{ needs.StartLocalStack.outputs.local_stack_host_name }}
277+ region : us-west-2
278+ terraform_assume_role : ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }}
279+ s3_integration_bucket : ${{ vars.S3_INTEGRATION_BUCKET }}
280+ is_selinux_test : false
281+ secrets : inherit
282+
283+ EC2LinuxIntegrationTest-4 :
284+ name : ' EC2LinuxTests-4'
285+ needs : [ CheckLabel, GenerateTestMatrix, OutputEnvVariables, StartLocalStack, BuildAndUpload ]
286+ if : ${{ needs.CheckLabel.outputs.should_run == 'true' && needs.GenerateTestMatrix.outputs.ec2_linux_matrix_page_count > 4 }}
287+ uses : ./.github/workflows/ec2-integration-test.yml
288+ permissions :
289+ id-token : write
290+ contents : read
291+ with :
292+ build_id : ${{ github.sha }}
293+ test_dir : terraform/ec2/linux
294+ job_id : ec2-linux-integration-test-4
295+ test_props : ${{ needs.GenerateTestMatrix.outputs.ec2_linux_matrix_4 }}
172296 test_repo_name : ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }}
173297 test_repo_url : ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_URL }}
174298 test_repo_branch : ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}
@@ -204,7 +328,7 @@ jobs:
204328
205329 StopLocalStack :
206330 name : ' StopLocalStack'
207- needs : [ CheckLabel, StartLocalStack, EC2LinuxIntegrationTest, OutputEnvVariables ]
331+ needs : [ CheckLabel, StartLocalStack, EC2LinuxIntegrationTest-0, EC2LinuxIntegrationTest-1, EC2LinuxIntegrationTest-2, EC2LinuxIntegrationTest-3, EC2LinuxIntegrationTest-4 , OutputEnvVariables ]
208332 if : ${{ always() && needs.StartLocalStack.result == 'success' && needs.CheckLabel.outputs.should_run == 'true'}}
209333 uses : ./.github/workflows/stop-localstack.yml
210334 secrets : inherit
@@ -240,8 +364,9 @@ jobs:
240364 verify-all :
241365 name : Verify All PR Test Jobs
242366 needs : [IntegrationTestGate, CheckLabel, BuildAndUpload, OutputEnvVariables, StartLocalStack,
243- GenerateTestMatrix, EC2LinuxIntegrationTest, EC2SELinuxIntegrationTest,
244- StopLocalStack]
367+ GenerateTestMatrix, EC2LinuxIntegrationTest-0, EC2LinuxIntegrationTest-1,
368+ EC2LinuxIntegrationTest-2, EC2LinuxIntegrationTest-3, EC2LinuxIntegrationTest-4,
369+ EC2SELinuxIntegrationTest, StopLocalStack]
245370 runs-on : ubuntu-latest
246371 if : always()
247372 steps :
0 commit comments