Skip to content

Commit f18bc9c

Browse files
feat: add codecov integration with test results upload (#13)
* feat: add codecov integration with test results upload - Add .codecov.yml configuration with project and patch coverage checks (0.05% threshold) - Configure jest to output test results in JUnit XML format using jest-junit reporter - Update pytest to output coverage in XML format and test results in JUnit XML format - Add codecov/codecov-action@v5 step to upload coverage from both jest (lcov) and pytest (xml) - Add codecov/test-results-action@v1 step to upload test results from both test suites - Set fail_ci_if_error: false for coverage upload to prevent blocking CI if codecov has issues - Use if: '!cancelled()' for test results upload to ensure results are uploaded even if tests fail Follows the same codecov configuration pattern as deepnote-internal and deepnote-toolkit repos. Note: CODECOV_TOKEN secret needs to be configured in repository settings for codecov uploads to work. * fix: address codecov configuration issues - Create coverage directory before pytest runs to ensure junit xml output succeeds - Fix codecov upload file paths (coverage.xml and coverage/lcov.info) - Configure jest-junit to output to coverage/junit.xml explicitly - Set coverageDirectory to ./coverage for consistency Addresses CodeRabbit review comments. * ci: fail job on upload failure * fix: set test results upload to fail CI on error Add fail_ci_if_error: true to test results upload step to ensure CI fails when codecov upload fails, matching the coverage upload configuration. --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 7ac4a8e commit f18bc9c

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

.codecov.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
target: auto
6+
threshold: 0.05%
7+
patch:
8+
default:
9+
target: auto
10+
threshold: 0.05%

.github/workflows/build.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ jobs:
4444
set -eux
4545
python -m pip install .[test]
4646
47-
pytest -vv -r ap --cov jupyterlab_deepnote
47+
mkdir -p coverage
48+
pytest -vv -r ap --cov jupyterlab_deepnote --cov-report=xml --junit-xml=coverage/pytest-results.xml
4849
jupyter server extension list
4950
jupyter server extension list 2>&1 | grep -ie "jupyterlab_deepnote.*OK"
5051
@@ -54,6 +55,21 @@ jobs:
5455
env:
5556
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5657

58+
- name: Upload coverage to Codecov
59+
uses: codecov/codecov-action@v5
60+
with:
61+
token: ${{ secrets.CODECOV_TOKEN }}
62+
files: coverage.xml,coverage/lcov.info
63+
fail_ci_if_error: true
64+
65+
- name: Upload test results to Codecov
66+
if: '!cancelled()'
67+
uses: codecov/test-results-action@v1
68+
with:
69+
token: ${{ secrets.CODECOV_TOKEN }}
70+
files: coverage/pytest-results.xml,coverage/junit.xml
71+
fail_ci_if_error: true
72+
5773
- name: Package the extension
5874
run: |
5975
set -eux

jest.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ module.exports = {
2222
'!src/**/*.d.ts',
2323
'!src/**/.ipynb_checkpoints/*'
2424
],
25+
coverageDirectory: './coverage',
2526
coverageReporters: ['lcov', 'text'],
27+
reporters: [
28+
'default',
29+
['jest-junit', { outputDirectory: './coverage', outputName: 'junit.xml' }]
30+
],
2631
testRegex: 'src/.*/.*.spec.ts[x]?$',
2732
transformIgnorePatterns: [`/node_modules/(?!${esModules}).+`]
2833
};

0 commit comments

Comments
 (0)