Skip to content

Commit

Permalink
Updates to Code Coverage Collection
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldruce authored and Prabhakar Kumar committed Feb 24, 2023
1 parent 2b556d2 commit 5c8f3a8
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 71 deletions.
2 changes: 0 additions & 2 deletions .coveragerc

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2023 The MathWorks, Inc
# Copyright 2020-2023 The MathWorks, Inc

# Workflow to release MATLAB Jupyter Integration to PyPi
name: Release to PyPI
Expand Down Expand Up @@ -64,4 +64,4 @@ jobs:
user: __token__
verbose: true
password: ${{ secrets.PYPI_TOKEN }}
repository_url: ${{ secrets.PYPI_REPOSITORY_URL }}
repository_url: ${{ secrets.PYPI_REPOSITORY_URL }}
45 changes: 24 additions & 21 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2023 The MathWorks, Inc
# Copyright 2020-2023 The MathWorks, Inc

# Workflow that contains jobs to test MATLAB Jupyter Integration
name: Testing MATLAB Jupyter Integration
Expand All @@ -11,11 +11,13 @@ on:
jobs:
python_tests:
runs-on: ubuntu-latest
env:
code-cov-py: "3.10"
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']

python-version: ["3.7", "3.8", "3.9", "3.10"]
name: "Run Python Tests with Python ${{matrix.python-version}}"
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -38,33 +40,34 @@ jobs:
run: black --check .

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

generate_and_upload_code_coverage:
- name: Test with pytest and get code coverage for Python ${{env.code-cov-py}}
if: ${{matrix.python-version == env.code-cov-py }}
run: python3 -m pytest --cov --cov-report=xml

- name: Persist coverage data to be uploaded if all jobs are successful.
if: ${{matrix.python-version == env.code-cov-py }}
uses: actions/upload-artifact@v3
with:
name: coverage_file
path: ./coverage.xml
retention-days: 5

upload_code_coverage:
name: "Upload Code Coverage using codecov"
needs: [python_tests]
if: success()
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python 3.7
uses: actions/setup-python@v4
- name: Get coverage files from previous job
uses: actions/download-artifact@v3
with:
python-version: 3.7

- name: Install Python build dependencies
run: |
python -m pip install --upgrade pip
python3 -m pip install wheel pytest
python3 -m pip install .[dev]
- name: Generate Code Coverage report for Python code
run: |
pytest --cov=./ --cov-report=xml
name: coverage_file

- name: Upload python coverage report to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
directory: ./
name: Python-codecov
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ dist/
.venv/
.vscode/
htmlcov/
.coverage
.coverage
coverage.xml
cov_html
74 changes: 38 additions & 36 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Copyright 2023 The MathWorks, Inc.

[build-system]
requires = [
"jupyterlab>=3.1",
"hatchling"
]
requires = ["jupyterlab>=3.1,<4.0.0", "hatchling"]
build-backend = "hatchling.build"

[project]
Expand All @@ -25,7 +24,7 @@ keywords = [
"MATLAB Web Desktop",
"Remote MATLAB Web Access",
"JupyterLab",
"MATLAB Kernel for Jupyter"
"MATLAB Kernel for Jupyter",
]
classifiers = [
"Framework :: Jupyter",
Expand All @@ -42,14 +41,30 @@ dependencies = [
"jupyter-server-proxy",
"jupyter-contrib-nbextensions",
"matlab-proxy>=0.2.9",
"requests"
"requests",
]

[project.urls]
Homepage = "https://github.com/mathworks/jupyter-matlab-proxy"

[project.optional-dependencies]
dev = ["black", "ruamel.yaml", "pytest", "pytest-cov"]

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

[project.entry-points.matlab_proxy_configs]
Jupyter = "jupyter_matlab_proxy.jupyter_config:config"


[tool.hatch.build.targets.wheel]
packages = [
"src/jupyter_matlab_kernel",
"src/jupyter_matlab_proxy"
packages = ["src/jupyter_matlab_kernel", "src/jupyter_matlab_proxy"]

[tool.hatch.build.targets.sdist]
artifacts = [
"src/jupyter_matlab_labextension/jupyter_matlab_labextension/labextension",
]
exclude = [".github"]

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

[tool.hatch.build.targets.sdist]
exclude = [
".github",
]

[tool.hatch.build.hooks.jupyter-builder]
dependencies = ["hatch-jupyter-builder>=0.8.1"]
build-function = "hatch_jupyter_builder.npm_builder"
Expand All @@ -74,32 +84,24 @@ skip-if-exists = [
"src/jupyter_matlab_labextension/jupyter_matlab_labextension/labextension/static/style.js",
]

[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs]
build_cmd = "install:extension"
npm = [
"jlpm",
]

[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
path = "src/jupyter_matlab_labextension"
build_cmd = "build:prod"
npm = [
"jlpm",
]
npm = ["jlpm"]

[project.optional-dependencies]
dev = [
"black",
"ruamel.yaml",
"pytest",
"pytest-cov",
]
[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs]
path = "src/jupyter_matlab_labextension"
build_cmd = "install:extension"
npm = ["jlpm"]

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

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

[project.urls]
Homepage = "https://github.com/mathworks/jupyter-matlab-proxy"
[tool.coverage.run]
source = ["jupyter_matlab_proxy", "jupyter_matlab_kernel"]
omit = ["**/__main__.py"]
branch = true
7 changes: 0 additions & 7 deletions pytest.ini

This file was deleted.

2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Copyright 2023 The MathWorks, Inc.

# setup.py shim for use with applications that require it.
__import__("setuptools").setup()
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
% When resetFlag is set, old exceptionMessage if any is returned, and is
% cleared.

% Copyright 2023 The MathWorks, Inc.

persistent stashedException

% Initialize the persistent variable if it is not already done.
Expand Down
2 changes: 1 addition & 1 deletion src/jupyter_matlab_labextension/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@

# Copyright 2023 The MathWorks, Inc.
7 changes: 6 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# Copyright 2020-2021 The MathWorks, Inc.
# Copyright 2020-2023 The MathWorks, Inc.

# Pytest won't include files in the coverage metrics unless they are imported in the tests.
# By importing the systems under test here, any files not hit by a test point are still included in the code coverage metrics.
import jupyter_matlab_kernel
import jupyter_matlab_proxy

0 comments on commit 5c8f3a8

Please sign in to comment.