diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index a24c1cd..a982926 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -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" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5cc0ccd..4c01584 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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"