From 643d9a71da7d2d92996202b89d94d9af98828e6c Mon Sep 17 00:00:00 2001 From: getzze Date: Fri, 20 Sep 2024 23:47:44 +0100 Subject: [PATCH] working tox env + remove 'pip install -e' in CI.yaml --- .github/workflows/{check.yaml => CI.yaml} | 2 -- .github/workflows/coverage.yaml | 35 ------------------- .../{run-tests.yaml => schedule-tests.yaml} | 0 pyproject.toml | 8 +++-- tests/test_video.py | 3 +- tox.ini | 12 ++++--- 6 files changed, 16 insertions(+), 44 deletions(-) rename .github/workflows/{check.yaml => CI.yaml} (98%) delete mode 100644 .github/workflows/coverage.yaml rename .github/workflows/{run-tests.yaml => schedule-tests.yaml} (100%) diff --git a/.github/workflows/check.yaml b/.github/workflows/CI.yaml similarity index 98% rename from .github/workflows/check.yaml rename to .github/workflows/CI.yaml index 6e8cc626..5720f1af 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/CI.yaml @@ -112,8 +112,6 @@ jobs: allow-prereleases: true - name: Install tox-uv run: python -Im pip install tox-uv - - name: install - run: python -Im pip install -e .[test] - run: >- uvx --with=tox-uv diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml deleted file mode 100644 index 42c8a279..00000000 --- a/.github/workflows/coverage.yaml +++ /dev/null @@ -1,35 +0,0 @@ -name: Post coverage comment - -on: - workflow_run: - workflows: ["CI"] - types: - - completed - -jobs: - test: - name: Run tests & display coverage - runs-on: ubuntu-latest - if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' - permissions: - # Gives the action the necessary permissions for publishing new - # comments in pull requests. - pull-requests: write - # Gives the action the necessary permissions for editing existing - # comments (to avoid publishing multiple comments in the same PR) - contents: write - # Gives the action the necessary permissions for looking up the - # workflow that launched this workflow, and download the related - # artifact that contains the comment to be published - actions: read - steps: - # DO NOT run actions/checkout here, for security reasons - # For details, refer to https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ - - name: Post comment - uses: py-cov-action/python-coverage-comment-action@v3 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }} - # Update those if you changed the default values: - # COMMENT_ARTIFACT_NAME: python-coverage-comment-action - # COMMENT_FILENAME: python-coverage-comment-action.txt diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/schedule-tests.yaml similarity index 100% rename from .github/workflows/run-tests.yaml rename to .github/workflows/schedule-tests.yaml diff --git a/pyproject.toml b/pyproject.toml index 6aceccf1..f33236f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,7 +62,7 @@ docs = [ "towncrier", ] test = [ - "coverage[toml]>=5.3", + "coverage[toml]>=7", "mypy", "types-requests", "types-beautifulsoup4", @@ -162,10 +162,14 @@ omit = [ "subliminal/cli.py", ] +[tool.coverage.paths] +source = [".tox/py*/**/site-packages"] + [tool.coverage.run] source = ["subliminal"] branch = true -relative_files = false +parallel = true +relative_files = true # https://docs.astral.sh/ruff/ diff --git a/tests/test_video.py b/tests/test_video.py index a1d076a4..b630edfc 100644 --- a/tests/test_video.py +++ b/tests/test_video.py @@ -14,7 +14,8 @@ def test_video_exists_age(movies, tmpdir, monkeypatch): video = movies['man_of_steel'] tmpdir.ensure(video.name).setmtime(timestamp(datetime.now(timezone.utc) - timedelta(days=3))) assert video.exists - assert timedelta(days=3) <= video.age < timedelta(days=3, seconds=1) + with pytest.deprecated_call(): + assert timedelta(days=3) <= video.age < timedelta(days=3, seconds=1) def test_video_age(movies): diff --git a/tox.ini b/tox.ini index 944a8cf9..7d417f64 100644 --- a/tox.ini +++ b/tox.ini @@ -8,7 +8,6 @@ env_list = docs, changelog, - [testenv:.pkg] pass_env = SETUPTOOLS_SCM_PRETEND_VERSION @@ -44,7 +43,9 @@ usedevelop = true deps = coverage[toml]>=7 set_env = COVERAGE_PROCESS_START = pyproject.toml -commands = pytest --cov --cov-report=term-missing:skip-covered {posargs:-n auto} +commands = + python -m pytest --cov=subliminal --cov-report= --cov-fail-under=0 {posargs:-n auto} + coverage report --skip-covered --show-missing --fail-under=80 [testenv:py3{,.}{8,9,10,11,12}-coverage] @@ -57,10 +58,13 @@ deps = coverage[toml]>=7 set_env = COVERAGE_PROCESS_START = pyproject.toml commands = - pytest --ignore=tests/refiners --ignore=tests/providers --cov --cov-report= --cov-fail-under=0 {posargs:-n auto} + python -m pytest \ + --ignore=tests/refiners --ignore=tests/providers \ + --cov=subliminal --cov-report= --cov-fail-under=0 \ + {posargs:-n auto} coverage report \ --omit='subliminal/cli.py,subliminal/converters/*,subliminal/providers/*,subliminal/refiners/*' \ - --skip-covered --fail-under=100 + --skip-covered --show-missing --fail-under=100 [testenv:py3{,.}{8,9,10,11,12}-coverage-core]