Skip to content

Commit 5c8f3a8

Browse files
pauldrucePrabhakar Kumar
authored and
Prabhakar Kumar
committed
Updates to Code Coverage Collection
1 parent 2b556d2 commit 5c8f3a8

File tree

10 files changed

+78
-71
lines changed

10 files changed

+78
-71
lines changed

.coveragerc

-2
This file was deleted.

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020-2023 The MathWorks, Inc
1+
# Copyright 2020-2023 The MathWorks, Inc
22

33
# Workflow to release MATLAB Jupyter Integration to PyPi
44
name: Release to PyPI
@@ -64,4 +64,4 @@ jobs:
6464
user: __token__
6565
verbose: true
6666
password: ${{ secrets.PYPI_TOKEN }}
67-
repository_url: ${{ secrets.PYPI_REPOSITORY_URL }}
67+
repository_url: ${{ secrets.PYPI_REPOSITORY_URL }}

.github/workflows/run-tests.yml

+24-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020-2023 The MathWorks, Inc
1+
# Copyright 2020-2023 The MathWorks, Inc
22

33
# Workflow that contains jobs to test MATLAB Jupyter Integration
44
name: Testing MATLAB Jupyter Integration
@@ -11,11 +11,13 @@ on:
1111
jobs:
1212
python_tests:
1313
runs-on: ubuntu-latest
14+
env:
15+
code-cov-py: "3.10"
1416
strategy:
1517
fail-fast: false
1618
matrix:
17-
python-version: ['3.7', '3.8', '3.9', '3.10']
18-
19+
python-version: ["3.7", "3.8", "3.9", "3.10"]
20+
name: "Run Python Tests with Python ${{matrix.python-version}}"
1921
steps:
2022
- name: Checkout
2123
uses: actions/checkout@v3
@@ -38,33 +40,34 @@ jobs:
3840
run: black --check .
3941

4042
- name: Test with pytest
43+
if: ${{ matrix.python-version != env.code-cov-py }}
4144
run: python3 -m pytest
4245

43-
generate_and_upload_code_coverage:
46+
- name: Test with pytest and get code coverage for Python ${{env.code-cov-py}}
47+
if: ${{matrix.python-version == env.code-cov-py }}
48+
run: python3 -m pytest --cov --cov-report=xml
49+
50+
- name: Persist coverage data to be uploaded if all jobs are successful.
51+
if: ${{matrix.python-version == env.code-cov-py }}
52+
uses: actions/upload-artifact@v3
53+
with:
54+
name: coverage_file
55+
path: ./coverage.xml
56+
retention-days: 5
57+
58+
upload_code_coverage:
59+
name: "Upload Code Coverage using codecov"
4460
needs: [python_tests]
4561
if: success()
4662
runs-on: ubuntu-latest
4763
steps:
48-
- name: Checkout
49-
uses: actions/checkout@v3
50-
51-
- name: Set up Python 3.7
52-
uses: actions/setup-python@v4
64+
- name: Get coverage files from previous job
65+
uses: actions/download-artifact@v3
5366
with:
54-
python-version: 3.7
55-
56-
- name: Install Python build dependencies
57-
run: |
58-
python -m pip install --upgrade pip
59-
python3 -m pip install wheel pytest
60-
python3 -m pip install .[dev]
61-
62-
- name: Generate Code Coverage report for Python code
63-
run: |
64-
pytest --cov=./ --cov-report=xml
67+
name: coverage_file
6568

6669
- name: Upload python coverage report to Codecov
67-
uses: codecov/codecov-action@v2
70+
uses: codecov/codecov-action@v3
6871
with:
6972
directory: ./
7073
name: Python-codecov

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ dist/
66
.venv/
77
.vscode/
88
htmlcov/
9-
.coverage
9+
.coverage
10+
coverage.xml
11+
cov_html

pyproject.toml

+38-36
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
# Copyright 2023 The MathWorks, Inc.
2+
13
[build-system]
2-
requires = [
3-
"jupyterlab>=3.1",
4-
"hatchling"
5-
]
4+
requires = ["jupyterlab>=3.1,<4.0.0", "hatchling"]
65
build-backend = "hatchling.build"
76

