Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move coverage upload to separate step #323

Merged
merged 20 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 44 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ jobs:
- name: Test
run: |
coverage run --source=npe2 -m pytest --color yes
coverage xml
coverage report --show-missing

- name: Coverage
uses: codecov/codecov-action@v3
- name: Upload coverage as artifact
uses: actions/upload-artifact@v3
with:
fail_ci_if_error: true
name: coverage reports
path: |
./.coverage.*

test_napari:
name: napari tests
Expand Down Expand Up @@ -104,6 +104,45 @@ jobs:
env:
NPE2_SCHEMA: "_schema.json"

upload_coverage:
needs: test
name: Upload coverage
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: "3.x"
cache-dependency-path: setup.cfg
cache: 'pip'

- name: Install Dependencies
run: |
pip install --upgrade pip
pip install codecov

- name: Download coverage data
uses: actions/download-artifact@v3
with:
name: coverage reports
path: coverage

- name: combine coverage data
run: |
python -Im coverage combine coverage
python -Im coverage xml -o coverage.xml

# Report and write to summary.
python -Im coverage report --format=markdown --skip-empty --skip-covered >> $GITHUB_STEP_SUMMARY

- name: Upload coverage data
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

deploy:
name: Deploy
needs: test
Expand Down
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ pretty = true


[tool.coverage.run]
parallel = true
source = ["src"]
omit = [
"src/npe2/manifest/contributions/_keybindings.py",
Expand All @@ -145,6 +146,14 @@ omit = [
"src/npe2/_setuptools_plugin.py",
]

[tool.coverage.paths]
source = [
"src",
"/Users/runner/work/npe2/npe2/src",
"/home/runner/work/npe2/npe2/src",
"D:\\a\\npe2\\npe2\\src",
]

# https://coverage.readthedocs.io/en/6.4/config.html
[tool.coverage.report]
exclude_lines = [
Expand Down
8 changes: 8 additions & 0 deletions src/npe2/_inspection/_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,16 @@ def _get_manifest_from_git_url(url: str) -> PluginManifest:
if url.startswith("git+"):
url = url[4:]

branch = ""
if "@" in url:
url, branch = url.split("@")

with tempfile.TemporaryDirectory() as td:
subprocess.run(["git", "clone", url, td], stdout=subprocess.DEVNULL)
if branch:
subprocess.run(
["git", "checkout", branch], cwd=td, stdout=subprocess.DEVNULL
)
return _build_src_and_extract_manifest(td)


Expand Down
121 changes: 0 additions & 121 deletions src/npe2/_inspection/_full_install.py

This file was deleted.

31 changes: 0 additions & 31 deletions tests/test_all_plugins.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import os
from importlib import metadata
from subprocess import CalledProcessError
from typing import TYPE_CHECKING

import pytest

from npe2._inspection._full_install import isolated_plugin_env
from npe2.cli import app

if TYPE_CHECKING:
Expand All @@ -16,34 +13,6 @@
pytest.skip("skipping plugin specific tests", allow_module_level=True)


@pytest.fixture(scope="session")
def plugin_env():
try:
with isolated_plugin_env(PLUGIN) as env:
yield env
except CalledProcessError as e:
if "Failed building wheel" in str(e.output):
yield None


def test_entry_points_importable(plugin_env):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give me a bit more context around this removal? Was it always xfail-ing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no CI job with TEST_PACKAGE_NAME defined so it land in xfail branch.

if plugin_env is None:
pytest.mark.xfail()
return

entry_points = [
ep
for ep in metadata.distribution(PLUGIN).entry_points
if ep.group in ("napari.plugin", "napari.manifest")
]
if PLUGIN not in {"napari-console", "napari-error-reporter"}:
assert entry_points

for ep in entry_points:
if ep.group == "napari.plugin":
ep.load()


def test_fetch(tmp_path: "Path"):
from typer.testing import CliRunner

Expand Down
16 changes: 2 additions & 14 deletions tests/test_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
get_pypi_plugins,
get_pypi_url,
)
from npe2._inspection._full_install import fetch_manifest_with_full_install
from npe2.manifest._npe1_adapter import NPE1Adapter


def test_fetch_npe2_manifest():
Expand All @@ -26,7 +24,7 @@ def test_fetch_npe2_manifest():

@pytest.mark.skip("package looks deleted from pypi")
def test_fetch_npe1_manifest_with_writer():
mf = fetch_manifest("example-plugin")
mf = fetch_manifest("dummy-test-plugin", version="0.1.3")
assert mf.name == "example-plugin"
assert mf.contributions.writers
# Test will eventually fail when example-plugin is updated to npe2
Expand Down Expand Up @@ -69,16 +67,6 @@ def test_from_pypi_wheel_bdist_missing():
fetch_manifest("my-package")


@pytest.mark.skipif(not os.getenv("CI"), reason="slow, only run on CI")
def testfetch_manifest_with_full_install():
# TODO: slowest of the tests ... would be nice to provide a local mock
mf = fetch_manifest_with_full_install("napari-ndtiffs", version="0.1.2")
# use version 0.1.2 which is npe1
assert isinstance(mf, NPE1Adapter)
assert mf.name == "napari-ndtiffs"
assert mf.contributions


@pytest.mark.skipif(not os.getenv("CI"), reason="slow, only run on CI")
def test_manifest_from_sdist():
mf = _manifest_from_pypi_sdist("zarpaint")
Expand Down Expand Up @@ -109,7 +97,7 @@ def test_get_pypi_plugins():
[
"https://files.pythonhosted.org/packages/fb/01/e59bc1d6ac96f84ce9d7a46cc5422250e047958ead6c5693ed386cf94003/napari_dv-0.3.0.tar.gz", # noqa
"https://files.pythonhosted.org/packages/5d/ae/17779e12ce60d8329306963e1a8dec608465caee582440011ff0c1310715/example_plugin-0.0.7-py3-none-any.whl", # noqa
# "git+https://github.com/DragaDoncila/example-plugin.git", Draga hide package
"git+https://github.com/napari/dummy-test-plugin.git@npe1",
# this one doesn't use setuptools_scm, can check direct zip without clone
"https://github.com/jo-mueller/napari-stl-exporter/archive/refs/heads/main.zip",
],
Expand Down
4 changes: 3 additions & 1 deletion tests/test_setuptools_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

[tool.npe2]
template="{TEMPLATE}"
"""
""".replace(
"\\", "\\\\"
)


@pytest.mark.skipif(not os.getenv("CI"), reason="slow, only run on CI")
Expand Down