Skip to content

Internal: Parallel smoke testing #12329

Internal: Parallel smoke testing

Internal: Parallel smoke testing #12329

Workflow file for this run

# This workflow is especially helpful for pull requests to quickly see if the other tests will definitely fail.
# In order to get even quicker feedback, we also ping our Continuous Integration server to get a status check
# as soon as we know the outcome, as the GitHub Actions Pull Request UI takes a little bit to update.
name: 🔥 Parallel Smoke Tests
on:
pull_request:
jobs:
run-smoke-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate composer.json and composer.lock
run: composer validate --strict --no-check-all
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install Composer Dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Prepare test directories
run: |
mkdir unit_tests feature_tests
cp -R . unit_tests/
cp -R . feature_tests/
- name: Run Parallel Smoke Tests
id: smoke-tests
run: |
run_tests() {
local suite=$1
local testsuite=$2
cd ${suite}_tests
../vendor/bin/pest --stop-on-failure --log-junit ../${suite}_report.xml --testsuite="$testsuite" 2>&1 | sed -E "s/^/[${suite^^}] /"
}
(run_tests unit UnitFramework) &
(run_tests feature "FeatureHyde,FeatureFramework,Publications,Realtime Compiler") &
wait
- name: Combine Test Reports
if: always()
run: |
php -r '
$unit = simplexml_load_file("unit_report.xml");
$feature = simplexml_load_file("feature_report.xml");
$combined = new SimpleXMLElement("<?xml version=\"1.0\" encoding=\"UTF-8\"?><testsuites></testsuites>");
foreach ($unit->testsuite as $suite) $combined->addChild("testsuite", $suite);
foreach ($feature->testsuite as $suite) $combined->addChild("testsuite", $suite);
$combined->asXML("report.xml");
'
- name: Ping continuous integration server with test status
if: always() && github.event.repository.full_name == 'hydephp/develop'
run: |
bearerToken="${{ secrets.CI_SERVER_TOKEN }}"
commit="${{ github.event.pull_request.head.sha }}"
url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# If bearerToken is not set, we we exit early as we are probably running on a fork
if [ -z "$bearerToken" ]; then
echo "Exiting early as bearerToken is not set"
exit 0
fi
if [ ${{ steps.smoke-tests.outcome }} == "failure" ]; then
status=false
else
status=true
fi
curl -X POST --fail-with-body \
-H "Authorization: Bearer $bearerToken" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"commit":"'"$commit"'", "status":'$status', "url":"'"$url"'"}' \
https://ci.hydephp.com/api/test-run-reports
- 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 }}