diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 36ff67aba..67c18ff59 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -60,26 +60,57 @@ jobs: export K6_BROWSER_EXECUTABLE_PATH=/usr/bin/google-chrome fi export K6_BROWSER_HEADLESS=true + + # run only two E2E tests in parallel + # the current runner is low on resources + max_concurrent_jobs=2 + current_jobs=0 + declare -a pids declare -a output_files + launch_job() { + local f="$1" + + local output_file="output_$(basename "$f" .js).txt" + output_files+=("$output_file") + + # Run the test in the background + ./k6extension run "$f" > "$output_file" 2>&1 & + local pid=$! + + pids+=($pid) + current_jobs=$((current_jobs + 1)) + } + for f in examples/*.js; do if [ "$f" == "examples/hosts.js" ] && [ "$RUNNER_OS" == "Windows" ]; then echo "skipping $f on Windows" continue fi - output_file="output_$(basename "$f" .js).txt" - output_files+=("$output_file") - ./k6extension run -q "$f" > "$output_file" 2>&1 & - pids+=($!) + + launch_job "$f" + + # If we've reached the maximum number of concurrent jobs, wait for one to finish + if [ "$current_jobs" -ge "$max_concurrent_jobs" ]; then + wait "${pids[0]}" + unset "pids[0]" + pids=("${pids[@]}") + current_jobs=$((current_jobs - 1)) + fi done - # Wait for each background job to finish and display its output - for i in "${!pids[@]}"; do - wait "${pids[$i]}" - echo "Output for job ${pids[$i]} (from file ${output_files[$i]}):" - cat "${output_files[$i]}" + # Wait for all remaining jobs to finish + for pid in "${pids[@]}"; do + wait "$pid" done + + # Output the results + for output_file in "${output_files[@]}"; do + echo "Output from file $output_file:" + cat "$output_file" + done + - name: Check screenshot if: matrix.go != 'tip' || matrix.platform != 'windows-latest' # TODO: Do something more sophisticated?