From e6d46e072c8773d15a89dbd92e9becb6615dc088 Mon Sep 17 00:00:00 2001 From: Orkun Date: Mon, 2 Sep 2024 16:22:30 +0300 Subject: [PATCH] chore(coverage-diff): update diff base coverage calc and hide files section --- .github/workflows/coverage-diff.yml | 12 ++++++++++-- coverage.php | 5 ++++- 2 files changed, 14 insertions(+), 3 deletions(-) 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