diff --git a/.github/workflows/coverage-diff.yml b/.github/workflows/coverage-diff.yml index 2208cc05..87530a4f 100644 --- a/.github/workflows/coverage-diff.yml +++ b/.github/workflows/coverage-diff.yml @@ -64,8 +64,16 @@ jobs: - name: Create coverage report for Base id: base_coverage run: | - php ./coverage.php - COVERAGE_BASE=$(jq -r '.total.statements.pct' cov/json/index.json) + COVERAGE_BASE=0 + + if [ -f "./coverage.php" ]; then + php ./coverage.php + fi + + if [ -f "cov/json/index.json" ]; then + COVERAGE_BASE=$(jq -r '.total.statements.pct' cov/json/index.json) + fi + echo "COVERAGE_BASE=$COVERAGE_BASE" >> $GITHUB_ENV - name: Compare coverage diff --git a/coverage.php b/coverage.php index 66c58b01..69b86d02 100644 --- a/coverage.php +++ b/coverage.php @@ -40,7 +40,8 @@ $percentage ); -$markdown .= "\n## Files Coverage\n\n"; +$markdown .= "\n
\n"; +$markdown .= "Files Coverage\n\n"; $markdown .= "| File | Methods | Conditionals | Statements | Total Coverage |\n"; $markdown .= "|------|-------------------|-------------------------|------------------------|----------------|\n"; @@ -66,4 +67,6 @@ ); } +$markdown .= "\n
\n"; + file_put_contents($markdownPath . "coverage_report.md", $markdown); \ No newline at end of file