-
-
Notifications
You must be signed in to change notification settings - Fork 6
140 lines (121 loc) · 5.04 KB
/
smoke-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
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: 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: |
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: Execute Tests in Parallel
run: |
mkdir -p test_results
mkdir -p test_outputs
# 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
# Check if any tests failed
if [ -f test_failures ]; then
echo "The following test suites failed:"
cat test_failures
exit 1
fi
- name: Display Unit Tests Output
if: always()
run: |
cat test_outputs/unit.log
grep -q "Unit tests failed" test_failures && exit 1 || exit 0
- name: Display Feature Hyde Tests Output
if: always()
run: |
cat test_outputs/feature_hyde.log
grep -q "Feature Hyde tests failed" test_failures && exit 1 || exit 0
- name: Display Feature Framework Tests Output
if: always()
run: |
cat test_outputs/feature_framework.log
grep -q "Feature Framework tests failed" test_failures && exit 1 || exit 0
- name: Display Publications Tests Output
if: always()
run: |
cat test_outputs/publications.log
grep -q "Publications tests failed" test_failures && exit 1 || exit 0
- name: Display Realtime Compiler Tests Output
if: always()
run: |
cat test_outputs/realtime_compiler.log
grep -q "Realtime Compiler tests failed" test_failures && exit 1 || exit 0
- 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://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 }}