Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal: Parallel smoke testing #1928

Merged
merged 80 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
e2f4df8
Cleanup formatting
caendesilva Aug 2, 2024
4313f6d
Initial parallel coverage testing workflow
caendesilva Aug 2, 2024
a154e3e
Fix copying syntax
caendesilva Aug 2, 2024
95bc600
Fix testsuite syntax
caendesilva Aug 2, 2024
a8b1465
Execute tests in parallel
caendesilva Aug 2, 2024
110d342
Fix coverage merging
caendesilva Aug 2, 2024
5563f0a
Run coverage tests on PHP 8.3
caendesilva Aug 2, 2024
fc4cf2f
Create custom output formatter
caendesilva Aug 2, 2024
fed7291
Force unbuffered output
caendesilva Aug 2, 2024
9b66f5e
Revert "Force unbuffered output"
caendesilva Aug 2, 2024
1ce1ba5
Capture all output
caendesilva Aug 2, 2024
c74bff2
Revert "Capture all output"
caendesilva Aug 2, 2024
95d5662
Revert "Create custom output formatter "
caendesilva Aug 2, 2024
95e3b64
Prefix output lines
caendesilva Aug 2, 2024
0255c73
Retain formatting lost by sed prefixer
caendesilva Aug 2, 2024
8f2bf28
Set colors to always
caendesilva Aug 2, 2024
b1f4269
Merge the Junit XML reports
caendesilva Aug 2, 2024
825a13d
Match indentation
caendesilva Aug 2, 2024
288311e
Add debugging
caendesilva Aug 2, 2024
f64b2b4
Add debug
caendesilva Aug 2, 2024
7778626
Revert "Add debugging"
caendesilva Aug 2, 2024
1134fe5
Revert "Add debug"
caendesilva Aug 2, 2024
16da9a4
Revert "Merge the Junit XML reports"
caendesilva Aug 2, 2024
6ac0bd7
Manually merge the Junit XML reports
caendesilva Aug 2, 2024
25636f4
Revert "Manually merge the Junit XML reports"
caendesilva Aug 2, 2024
66731ea
Manually generate the Junit XML report
caendesilva Aug 2, 2024
876c71b
Test workflow issue
caendesilva Aug 2, 2024
f5b64db
Revert "Test workflow issue"
caendesilva Aug 2, 2024
9f9d917
Use a more robust approach with named pipes
caendesilva Aug 2, 2024
b5cf579
Refactor and add debugging
caendesilva Aug 2, 2024
f528fe2
Remove debug and add live output
caendesilva Aug 2, 2024
ceac4c8
Fix paths in the the merged coverage report
caendesilva Aug 2, 2024
c2412ae
Move back Git directory to root
caendesilva Aug 2, 2024
8e17b70
Cleanup workflow
caendesilva Aug 2, 2024
aa834fd
Update file path
caendesilva Aug 2, 2024
e39fa77
Add debug
caendesilva Aug 2, 2024
8e8bcf2
Reset coverage testing workflow
caendesilva Aug 2, 2024
845a510
Initial parallel smoke testing
caendesilva Aug 2, 2024
edcbdb4
Remove CI server integration
caendesilva Aug 2, 2024
ddad3b0
Use rsync
caendesilva Aug 2, 2024
9dd8a36
Adapt the parallel coverage workflow implementation
caendesilva Aug 2, 2024
ea437df
Fix checkout paths
caendesilva Aug 2, 2024
57e415a
Cleanup formatting
caendesilva Aug 2, 2024
4092e04
Merge Junit XML reports
caendesilva Aug 2, 2024
60b36f0
Dynamic padding
caendesilva Aug 2, 2024
ada3c8c
Run all feature test suites in parallel
caendesilva Aug 2, 2024
881a996
Improved live output
caendesilva Aug 2, 2024
f08bc16
Fix live output formatting
caendesilva Aug 2, 2024
974e318
Try to fix formatting
caendesilva Aug 2, 2024
d5142e3
Revert "Try to fix formatting"
caendesilva Aug 2, 2024
7affb09
Revert "Fix live output formatting"
caendesilva Aug 2, 2024
a132456
Revert "Improved live output"
caendesilva Aug 2, 2024
60a8150
Improved live output
caendesilva Aug 2, 2024
f4f15f8
Try to fix output
caendesilva Aug 2, 2024
663bfb8
Revert "Try to fix output"
caendesilva Aug 2, 2024
eb3ff87
Revert "Improved live output"
caendesilva Aug 2, 2024
3726e01
Improved live output
caendesilva Aug 2, 2024
fa5a29a
Lower level updates
caendesilva Aug 2, 2024
cd78f91
Simplify output
caendesilva Aug 2, 2024
66c9d1f
Optimize directory setup
caendesilva Aug 2, 2024
ecd4ffe
Revert "Optimize directory setup"
caendesilva Aug 2, 2024
304d964
Optimize directory setup
caendesilva Aug 2, 2024
78793c6
Fix setup syntax
caendesilva Aug 2, 2024
621df92
Revert "Fix setup syntax"
caendesilva Aug 2, 2024
22e6dc6
Revert "Optimize directory setup"
caendesilva Aug 2, 2024
617ca24
Time the directory setups
caendesilva Aug 2, 2024
241a472
Run directory setup in parallel
caendesilva Aug 2, 2024
e908729
Create symbolic links for other test directories
caendesilva Aug 2, 2024
4336f24
Remove stop on failure
caendesilva Aug 2, 2024
c412684
Fix formatting
caendesilva Aug 2, 2024
347fe9e
Fail when a test fails
caendesilva Aug 2, 2024
da0337c
Revert "Fix formatting"
caendesilva Aug 2, 2024
562e50c
Revert "Create symbolic links for other test directories"
caendesilva Aug 2, 2024
0ab60cf
Revert "Run directory setup in parallel"
caendesilva Aug 2, 2024
9d44f4f
Setup directories with parallel rsync
caendesilva Aug 2, 2024
281afea
Setup directories with parallel copy
caendesilva Aug 2, 2024
abf8d92
Create hard links for all suites
caendesilva Aug 2, 2024
d23e013
Move Composer validation to coverage testing workflow
caendesilva Aug 2, 2024
b0af9e5
Formatting
caendesilva Aug 2, 2024
a180d59
Cleanup workflow
caendesilva Aug 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/coverage-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
pull_request:

