Skip to content

Commit 83ccaad

Browse files
fix: get test names
1 parent 13d0368 commit 83ccaad

File tree

1 file changed

+34
-17
lines changed

1 file changed

+34
-17
lines changed

.github/workflows/quality.yml

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -221,33 +221,46 @@ jobs:
221221
name: playwright-artifacts
222222
path: playwright-artifacts
223223

224-
- name: Count new tests
225-
id: count_tests
224+
- name: Extract test names and count
225+
id: test_info
226226
run: |
227227
git fetch origin main:main
228228
new_tests=0
229+
test_names=""
229230
230231
# Get list of changed test files
231232
for file in $(git diff --name-only main...HEAD | grep -E '^tests/suites/.*\.(spec|test)\.(ts|tsx|js|jsx)$'); do
232-
# Count tests in current version
233+
# Get test names from current version that don't exist in main
233234
if git show HEAD:"$file" > /dev/null 2>&1; then
234-
current_tests=$(git show HEAD:"$file" | grep -E "test\([\'\"]" | wc -l)
235-
else
236-
current_tests=0
235+
current_tests=$(git show HEAD:"$file" | grep -E "test\([\'\"]" | sed -E "s/.*test\(['\"]([^'\"]+)['\"].*/\1/")
236+
237+
# For each test in current version
238+
while IFS= read -r test_name; do
239+
if [ ! -z "$test_name" ]; then
240+
# Check if test exists in main version
241+
if git show main:"$file" > /dev/null 2>&1; then
242+
if ! git show main:"$file" | grep -q "test(['\"]$test_name['\"]"; then
243+
# Test doesn't exist in main - it's new
244+
test_names="$test_names- $test_name\n"
245+
((new_tests++))
246+
fi
247+
else
248+
# File doesn't exist in main - all tests are new
249+
test_names="$test_names- $test_name\n"
250+
((new_tests++))
251+
fi
252+
fi
253+
done <<< "$current_tests"
237254
fi
238-
239-
# Count tests in main version
240-
if git show main:"$file" > /dev/null 2>&1; then
241-
base_tests=$(git show main:"$file" | grep -E "test\([\'\"]" | wc -l)
242-
else
243-
base_tests=0
244-
fi
245-
246-
# Add difference to total
247-
((new_tests += current_tests - base_tests))
248255
done
249256
257+
# Escape newlines for GitHub Actions
258+
test_names="${test_names//'%'/'%25'}"
259+
test_names="${test_names//$'\n'/'%0A'}"
260+
test_names="${test_names//$'\r'/'%0D'}"
261+
250262
echo "new_tests=$new_tests" >> $GITHUB_OUTPUT
263+
echo "test_names=$test_names" >> $GITHUB_OUTPUT
251264
252265
- name: Update PR description
253266
uses: actions/github-script@v6
@@ -293,7 +306,8 @@ jobs:
293306
parseFloat(percent) > 0 ? '🔺' :
294307
parseFloat(percent) < 0 ? '🔽' : '✅';
295308
296-
const newTests = parseInt('${{ steps.count_tests.outputs.new_tests }}');
309+
const newTests = parseInt('${{ steps.test_info.outputs.new_tests }}');
310+
const testNames = '${{ steps.test_info.outputs.test_names }}'.replace(/%0A/g, '\n');
297311
const testsStatus = newTests > 0 ? '✨' : '➖';
298312
299313
const ciSection = `## CI Results
@@ -305,6 +319,9 @@ jobs:
305319
|:-----:|:------:|:------:|:-----:|:-------:|:---------:|
306320
| ${testResults.total} | ${testResults.passed} | ${testResults.failed} | ${testResults.flaky} | ${testResults.skipped} | ${testsStatus} ${newTests} |
307321
322+
${newTests > 0 ? `<details>
323+
<summary>✨ New Tests Added (${newTests})</summary>\n\n${testNames}\n</details>\n` : ''}
324+
308325
### Bundle Size: ${bundleStatus}
309326
Current: ${formatSize(currentSize)} | Main: ${formatSize(mainSize)}
310327
Diff: ${diff > 0 ? '+' : ''}${formatSize(Math.abs(diff))} (${percent === 'N/A' ? 'N/A' : `${percent}%`})

0 commit comments

Comments
 (0)