Resolved (I think) test and check workflows

This commit is contained in:
Alicia Sykes committed 2025-09-22 22:44:27 +01:00
1 parent 6b7ff84275
commit d2875f1543
2 files changed
+43 -36

No files matched your search

+12 -3
View File
@@ -129,10 +129,19 @@ jobs:
line "$TEST" "Tests" "npm test"
line "$DEPS" "Dependencies" "npm audit --audit-level=high"
failed_count=$(echo "$BUILD $LINT $FORMAT $TYPES $SVCHK $TEST $DEPS" | tr ' ' '\n' | grep -c failure || echo "0")
if [ "$failed_count" -eq 0 ]; then
# Count failures properly
failures=0
[ "$BUILD" = "failure" ] && failures=$((failures + 1))
[ "$LINT" = "failure" ] && failures=$((failures + 1))
[ "$FORMAT" = "failure" ] && failures=$((failures + 1))
[ "$TYPES" = "failure" ] && failures=$((failures + 1))
[ "$SVCHK" = "failure" ] && failures=$((failures + 1))
[ "$TEST" = "failure" ] && failures=$((failures + 1))
[ "$DEPS" = "failure" ] && failures=$((failures + 1))
if [ "$failures" -eq 0 ]; then
echo -e "\n🎉 **All checks passed!**"
else
echo -e "\n⚠️ **$failed_count check(s) failed** - please fix the issues above before merging."
echo -e "\n⚠️ **$failures check(s) failed** - please fix the issues above before merging."
fi
} >> "$GITHUB_STEP_SUMMARY"
+31 -33
View File
@@ -103,15 +103,15 @@ jobs:
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}-chromium-firefox-${{ hashFiles('**/package-lock.json') }}
- name: Install Playwright
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps chromium
run: npx playwright install --with-deps chromium firefox
- name: Install Playwright deps only
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: npx playwright install-deps chromium
run: npx playwright install-deps chromium firefox
- name: Run e2e tests
id: test
@@ -163,6 +163,13 @@ jobs:
pattern: test-result-*
merge-multiple: true
- name: Get test reports
id: reports
run: |
# Get the test report URLs from the Check API
# Note: This is a simplified approach - in practice you'd use GitHub API
echo "Getting test report details..."
- name: Write summary
env:
UNIT_JOB: ${{ needs.unit-tests.result }}
@@ -175,44 +182,35 @@ jobs:
em() { case "$1" in success) echo "✅";; failure) echo "❌";; cancelled|skipped) echo "⏭️";; *) echo "❔";; esac; }
line() { r="$1"; n="$2"; cmd="$3"; s="Passing"; [ "$r" = "failure" ] && s="**Failing** - run \`$cmd\`"; [ "$r" = "skipped" ] && s="Skipped"; echo "- $(em "$r") $n: $s"; }
# Count test results for chart
passing=0; failing=0; skipped=0; unknown=0
for result in "$UNIT" "$E2E"; do
case "$result" in
success) passing=$((passing + 1)) ;;
failure) failing=$((failing + 1)) ;;
skipped) skipped=$((skipped + 1)) ;;
*) unknown=$((unknown + 1)) ;;
esac
done
# Calculate percentages for chart
total=$((passing + failing + skipped + unknown))
[ "$total" -eq 0 ] && total=1 # Avoid division by zero
pass_pct=$((passing * 100 / total))
fail_pct=$((failing * 100 / total))
skip_pct=$((skipped * 100 / total))
unkn_pct=$((unknown * 100 / total))
# Create QuickChart URL (simple URL encoding)
chart_config="{\"type\":\"pie\",\"data\":{\"labels\":[\"Passing\",\"Failing\",\"Skipped\",\"Unknown\"],\"datasets\":[{\"data\":[$pass_pct,$fail_pct,$skip_pct,$unkn_pct],\"backgroundColor\":[\"#50fa7b\",\"#ff5555\",\"#8be9fd\",\"#808080\"]}]},\"options\":{\"plugins\":{\"legend\":{\"position\":\"bottom\"}}}}"
# Simple URL encoding for the chart config
encoded_config=$(echo "$chart_config" | sed 's/ /%20/g; s/{/%7B/g; s/}/%7D/g; s/\[/%5B/g; s/\]/%5D/g; s/"/%22/g; s/:/%3A/g; s/,/%2C/g; s/#/%23/g')
chart_url="https://quickchart.io/chart?v=2.9.4&w=300&h=200&c=$encoded_config"
# Count failures
failures=0
[ "$UNIT" = "failure" ] && failures=$((failures + 1))
[ "$E2E" = "failure" ] && failures=$((failures + 1))
{
echo "## 🧪 Test Results"
echo ""
echo "![Test Results Chart]($chart_url)"
echo ""
line "$UNIT" "Unit Tests" "npm run test:coverage"
line "$E2E" "E2E Tests" "npm run test:e2e"
if [ "$failing" -eq 0 ]; then
if [ "$failures" -eq 0 ]; then
echo -e "\n🎉 **All test suites passed!**"
[ "$passing" -gt 0 ] && echo "📈 Coverage report may be available in [Codecov](https://codecov.io)"
[ "$UNIT" = "success" ] && echo "📈 Coverage report may be available in [Codecov](https://codecov.io)"
else
echo -e "\n⚠️ **$failing of $total test suite(s) failed**"
echo "📊 Check artifacts for detailed test reports"
echo -e "\n⚠️ **$failures test suite(s) failed**"
echo "📊 Check the detailed test reports below for more information"
fi
echo ""
echo "---"
echo ""
echo "### 📋 Detailed Test Reports"
echo ""
echo "The test reports below are generated by [dorny/test-reporter](https://github.com/dorny/test-reporter) and show detailed results for each test suite:"
echo ""
echo "- **Unit Tests**: Individual test results with execution times and failure details"
echo "- **E2E Tests**: Browser-based test results across Chromium and Firefox"
echo ""
echo "> 💡 **Tip**: Click on any failed test in the Checks tab to see detailed error information and stack traces."
} >> "$GITHUB_STEP_SUMMARY"