From 153e6c60f273014e3049c4076cc132adc6c4a9d4 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Fri, 8 Jul 2022 13:24:36 +0300 Subject: [PATCH] Test with tox and upload coverage to Codecov --- .coveragerc | 15 +++++++++++++++ .github/workflows/main.yml | 22 +++++++++++++++------- pyproject.toml | 2 +- tox.ini | 12 ++++++++++++ 4 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 .coveragerc create mode 100644 tox.ini diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..819f0b6 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,15 @@ +# .coveragerc to control coverage.py + +[report] +# Regexes for lines to exclude from consideration +exclude_lines = + # Have to re-enable the standard pragma: + pragma: no cover + + # Don't complain if non-runnable code isn't run: + if __name__ == .__main__.: + def cherry_pick_cli + +[run] +omit = + cherry_picker/__main__.py diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b212051..9548395 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,6 +2,9 @@ name: tests on: [push, pull_request, workflow_dispatch] +env: + FORCE_COLOR: 1 + jobs: test: strategy: @@ -22,17 +25,22 @@ jobs: # fetch all branches and tags # ref actions/checkout#448 fetch-depth: 0 - - name: Setup Python - uses: actions/setup-python@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python }} cache: pip - cache-dependency-path: .github/workflows/main.yml - - name: Install package + cache-dependency-path: pyproject.toml + - name: Install tox run: | - python -m pip install .[dev] + python -m pip install tox - name: Run tests - run: pytest + run: tox -e py + - name: Upload coverage + uses: codecov/codecov-action@v3 + with: + flags: ${{ matrix.os }} + name: ${{ matrix.os }} Python ${{ matrix.python-version }} release: needs: test @@ -42,7 +50,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Setup Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: "3.10" cache: pip diff --git a/pyproject.toml b/pyproject.toml index 4c017a9..8e2fed8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,4 +19,4 @@ requires-python = ">=3.7" cherry_picker = "cherry_picker.cherry_picker:cherry_pick_cli" [tool.flit.metadata.requires-extra] -dev = ["pytest"] +dev = ["pytest", "pytest-cov"] diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..1361a96 --- /dev/null +++ b/tox.ini @@ -0,0 +1,12 @@ +[tox] +envlist = + py{310, 39, 38, 37} +isolated_build = true + +[testenv] +passenv = + FORCE_COLOR +extras = + dev +commands = + {envpython} -m pytest --cov cherry_picker --cov-report html --cov-report term --cov-report xml {posargs}