From 8f76c64deca19c6080d2c44097825ff7d39214b7 Mon Sep 17 00:00:00 2001 From: pavel Date: Mon, 4 Mar 2024 21:26:03 +0300 Subject: [PATCH 01/15] add coverage report generating in pull request --- .github/workflows/lint_and_test.yml | 44 +++++++++++++++++++++++++++-- justfile | 11 ++++++-- scripts/invoke_tasks.py | 21 ++++++++------ 3 files changed, 62 insertions(+), 14 deletions(-) diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml index 55d1386b..9d80f041 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/lint_and_test.yml @@ -18,7 +18,7 @@ concurrency: jobs: linting: - name: Run linters + name: Linting runs-on: ubuntu-latest timeout-minutes: 3 @@ -44,7 +44,7 @@ jobs: just lint testing: - name: Run tests + name: Testing runs-on: ${{ matrix.os }} needs: linting @@ -82,4 +82,42 @@ jobs: - name: Run tests run: - just test-on ${{ matrix.python_version.tox }} + just test-with-coverage ${{ matrix.python_version.tox }} + + - name: Store coverage file + uses: actions/upload-artifact@v4 + with: + name: coverage-${{ matrix.python_version.setup }} + path: coverage.db + if-no-files-found: error + + coverage: + name: Coverage + runs-on: ubuntu-latest + needs: testing + permissions: + pull-requests: write + contents: write + + steps: + - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + id: download + with: + pattern: coverage-* + merge-multiple: true + + - name: Coverage comment + id: coverage_comment + uses: py-cov-action/python-coverage-comment-action@v3 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + MERGE_COVERAGE_FILES: true + + - name: Store Pull Request comment to be posted + uses: actions/upload-artifact@v4 + if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' + with: + name: python-coverage-comment-action + path: python-coverage-comment-action.txt diff --git a/justfile b/justfile index 14b6d7a6..5f123865 100644 --- a/justfile +++ b/justfile @@ -39,13 +39,18 @@ set windows-powershell := true tox -e $(tox list --no-desc | grep '^py' | sort -r | tr '\n' ',') -p auto # run all tests on specific python version -@test-on target: - tox -e $(tox list --no-desc | grep '^{{ target }}' | sort -r | tr '\n' ',') +@test-with-coverage target: + {{ inv }} cov \ + --env-list $(tox list --no-desc | grep '^{{ target }}' | sort -r | tr '\n' ',') \ + --output coverage.db inv := "inv -r scripts -c invoke_tasks" @cov: - {{ inv }} cov + {{ inv }} cov \ + --env-list $(tox list --no-desc | grep -e '^py' | sort -r | tr '\n' ',') \ + --output coverage.db \ + --parallel @deps-compile: {{ inv }} deps-compile diff --git a/scripts/invoke_tasks.py b/scripts/invoke_tasks.py index f4aa67ff..4277bb6d 100644 --- a/scripts/invoke_tasks.py +++ b/scripts/invoke_tasks.py @@ -11,8 +11,12 @@ def q(value: Union[Path, str]) -> str: return shlex.quote(str(value)) +def if_str(flag: bool, value: str) -> str: + return value if flag else '' + + @task -def cov(c: Context): +def cov(c: Context, env_list, output='coverage.xml', parallel=False): inner_bash_command = q( "coverage run" " --branch" @@ -21,25 +25,26 @@ def cov(c: Context): ) tox_commands = f"bash -c '{q(inner_bash_command)}'" c.run( - r"tox -e $(tox -l | grep -e '^py' | grep -v 'bench' | sort -r | tr '\n' ',')" - " -p auto" + f"tox -e {q(env_list)}" + + if_str(parallel, " -p auto") + " --override 'testenv.allowlist_externals=bash'" f" --override 'testenv.commands={tox_commands}'", pty=True, ) c.run("coverage combine --data-file .tox/cov-storage/.coverage .tox/cov-storage") - c.run("coverage xml --data-file .tox/cov-storage/.coverage") + if output.endswith('.xml'): + c.run(f"coverage xml --data-file .tox/cov-storage/.coverage -o {output}") + else: + c.run(f"cp .tox/cov-storage/.coverage {output}") @task def deps_compile(c: Context, upgrade=False): - extra = "" - if upgrade: - extra += " --upgrade" promises = [ c.run( f'pip-compile {req} -o {Path("requirements") / req.name}' - ' -q --allow-unsafe --strip-extras' + extra, + ' -q --allow-unsafe --strip-extras' + + if_str(upgrade, " --upgrade"), asynchronous=True, ) for req in Path(".").glob("requirements/raw/*.txt") From 1d3b7abca82224c86b23ef949031458581abc5f7 Mon Sep 17 00:00:00 2001 From: pavel Date: Mon, 4 Mar 2024 21:31:04 +0300 Subject: [PATCH 02/15] fix linters --- scripts/invoke_tasks.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/invoke_tasks.py b/scripts/invoke_tasks.py index 4277bb6d..cb477723 100644 --- a/scripts/invoke_tasks.py +++ b/scripts/invoke_tasks.py @@ -11,12 +11,12 @@ def q(value: Union[Path, str]) -> str: return shlex.quote(str(value)) -def if_str(flag: bool, value: str) -> str: - return value if flag else '' +def if_str(flag: bool, value: str) -> str: # noqa: FBT001 + return value if flag else "" @task -def cov(c: Context, env_list, output='coverage.xml', parallel=False): +def cov(c: Context, env_list, output="coverage.xml", parallel=False): inner_bash_command = q( "coverage run" " --branch" @@ -32,7 +32,7 @@ def cov(c: Context, env_list, output='coverage.xml', parallel=False): pty=True, ) c.run("coverage combine --data-file .tox/cov-storage/.coverage .tox/cov-storage") - if output.endswith('.xml'): + if output.endswith(".xml"): c.run(f"coverage xml --data-file .tox/cov-storage/.coverage -o {output}") else: c.run(f"cp .tox/cov-storage/.coverage {output}") From 2aa2a69eb52eb5e9efb9ba07895cef76453f924d Mon Sep 17 00:00:00 2001 From: pavel Date: Mon, 4 Mar 2024 21:39:36 +0300 Subject: [PATCH 03/15] add coverage package to test envs --- requirements/dev.txt | 4 ++-- requirements/lint.txt | 2 ++ requirements/raw/dev.txt | 1 - requirements/raw/test_extra_none.txt | 1 + requirements/test_extra_new.txt | 2 ++ requirements/test_extra_none.txt | 2 ++ requirements/test_extra_old.txt | 2 ++ 7 files changed, 11 insertions(+), 3 deletions(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index fca189de..d8e2f6a9 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -52,8 +52,8 @@ colorama==0.4.6 # tox contourpy==1.2.0 # via matplotlib -coverage==7.3.3 - # via -r requirements/raw/dev.txt +coverage==7.4.3 + # via -r requirements/raw/test_extra_none.txt cycler==0.12.1 # via matplotlib dataclass-factory==2.16 diff --git a/requirements/lint.txt b/requirements/lint.txt index 00e7100c..9c1daceb 100644 --- a/requirements/lint.txt +++ b/requirements/lint.txt @@ -40,6 +40,8 @@ colorama==0.4.6 # via radon contourpy==1.2.0 # via matplotlib +coverage==7.4.3 + # via -r requirements/raw/test_extra_none.txt cycler==0.12.1 # via matplotlib dataclass-factory==2.16 diff --git a/requirements/raw/dev.txt b/requirements/raw/dev.txt index 92020247..b74b22e7 100644 --- a/requirements/raw/dev.txt +++ b/requirements/raw/dev.txt @@ -1,4 +1,3 @@ -coverage==7.3.3 pip-tools==7.3.0 setuptools==69.0.0 towncrier==23.11.0 diff --git a/requirements/raw/test_extra_none.txt b/requirements/raw/test_extra_none.txt index 767f0019..820dc5c3 100644 --- a/requirements/raw/test_extra_none.txt +++ b/requirements/raw/test_extra_none.txt @@ -8,3 +8,4 @@ dirty-equals==0.7.1.post0 typing-extensions==4.9.0 greenlet==3.0.2 +coverage==7.4.3 diff --git a/requirements/test_extra_new.txt b/requirements/test_extra_new.txt index 98d9e0d4..96badd3d 100644 --- a/requirements/test_extra_new.txt +++ b/requirements/test_extra_new.txt @@ -8,6 +8,8 @@ # via -r requirements/raw/test_extra_none.txt attrs==23.2.0 # via -r requirements/raw/test_extra_new.txt +coverage==7.4.3 + # via -r requirements/raw/test_extra_none.txt dirty-equals==0.7.1.post0 # via -r requirements/raw/test_extra_none.txt greenlet==3.0.2 diff --git a/requirements/test_extra_none.txt b/requirements/test_extra_none.txt index 4e202537..034c665e 100644 --- a/requirements/test_extra_none.txt +++ b/requirements/test_extra_none.txt @@ -6,6 +6,8 @@ # -e ./tests/tests_helpers # via -r requirements/raw/test_extra_none.txt +coverage==7.4.3 + # via -r requirements/raw/test_extra_none.txt dirty-equals==0.7.1.post0 # via -r requirements/raw/test_extra_none.txt greenlet==3.0.2 diff --git a/requirements/test_extra_old.txt b/requirements/test_extra_old.txt index fdb01d13..058a5d0c 100644 --- a/requirements/test_extra_old.txt +++ b/requirements/test_extra_old.txt @@ -8,6 +8,8 @@ # via -r requirements/raw/test_extra_none.txt attrs==21.3.0 # via -r requirements/raw/test_extra_old.txt +coverage==7.4.3 + # via -r requirements/raw/test_extra_none.txt dirty-equals==0.7.1.post0 # via -r requirements/raw/test_extra_none.txt greenlet==3.0.2 From b26f17e56b6ef815c52752a471a68b061314ee9f Mon Sep 17 00:00:00 2001 From: pavel Date: Mon, 4 Mar 2024 21:53:54 +0300 Subject: [PATCH 04/15] add coverage to runner venv --- justfile | 2 +- requirements/dev.txt | 4 +++- requirements/raw/runner.txt | 1 + requirements/runner.txt | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/justfile b/justfile index 5f123865..bc7a25e0 100644 --- a/justfile +++ b/justfile @@ -38,7 +38,7 @@ set windows-powershell := true @test-all: tox -e $(tox list --no-desc | grep '^py' | sort -r | tr '\n' ',') -p auto -# run all tests on specific python version +# run all tests on specific python version with coverage @test-with-coverage target: {{ inv }} cov \ --env-list $(tox list --no-desc | grep '^{{ target }}' | sort -r | tr '\n' ',') \ diff --git a/requirements/dev.txt b/requirements/dev.txt index d8e2f6a9..af18437c 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -53,7 +53,9 @@ colorama==0.4.6 contourpy==1.2.0 # via matplotlib coverage==7.4.3 - # via -r requirements/raw/test_extra_none.txt + # via + # -r requirements/raw/runner.txt + # -r requirements/raw/test_extra_none.txt cycler==0.12.1 # via matplotlib dataclass-factory==2.16 diff --git a/requirements/raw/runner.txt b/requirements/raw/runner.txt index 0cf15e23..3f32b89e 100644 --- a/requirements/raw/runner.txt +++ b/requirements/raw/runner.txt @@ -1,2 +1,3 @@ tox==4.11.4 invoke==2.2.0 +coverage==7.4.3 diff --git a/requirements/runner.txt b/requirements/runner.txt index 9e2a273d..4feccc95 100644 --- a/requirements/runner.txt +++ b/requirements/runner.txt @@ -10,6 +10,8 @@ chardet==5.2.0 # via tox colorama==0.4.6 # via tox +coverage==7.4.3 + # via -r requirements/raw/runner.txt distlib==0.3.8 # via virtualenv filelock==3.13.1 From 4dd0eaade51130924a8031309326a3986d8636c4 Mon Sep 17 00:00:00 2001 From: pavel Date: Mon, 4 Mar 2024 23:29:59 +0300 Subject: [PATCH 05/15] fix ci --- .github/workflows/lint_and_test.yml | 6 ++++-- justfile | 27 +++++++++++++++------------ scripts/invoke_tasks.py | 9 +++++++++ 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml index 9d80f041..937b719d 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/lint_and_test.yml @@ -82,13 +82,15 @@ jobs: - name: Run tests run: - just test-with-coverage ${{ matrix.python_version.tox }} + just inv test-on-ci \ + --py-target {{ matrix.python_version.tox }} \ + --cov-output .coverage.${{ matrix.python_version }} - name: Store coverage file uses: actions/upload-artifact@v4 with: name: coverage-${{ matrix.python_version.setup }} - path: coverage.db + path: .coverage.${{ matrix.python_version }} if-no-files-found: error coverage: diff --git a/justfile b/justfile index bc7a25e0..b6b893a0 100644 --- a/justfile +++ b/justfile @@ -17,11 +17,6 @@ set windows-powershell := true pip-sync requirements/pre.txt requirements/dev.txt pip install -e . -[private] -@setup-runner: - pip install -r requirements/pre.txt - pip install -r requirements/runner.txt - # run all linters @lint: tox -e lint @@ -38,18 +33,12 @@ set windows-powershell := true @test-all: tox -e $(tox list --no-desc | grep '^py' | sort -r | tr '\n' ',') -p auto -# run all tests on specific python version with coverage -@test-with-coverage target: - {{ inv }} cov \ - --env-list $(tox list --no-desc | grep '^{{ target }}' | sort -r | tr '\n' ',') \ - --output coverage.db - inv := "inv -r scripts -c invoke_tasks" @cov: {{ inv }} cov \ --env-list $(tox list --no-desc | grep -e '^py' | sort -r | tr '\n' ',') \ - --output coverage.db \ + --output coverage.xml \ --parallel @deps-compile: @@ -69,3 +58,17 @@ doc_target := "docs-build" # clean generated documentation and build cache @doc-clean: sphinx-build -M clean {{ doc_source }} {{ doc_target }} + + +# Continious integration + +[private] +@setup-runner: + pip install -r requirements/pre.txt + pip install -r requirements/runner.txt + +[private] +@inv *ARGS: + {{ inv }} {{ ARGS }} + + diff --git a/scripts/invoke_tasks.py b/scripts/invoke_tasks.py index cb477723..1021d05e 100644 --- a/scripts/invoke_tasks.py +++ b/scripts/invoke_tasks.py @@ -56,3 +56,12 @@ def deps_compile(c: Context, upgrade=False): for file in Path(".").glob("requirements/*.txt"): c.run(fr'sed -i -E "s/-e file:.+\/tests\/tests_helpers/-e .\/tests\/tests_helpers/" {file}') c.run(fr'sed -i -E "s/-e file:.+\/benchmarks/-e .\/benchmarks/" {file}') + + +@task +def test_on_ci(c: Context, py_target, cov_output): + env_list = c.run(fr"tox list --no-desc | grep '^{py_target}' | sort -r | tr '\n' ','", hide=True).stdout + if 'pypy' in py_target: + c.run(fr"tox -e {env_list}", pty=True) + else: + cov(c, env_list=env_list, output=cov_output) From 88e3ce05d171a6154d55b990b54f204c0dacf33a Mon Sep 17 00:00:00 2001 From: pavel Date: Mon, 4 Mar 2024 23:35:04 +0300 Subject: [PATCH 06/15] fix ci --- .github/workflows/lint_and_test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml index 937b719d..83a40159 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/lint_and_test.yml @@ -82,8 +82,8 @@ jobs: - name: Run tests run: - just inv test-on-ci \ - --py-target {{ matrix.python_version.tox }} \ + just inv test-on-ci + --py-target {{ matrix.python_version.tox }} --cov-output .coverage.${{ matrix.python_version }} - name: Store coverage file From bea1208a20881c8ad860033933947e88ebd45e80 Mon Sep 17 00:00:00 2001 From: pavel Date: Mon, 4 Mar 2024 23:37:54 +0300 Subject: [PATCH 07/15] fix ci --- .github/workflows/lint_and_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml index 83a40159..acdc83e2 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/lint_and_test.yml @@ -83,7 +83,7 @@ jobs: - name: Run tests run: just inv test-on-ci - --py-target {{ matrix.python_version.tox }} + --py-target ${{ matrix.python_version.tox }} --cov-output .coverage.${{ matrix.python_version }} - name: Store coverage file From 800de2a1f2ceb86abef207dbecd27f8961b5f03d Mon Sep 17 00:00:00 2001 From: pavel Date: Mon, 4 Mar 2024 23:53:30 +0300 Subject: [PATCH 08/15] fix ci --- .github/workflows/lint_and_test.yml | 27 ++++++++++++++++++--------- justfile | 2 -- scripts/invoke_tasks.py | 4 ++-- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml index acdc83e2..6bf683d6 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/lint_and_test.yml @@ -52,14 +52,14 @@ jobs: fail-fast: true matrix: python_version: - - { setup: '3.8', tox: 'py38' } - - { setup: '3.9', tox: 'py39' } - - { setup: '3.10', tox: 'py310' } - - { setup: '3.11', tox: 'py311' } - - { setup: '3.12', tox: 'py312' } - - { setup: 'pypy3.8', tox: 'pypy38' } - - { setup: 'pypy3.9', tox: 'pypy39' } - - { setup: 'pypy3.10', tox: 'pypy310' } + - { setup: '3.8', tox: 'py38', cov: true } + - { setup: '3.9', tox: 'py39', cov: true } + - { setup: '3.10', tox: 'py310', cov: true } + - { setup: '3.11', tox: 'py311', cov: true } + - { setup: '3.12', tox: 'py312', cov: true } + - { setup: 'pypy3.8', tox: 'pypy38', cov: false } + - { setup: 'pypy3.9', tox: 'pypy39', cov: false } + - { setup: 'pypy3.10', tox: 'pypy310', cov: false } os: ['ubuntu-latest'] @@ -80,7 +80,8 @@ jobs: run: just setup-runner - - name: Run tests + - name: Run tests with coverage + if: matrix.python_version.cov run: just inv test-on-ci --py-target ${{ matrix.python_version.tox }} @@ -88,11 +89,19 @@ jobs: - name: Store coverage file uses: actions/upload-artifact@v4 + if: matrix.python_version.cov with: name: coverage-${{ matrix.python_version.setup }} path: .coverage.${{ matrix.python_version }} if-no-files-found: error + - name: Run tests without coverage + if: !matrix.python_version.cov + run: + just inv test-on-ci + --py-target ${{ matrix.python_version.tox }} + + coverage: name: Coverage runs-on: ubuntu-latest diff --git a/justfile b/justfile index b6b893a0..76ee0807 100644 --- a/justfile +++ b/justfile @@ -70,5 +70,3 @@ doc_target := "docs-build" [private] @inv *ARGS: {{ inv }} {{ ARGS }} - - diff --git a/scripts/invoke_tasks.py b/scripts/invoke_tasks.py index 1021d05e..f50d8bb1 100644 --- a/scripts/invoke_tasks.py +++ b/scripts/invoke_tasks.py @@ -59,9 +59,9 @@ def deps_compile(c: Context, upgrade=False): @task -def test_on_ci(c: Context, py_target, cov_output): +def test_on_ci(c: Context, py_target, cov_output=None): env_list = c.run(fr"tox list --no-desc | grep '^{py_target}' | sort -r | tr '\n' ','", hide=True).stdout - if 'pypy' in py_target: + if cov_output is None: c.run(fr"tox -e {env_list}", pty=True) else: cov(c, env_list=env_list, output=cov_output) From 9e38c3ebffb13bc1c8df7a45c37933a108c7327e Mon Sep 17 00:00:00 2001 From: pavel Date: Tue, 5 Mar 2024 00:02:04 +0300 Subject: [PATCH 09/15] fix ci --- .github/workflows/lint_and_test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml index 6bf683d6..84c91674 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/lint_and_test.yml @@ -81,7 +81,7 @@ jobs: just setup-runner - name: Run tests with coverage - if: matrix.python_version.cov + if: ${{ matrix.python_version.cov }} run: just inv test-on-ci --py-target ${{ matrix.python_version.tox }} @@ -89,14 +89,14 @@ jobs: - name: Store coverage file uses: actions/upload-artifact@v4 - if: matrix.python_version.cov + if: ${{ matrix.python_version.cov }} with: name: coverage-${{ matrix.python_version.setup }} path: .coverage.${{ matrix.python_version }} if-no-files-found: error - name: Run tests without coverage - if: !matrix.python_version.cov + if: ${{ !matrix.python_version.cov }} run: just inv test-on-ci --py-target ${{ matrix.python_version.tox }} From f8018a03bb9247bed90e01b529f80ce8d0d29c32 Mon Sep 17 00:00:00 2001 From: pavel Date: Tue, 5 Mar 2024 00:20:28 +0300 Subject: [PATCH 10/15] fix ci --- .github/workflows/lint_and_test.yml | 3 +-- pyproject.toml | 7 +++++++ scripts/invoke_tasks.py | 1 - 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml index 84c91674..c1064fca 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/lint_and_test.yml @@ -44,7 +44,7 @@ jobs: just lint testing: - name: Testing + name: Testing - ${{ matrix.python_version.tox }} runs-on: ${{ matrix.os }} needs: linting @@ -101,7 +101,6 @@ jobs: just inv test-on-ci --py-target ${{ matrix.python_version.tox }} - coverage: name: Coverage runs-on: ubuntu-latest diff --git a/pyproject.toml b/pyproject.toml index 9022080b..ce99f323 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -156,6 +156,7 @@ keep-runtime-typing = true [tool.ruff.lint.flake8-pytest-style] parametrize-names-type = "list" + [tool.towncrier] package = 'adaptix' filename = 'docs/changelog/changelog_body.rst' @@ -170,3 +171,9 @@ type = [ { name = "Bug Fixes", directory = "bugfix", showcontent = true }, { name = "Other", directory = "other", showcontent = true }, ] + + +[tool.coverage.run] +branch = true +relative_files = true +source = ["src/*"] diff --git a/scripts/invoke_tasks.py b/scripts/invoke_tasks.py index f50d8bb1..9b4ac524 100644 --- a/scripts/invoke_tasks.py +++ b/scripts/invoke_tasks.py @@ -19,7 +19,6 @@ def if_str(flag: bool, value: str) -> str: # noqa: FBT001 def cov(c: Context, env_list, output="coverage.xml", parallel=False): inner_bash_command = q( "coverage run" - " --branch" " --data-file=.tox/cov-storage/.coverage.$TOX_ENV_NAME" " -m pytest", ) From 92e7e022d0cfed8184a189beebe87c3ced418336 Mon Sep 17 00:00:00 2001 From: pavel Date: Tue, 5 Mar 2024 00:45:22 +0300 Subject: [PATCH 11/15] fix ci --- .github/workflows/lint_and_test.yml | 15 ++++----------- justfile | 2 +- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml index c1064fca..2c31d3ef 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/lint_and_test.yml @@ -44,7 +44,7 @@ jobs: just lint testing: - name: Testing - ${{ matrix.python_version.tox }} + name: Testing (${{ matrix.python_version.tox }}, ${{ matrix.os }}) runs-on: ${{ matrix.os }} needs: linting @@ -85,14 +85,14 @@ jobs: run: just inv test-on-ci --py-target ${{ matrix.python_version.tox }} - --cov-output .coverage.${{ matrix.python_version }} + --cov-output .coverage.${{ matrix.python_version.tox }} - name: Store coverage file uses: actions/upload-artifact@v4 if: ${{ matrix.python_version.cov }} with: - name: coverage-${{ matrix.python_version.setup }} - path: .coverage.${{ matrix.python_version }} + name: coverage-${{ matrix.python_version.tox }} + path: .coverage.${{ matrix.python_version.tox }} if-no-files-found: error - name: Run tests without coverage @@ -124,10 +124,3 @@ jobs: with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} MERGE_COVERAGE_FILES: true - - - name: Store Pull Request comment to be posted - uses: actions/upload-artifact@v4 - if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' - with: - name: python-coverage-comment-action - path: python-coverage-comment-action.txt diff --git a/justfile b/justfile index 76ee0807..ea25215b 100644 --- a/justfile +++ b/justfile @@ -37,7 +37,7 @@ inv := "inv -r scripts -c invoke_tasks" @cov: {{ inv }} cov \ - --env-list $(tox list --no-desc | grep -e '^py' | sort -r | tr '\n' ',') \ + --env-list $(tox list --no-desc | grep -e '^py' | grep -v '^pypy' | sort -r | tr '\n' ',') \ --output coverage.xml \ --parallel From 5281423f037ec1b92584544ebb5eb79570bd172c Mon Sep 17 00:00:00 2001 From: pavel Date: Tue, 5 Mar 2024 21:12:40 +0300 Subject: [PATCH 12/15] fix ci --- justfile | 4 ++-- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/justfile b/justfile index ea25215b..c09d82e3 100644 --- a/justfile +++ b/justfile @@ -35,10 +35,10 @@ set windows-powershell := true inv := "inv -r scripts -c invoke_tasks" -@cov: +@cov output='coverage.xml': {{ inv }} cov \ --env-list $(tox list --no-desc | grep -e '^py' | grep -v '^pypy' | sort -r | tr '\n' ',') \ - --output coverage.xml \ + --output {{ output }} \ --parallel @deps-compile: diff --git a/pyproject.toml b/pyproject.toml index ce99f323..c43549fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -176,4 +176,4 @@ type = [ [tool.coverage.run] branch = true relative_files = true -source = ["src/*"] +include = ["src/**"] From a438eb20018c7069508324821fda12ffa4f543a7 Mon Sep 17 00:00:00 2001 From: pavel Date: Tue, 5 Mar 2024 22:27:26 +0300 Subject: [PATCH 13/15] fix ci --- .github/workflows/lint_and_test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml index 2c31d3ef..07e85f1b 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/lint_and_test.yml @@ -108,6 +108,7 @@ jobs: permissions: pull-requests: write contents: write + if: ${{ github.event_name == 'pull_request' }} steps: - uses: actions/checkout@v4 @@ -124,3 +125,4 @@ jobs: with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} MERGE_COVERAGE_FILES: true + MINIMUM_GREEN: 90 From 9fa931df022462d85e4a0fe153ed90c7319b3113 Mon Sep 17 00:00:00 2001 From: pavel Date: Tue, 5 Mar 2024 23:09:57 +0300 Subject: [PATCH 14/15] run coverage only on pr --- .github/workflows/lint_and_test.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml index 07e85f1b..3cee0e56 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/lint_and_test.yml @@ -16,6 +16,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + NEED_COV: ${{ github.event_name == 'pull_request' }} + jobs: linting: name: Linting @@ -89,14 +92,14 @@ jobs: - name: Store coverage file uses: actions/upload-artifact@v4 - if: ${{ matrix.python_version.cov }} + if: ${{ matrix.python_version.cov && env.NEED_COV }} with: name: coverage-${{ matrix.python_version.tox }} path: .coverage.${{ matrix.python_version.tox }} if-no-files-found: error - name: Run tests without coverage - if: ${{ !matrix.python_version.cov }} + if: ${{ !(matrix.python_version.cov && env.NEED_COV) }} run: just inv test-on-ci --py-target ${{ matrix.python_version.tox }} @@ -108,7 +111,7 @@ jobs: permissions: pull-requests: write contents: write - if: ${{ github.event_name == 'pull_request' }} + if: ${{ env.NEED_COV }} steps: - uses: actions/checkout@v4 From a92a133b97e62caaf3f6e2db603f25154c4b4c52 Mon Sep 17 00:00:00 2001 From: pavel Date: Tue, 5 Mar 2024 23:17:42 +0300 Subject: [PATCH 15/15] fix ci --- .github/workflows/lint_and_test.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml index 3cee0e56..ab9900cd 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/lint_and_test.yml @@ -16,9 +16,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -env: - NEED_COV: ${{ github.event_name == 'pull_request' }} - jobs: linting: name: Linting @@ -92,14 +89,14 @@ jobs: - name: Store coverage file uses: actions/upload-artifact@v4 - if: ${{ matrix.python_version.cov && env.NEED_COV }} + if: ${{ (matrix.python_version.cov && github.event_name == 'pull_request') }} with: name: coverage-${{ matrix.python_version.tox }} path: .coverage.${{ matrix.python_version.tox }} if-no-files-found: error - name: Run tests without coverage - if: ${{ !(matrix.python_version.cov && env.NEED_COV) }} + if: ${{ !(matrix.python_version.cov && github.event_name == 'pull_request') }} run: just inv test-on-ci --py-target ${{ matrix.python_version.tox }} @@ -111,7 +108,7 @@ jobs: permissions: pull-requests: write contents: write - if: ${{ env.NEED_COV }} + if: ${{ github.event_name == 'pull_request' }} steps: - uses: actions/checkout@v4