Internal: Parallel smoke testing #12338
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 🔥 Parallel Smoke Tests | |
on: | |
pull_request: | |
jobs: | |
run-smoke-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
path: src | |
- name: Validate composer.json and composer.lock | |
run: | | |
cd src && composer validate --strict --no-check-all | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v4 | |
with: | |
path: src/vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php- | |
- name: Install Composer Dependencies | |
run: | | |
cd src && composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist | |
- name: Prepare test directories | |
run: | | |
for suite in unit feature_hyde feature_framework publications realtime_compiler; do | |
cp -R src ${suite}_tests | |
done | |
mv src/.git . | |
- name: Execute Tests in Parallel | |
run: | | |
mkdir -p test_results | |
# Function to run tests and update progress | |
run_tests() { | |
local suite=$1 | |
local testsuite=$2 | |
local padding="" | |
if [ "$suite" == "unit" ]; then | |
padding=" " | |
elif [ "$suite" == "feature_hyde" ] || [ "$suite" == "publications" ]; then | |
padding=" " | |
fi | |
cd ${suite}_tests | |
vendor/bin/pest --colors=always --stop-on-failure --log-junit="../test_results/${suite}_junit.xml" --testsuite="$testsuite" 2>&1 | tee "../test_results/${suite}_output.log" | while IFS= read -r line; do | |
echo "." >> "../test_results/${suite}_progress.txt" | |
done & | |
} | |
# Start all test suites | |
run_tests unit UnitFramework | |
run_tests feature_hyde FeatureHyde | |
run_tests feature_framework FeatureFramework | |
run_tests publications Publications | |
run_tests realtime_compiler "Realtime Compiler" | |
# Function to display progress | |
display_progress() { | |
while true; do | |
clear | |
echo "Test Progress:" | |
echo "[UNIT] $(cat test_results/unit_progress.txt 2>/dev/null || echo '')" | |
echo "[FEATURE_HYDE] $(cat test_results/feature_hyde_progress.txt 2>/dev/null || echo '')" | |
echo "[FEATURE_FRAMEWORK] $(cat test_results/feature_framework_progress.txt 2>/dev/null || echo '')" | |
echo "[PUBLICATIONS] $(cat test_results/publications_progress.txt 2>/dev/null || echo '')" | |
echo "[REALTIME_COMPILER] $(cat test_results/realtime_compiler_progress.txt 2>/dev/null || echo '')" | |
sleep 1 | |
done | |
} | |
# Start progress display in background | |
display_progress & | |
display_pid=$! | |
# Wait for all test suites to finish | |
wait | |
# Stop progress display | |
kill $display_pid | |
# Display final progress | |
clear | |
echo "Final Test Progress:" | |
echo "[UNIT] $(cat test_results/unit_progress.txt 2>/dev/null || echo '')" | |
echo "[FEATURE_HYDE] $(cat test_results/feature_hyde_progress.txt 2>/dev/null || echo '')" | |
echo "[FEATURE_FRAMEWORK] $(cat test_results/feature_framework_progress.txt 2>/dev/null || echo '')" | |
echo "[PUBLICATIONS] $(cat test_results/publications_progress.txt 2>/dev/null || echo '')" | |
echo "[REALTIME_COMPILER] $(cat test_results/realtime_compiler_progress.txt 2>/dev/null || echo '')" | |
- name: Display Unit Tests Output | |
run: cat test_results/unit_output.log | |
- name: Display Feature Hyde Tests Output | |
run: cat test_results/feature_hyde_output.log | |
- name: Display Feature Framework Tests Output | |
run: cat test_results/feature_framework_output.log | |
- name: Display Publications Tests Output | |
run: cat test_results/publications_output.log | |
- name: Display Realtime Compiler Tests Output | |
run: cat test_results/realtime_compiler_output.log | |
- name: Merge JUnit XML Reports | |
run: | | |
php -r ' | |
$files = glob("test_results/*_junit.xml"); | |
$totalTests = $totalAssertions = $totalTime = 0; | |
foreach ($files as $file) { | |
$xml = simplexml_load_file($file); | |
$totalTests += (int)$xml->testsuite["tests"]; | |
$totalAssertions += (int)$xml->testsuite["assertions"]; | |
$totalTime += (float)$xml->testsuite["time"]; | |
} | |
$output = sprintf( | |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites>\n <testsuite name=\"%s\" tests=\"%d\" assertions=\"%d\" errors=\"0\" failures=\"0\" skipped=\"0\" time=\"%.6f\">\n </testsuite>\n</testsuites>", | |
"H:\\monorepo\\phpunit.xml.dist", | |
$totalTests, | |
$totalAssertions, | |
$totalTime | |
); | |
file_put_contents("report.xml", $output); | |
' | |
- name: Ping statistics server with test results | |
run: | | |
curl https://raw.githubusercontent.com/hydephp/develop/6e9d17f31879f4ccda13a3fec4029c9663bccec0/monorepo/scripts/ping-openanalytics-testrunner.php -o ping.php | |
php ping.php "Monorepo Smoke Tests" ${{ secrets.OPENANALYTICS_TOKEN }} ${{ github.ref_name }} |