@@ -18,6 +18,10 @@ inputs:
1818 skip-schema-validation :
1919 description : " Skip schema validation step"
2020 default : true
21+ integration-test-forks :
22+ description : " Number of parallel forks for integration tests (auto-detect if not specified)"
23+ required : false
24+ default : " auto"
2125
2226runs :
2327 using : " composite"
@@ -147,10 +151,62 @@ runs:
147151 ./gradlew :prime-router:reloadSettings
148152 shell : bash
149153
154+ - name : Configure integration test parallelization
155+ if : inputs.run-integration-tests == 'true'
156+ shell : bash
157+ run : |
158+ # Auto-detect optimal parallelization based on runner specs
159+ CORES=$(nproc)
160+ MEMORY_GB=$(free -g | grep '^Mem' | awk '{print $2}')
161+
162+ if [ "${{ inputs.integration-test-forks }}" = "auto" ]; then
163+ # Conservative approach: use half the cores, with safety limits
164+ FORKS=$((CORES / 2))
165+ FORKS=$(( FORKS > 3 ? 3 : FORKS )) # Max 3 forks to reduce external API pressure
166+ FORKS=$(( FORKS < 1 ? 1 : FORKS )) # Min 1 fork
167+ else
168+ FORKS=${{ inputs.integration-test-forks }}
169+ fi
170+
171+ # Calculate memory per fork (leave some buffer for system)
172+ MEMORY_PER_FORK=$(( (MEMORY_GB * 80 / 100) / FORKS )) # 80% of total memory
173+ MEMORY_PER_FORK=$(( MEMORY_PER_FORK > 3 ? 3 : MEMORY_PER_FORK )) # Max 3GB per fork
174+ MEMORY_PER_FORK=$(( MEMORY_PER_FORK < 1 ? 1 : MEMORY_PER_FORK )) # Min 1GB per fork
175+
176+ echo "INTEGRATION_TEST_FORKS=$FORKS" >> $GITHUB_ENV
177+ echo "INTEGRATION_TEST_MEMORY=${MEMORY_PER_FORK}g" >> $GITHUB_ENV
178+
179+ echo "🖥️ Runner specifications detected:"
180+ echo " CPU cores available: $CORES"
181+ echo " Total memory: ${MEMORY_GB}GB"
182+ echo ""
183+ echo "🧪 Integration test configuration:"
184+ echo " Parallel forks: $FORKS"
185+ echo " Memory per fork: ${MEMORY_PER_FORK}GB"
186+ echo " Expected speedup: ~$((100 - (100 / FORKS)))% (theoretical)"
187+
150188 # Integrations tests require the metadata catalog
151- - name : Run Integration Tests
189+ - name : Run Integration Tests (Parallel with Resource Optimization)
152190 if : inputs.run-integration-tests == 'true'
153- run : ./gradlew :prime-router:testIntegration -Pshowtests
191+ run : |
192+ # Create a temporary gradle.properties with parallel settings
193+ echo "org.gradle.parallel=true" >> gradle.properties
194+ echo "org.gradle.workers.max=$INTEGRATION_TEST_FORKS" >> gradle.properties
195+ echo "org.gradle.jvmargs=-Xmx$INTEGRATION_TEST_MEMORY -XX:+UseParallelGC" >> gradle.properties
196+
197+ echo "📝 Gradle parallel configuration:"
198+ echo " Max workers: $INTEGRATION_TEST_FORKS"
199+ echo " JVM args: -Xmx$INTEGRATION_TEST_MEMORY -XX:+UseParallelGC"
200+ echo ""
201+
202+ # Run integration tests with parallel configuration and retry logic
203+ ./gradlew :prime-router:testIntegration -Pshowtests --continue || {
204+ echo "⚠️ First attempt failed, waiting 30s before retry..."
205+ sleep 30
206+ echo "🔄 Retrying integration tests with reduced parallelism..."
207+ echo "org.gradle.workers.max=1" >> gradle.properties
208+ ./gradlew :prime-router:testIntegration -Pshowtests --rerun-tasks
209+ }
154210 shell : bash
155211
156212 - name : Publish Integration Test Results
0 commit comments