87
[project]
@@ -25,7 +24,7 @@ keywords = [
2524
"MATLAB Web Desktop",
2625
"Remote MATLAB Web Access",
2726
"JupyterLab",
28-
"MATLAB Kernel for Jupyter"
27+
"MATLAB Kernel for Jupyter",
2928
]
3029
classifiers = [
3130
"Framework :: Jupyter",
@@ -42,14 +41,30 @@ dependencies = [
4241
"jupyter-server-proxy",
4342
"jupyter-contrib-nbextensions",
4443
"matlab-proxy>=0.2.9",
45-
"requests"
44+
"requests",
4645
]
4746

47+
[project.urls]
48+
Homepage = "https://github.com/mathworks/jupyter-matlab-proxy"
49+
50+
[project.optional-dependencies]
51+
dev = ["black", "ruamel.yaml", "pytest", "pytest-cov"]
52+
53+
[project.entry-points.jupyter_serverproxy_servers]
54+
matlab = "jupyter_matlab_proxy:setup_matlab"
55+
56+
[project.entry-points.matlab_proxy_configs]
57+
Jupyter = "jupyter_matlab_proxy.jupyter_config:config"
58+
59+
4860
[tool.hatch.build.targets.wheel]
49-
packages = [
50-
"src/jupyter_matlab_kernel",
51-
"src/jupyter_matlab_proxy"
61+
packages = ["src/jupyter_matlab_kernel", "src/jupyter_matlab_proxy"]
62+
63+
[tool.hatch.build.targets.sdist]
64+
artifacts = [
65+
"src/jupyter_matlab_labextension/jupyter_matlab_labextension/labextension",
5266
]
67+
exclude = [".github"]
5368

5469
[tool.hatch.build.targets.wheel.shared-data]
5570
"src/jupyter_matlab_labextension/jupyter_matlab_labextension/labextension" = "share/jupyter/labextensions/jupyter_matlab_labextension"
@@ -58,11 +73,6 @@ packages = [
5873
"img/logo-64x64.png" = "share/jupyter/kernels/jupyter_matlab_kernel/logo-64x64.png"
5974
"img/logo-svg.svg" = "share/jupyter/kernels/jupyter_matlab_kernel/logo-svg.svg"
6075

61-
[tool.hatch.build.targets.sdist]
62-
exclude = [
63-
".github",
64-
]
65-
6676
[tool.hatch.build.hooks.jupyter-builder]
6777
dependencies = ["hatch-jupyter-builder>=0.8.1"]
6878
build-function = "hatch_jupyter_builder.npm_builder"
@@ -74,32 +84,24 @@ skip-if-exists = [
7484
"src/jupyter_matlab_labextension/jupyter_matlab_labextension/labextension/static/style.js",
7585
]
7686

77-
[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs]
78-
build_cmd = "install:extension"
79-
npm = [
80-
"jlpm",
81-
]
82-
8387
[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
8488
path = "src/jupyter_matlab_labextension"
8589
build_cmd = "build:prod"
86-
npm = [
87-
"jlpm",
88-
]
90+
npm = ["jlpm"]
8991

90-
[project.optional-dependencies]
91-
dev = [
92-
"black",
93-
"ruamel.yaml",
94-
"pytest",
95-
"pytest-cov",
96-
]
92+
[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs]
93+
path = "src/jupyter_matlab_labextension"
94+
build_cmd = "install:extension"
95+
npm = ["jlpm"]
9796

98-
[project.entry-points.jupyter_serverproxy_servers]
99-
matlab = "jupyter_matlab_proxy:setup_matlab"
10097

101-
[project.entry-points.matlab_proxy_configs]
102-
Jupyter = "jupyter_matlab_proxy.jupyter_config:config"
98+
[tool.pytest.ini_options]
99+
minversion = "6.0"
100+
addopts = "-ra -q"
101+
testpaths = ["tests"]
102+
filterwarnings = ["ignore::DeprecationWarning", "ignore::RuntimeWarning"]
103103

104-
[project.urls]
105-
Homepage = "https://github.com/mathworks/jupyter-matlab-proxy"
104+
[tool.coverage.run]
105+
source = ["jupyter_matlab_proxy", "jupyter_matlab_kernel"]
106+
omit = ["**/__main__.py"]
107+
branch = true

pytest.ini

-7
This file was deleted.

setup.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# Copyright 2023 The MathWorks, Inc.
2+
13
# setup.py shim for use with applications that require it.
24
__import__("setuptools").setup()

src/jupyter_matlab_kernel/matlab/+jupyter/getOrStashExceptions.m

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
% When resetFlag is set, old exceptionMessage if any is returned, and is
77
% cleared.
88

9+
% Copyright 2023 The MathWorks, Inc.
10+
911
persistent stashedException
1012

1113
% Initialize the persistent variable if it is not already done.
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1+
# Copyright 2023 The MathWorks, Inc.

tests/__init__.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
# Copyright 2020-2021 The MathWorks, Inc.
1+
# Copyright 2020-2023 The MathWorks, Inc.
2+
3+
# Pytest won't include files in the coverage metrics unless they are imported in the tests.
4+
# By importing the systems under test here, any files not hit by a test point are still included in the code coverage metrics.
5+
import jupyter_matlab_kernel
6+
import jupyter_matlab_proxy

0 commit comments

Comments
 (0)