Skip to content

Commit a1a69d3

Browse files
committed
chore(ci): Simplify the logic and error handling for combining coverage
1 parent 919d72d commit a1a69d3

File tree

1 file changed

+6
-45
lines changed

1 file changed

+6
-45
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,9 @@ jobs:
334334
run: poetry install --no-interaction --only-root
335335

336336
- name: Run unit tests
337-
id: test-unit
338337
env:
339338
TOOLKIT_VERSION: ${{ steps.version.outputs.VERSION }}
340-
PYTHON_VERSION: ${{ matrix.python-version }}
341339
run: |
342-
set -euo pipefail
343-
344340
poetry run pytest tests/unit \
345341
--cov=deepnote_toolkit \
346342
--cov=installer \
@@ -350,31 +346,19 @@ jobs:
350346
--junitxml=junit.xml \
351347
-o junit_family=legacy
352348
353-
# Check if coverage data was generated
354-
if [ ! -f ".coverage" ]; then
355-
echo "Error: No coverage data file generated"
356-
echo "coverage_generated=false" >> $GITHUB_OUTPUT
357-
exit 1
358-
fi
359-
360-
echo "Coverage data generated successfully"
361-
echo "coverage_generated=true" >> $GITHUB_OUTPUT
362-
363349
- name: Per-version coverage summary
364-
if: steps.test-unit.outputs.coverage_generated == 'true'
365350
run: |
366351
echo "## Python ${{ matrix.python-version }} Coverage" >> $GITHUB_STEP_SUMMARY
367352
poetry run coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
368353
369-
- name: Upload test results to Codecov (these are results not coverage reports)
354+
- name: Upload test results to Codecov
370355
if: ${{ !cancelled() }}
371356
uses: codecov/test-results-action@47f89e9acb64b76debcd5ea40642d25a4adced9f # v1
372357
with:
373358
token: ${{ secrets.CODECOV_TOKEN }}
374359
flags: python-${{ matrix.python-version }}
375360

376361
- name: Upload coverage artifacts
377-
if: steps.test-unit.outputs.coverage_generated == 'true'
378362
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
379363
with:
380364
name: coverage-${{ matrix.python-version }}
@@ -409,46 +393,24 @@ jobs:
409393
path: coverage-artifacts/
410394

411395
- name: Combine coverage files
412-
id: combine
413396
run: |
414-
set -euo pipefail
415-
416-
# Collect all .coverage files from artifact subdirectories
417-
echo "Collecting coverage files from artifact subdirectories"
418397
shopt -s nullglob
419-
coverage_files=(coverage-artifacts/*/.coverage)
420-
421-
if [ ${#coverage_files[@]} -eq 0 ]; then
422-
echo "No coverage files to combine (tests may have failed)"
423-
echo "success=false" >> $GITHUB_OUTPUT
424-
exit 0
425-
fi
426-
427-
echo "Found ${#coverage_files[@]} coverage file(s) to combine"
428-
429-
# Rename each file to include a unique suffix for coverage combine
430398
mkdir -p coverage-data
399+
431400
i=0
432-
for file in "${coverage_files[@]}"; do
401+
for file in coverage-artifacts/*/.coverage; do
433402
cp "$file" "coverage-data/.coverage.$i"
434403
i=$((i + 1))
435404
done
436405
437-
echo "Running coverage combine from workspace root..."
438-
coverage combine coverage-data/ || { echo "coverage combine failed"; exit 1; }
439-
440-
echo "Generating XML report..."
441-
coverage xml -o coverage-data/coverage.xml || { echo "coverage xml failed"; exit 1; }
442-
443-
echo "Generating text report..."
444-
coverage report || { echo "coverage report failed"; exit 1; }
406+
coverage combine coverage-data/
407+
coverage xml -o coverage-data/coverage.xml
408+
coverage report
445409
446410
echo "## Combined Coverage Report" >> $GITHUB_STEP_SUMMARY
447411
coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
448-
echo "success=true" >> $GITHUB_OUTPUT
449412
450413
- name: Upload combined coverage to Codecov
451-
if: steps.combine.outputs.success == 'true'
452414
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5
453415
with:
454416
token: ${{ secrets.CODECOV_TOKEN }}
@@ -459,7 +421,6 @@ jobs:
459421
fail_ci_if_error: ${{ github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push' }}
460422

461423
- name: Upload combined coverage report
462-
if: steps.combine.outputs.success == 'true'
463424
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
464425
with:
465426
name: coverage-combined-report

0 commit comments

Comments
 (0)