jobs:

test-coverage:
runs-on: ubuntu-latest
steps:
Expand All @@ -15,6 +14,9 @@ jobs:
extensions: fileinfo
- 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
Expand All @@ -41,4 +43,4 @@ jobs:
- name: Ping statistics server with test results
run: |
curl https://github.com/raw/hydephp/develop/6e9d17f31879f4ccda13a3fec4029c9663bccec0/monorepo/scripts/ping-openanalytics-testrunner.php -o ping.php
php ping.php "Monorepo Coverage Tests" ${{ secrets.OPENANALYTICS_TOKEN }} ${{ github.ref_name }}
php ping.php "Monorepo Coverage Tests" ${{ secrets.OPENANALYTICS_TOKEN }} ${{ github.ref_name }}
137 changes: 101 additions & 36 deletions .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,130 @@
# 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: 🔥 Smoke Tests
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: Checkout code
uses: actions/checkout@v4
with:
path: src

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
path: src/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
run: |
cd src && composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Run smoke tests
id: smoke-tests
run: vendor/bin/pest --stop-on-failure --log-junit report.xml
- name: Prepare test directories
run: |
setup_directory() {
local suite=$1
mkdir -p "${suite}_tests"
cp -al src/. "${suite}_tests/"
}

# Create hard links for all suites
for suite in unit feature_hyde feature_framework publications realtime_compiler; do
setup_directory $suite
done

# Move the .git directory out of src
mv src/.git .

- name: Ping continuous integration server with test status
if: always() && github.event.repository.full_name == 'hydephp/develop'
- name: Execute Tests in Parallel
run: |
bearerToken="${{ secrets.CI_SERVER_TOKEN }}"
commit="${{ github.event.pull_request.head.sha }}"
url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
mkdir -p test_results
mkdir -p test_outputs

# 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
# Function to run tests
run_tests() {
local suite=$1
local testsuite=$2
echo "${suite^} tests started"
cd ${suite}_tests
if vendor/bin/pest --colors=always --log-junit="../test_results/${suite}_junit.xml" --testsuite="$testsuite" > "../test_outputs/${suite}.log" 2>&1; then
echo "${suite^} tests completed successfully"
else
echo "${suite^} tests failed"
return 1
fi
}

# Run tests in parallel and capture exit codes
run_tests unit UnitFramework & pid1=$!
run_tests feature_hyde FeatureHyde & pid2=$!
run_tests feature_framework FeatureFramework & pid3=$!
run_tests publications Publications & pid4=$!
run_tests realtime_compiler "Realtime Compiler" & pid5=$!

# Wait for all background jobs to finish and capture exit codes
wait $pid1 || echo "Unit tests failed" >> test_failures
wait $pid2 || echo "Feature Hyde tests failed" >> test_failures
wait $pid3 || echo "Feature Framework tests failed" >> test_failures
wait $pid4 || echo "Publications tests failed" >> test_failures
wait $pid5 || echo "Realtime Compiler tests failed" >> test_failures

if [ ${{ steps.smoke-tests.outcome }} == "failure" ]; then
status=false
else
status=true
# Check if any tests failed
if [ -f test_failures ]; then
echo "The following test suites failed:"
cat test_failures
exit 1
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: Display Unit Tests Output
if: always()
run: cat test_outputs/unit.log

- name: Display Feature Hyde Tests Output
if: always()
run: cat test_outputs/feature_hyde.log

- name: Display Feature Framework Tests Output
if: always()
run: cat test_outputs/feature_framework.log

- name: Display Publications Tests Output
if: always()
run: cat test_outputs/publications.log

- name: Display Realtime Compiler Tests Output
if: always()
run: cat test_outputs/realtime_compiler.log

- name: Merge JUnit XML Reports
if: always()
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
if: always()
run: |
curl https://github.com/raw/hydephp/develop/6e9d17f31879f4ccda13a3fec4029c9663bccec0/monorepo/scripts/ping-openanalytics-testrunner.php -o ping.php
php ping.php "Monorepo Smoke Tests" ${{ secrets.OPENANALYTICS_TOKEN }} ${{ github.ref_name }}