From 0cb44be33fb1cebacd25e8d7028a7ca33ebf5fc0 Mon Sep 17 00:00:00 2001 From: "Saullo G. P. Castro" Date: Mon, 2 Sep 2024 14:25:54 +0200 Subject: [PATCH] BLD: separating pytest and coverage --- .github/workflows/coverage.yml | 37 +++++++++++++++++++ .../{pytest_and_coverage.yml => pytest.yml} | 27 +++----------- 2 files changed, 43 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/coverage.yml rename .github/workflows/{pytest_and_coverage.yml => pytest.yml} (59%) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..fbbd3ee --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,37 @@ +name: codecov + +on: [push] + +jobs: + build: + + strategy: + matrix: + runs-on: [ubuntu-latest] + python-version: ['3.11'] + runs-on: ${{ matrix.runs-on }} + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python3 -m pip install --upgrade pip + python3 -m pip install -r ci_requirements.txt + python3 -m pip install --upgrade -r ci_requirements.txt + - name: Install module for coverage + run: | + python3 setup.py build_ext --inplace --force --define CYTHON_TRACE_NOGIL + - name: Test with pytest and coverage report + run: | + coverage run -m pytest tests + coverage report + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_UPLOAD_TOKEN }} + fail_ci_if_error: true + verbose: true diff --git a/.github/workflows/pytest_and_coverage.yml b/.github/workflows/pytest.yml similarity index 59% rename from .github/workflows/pytest_and_coverage.yml rename to .github/workflows/pytest.yml index b7a89a0..62a2dbf 100644 --- a/.github/workflows/pytest_and_coverage.yml +++ b/.github/workflows/pytest.yml @@ -1,4 +1,4 @@ -name: Test and coverage +name: pytest on: [push] @@ -10,28 +10,24 @@ jobs: runs-on: [ubuntu-latest, macos-latest, windows-latest] python-version: [3.8, 3.9, '3.10', '3.11', '3.12'] runs-on: ${{ matrix.runs-on }} - env: - USE_COVERAGE: ${{ matrix.runs-on == 'ubuntu-latest' && matrix.python-version == '3.11' }} steps: - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: Install dependencies run: | python3 -m pip install --upgrade pip - python3 -m pip install -r ci_requirements.txt python3 -m pip install --upgrade -r ci_requirements.txt - - name: Install module for coverage - if: env.USE_COVERAGE == 'true' - run: | - python3 setup.py build_ext --inplace --force --define CYTHON_TRACE_NOGIL + - name: Install module - if: env.USE_COVERAGE == 'false' run: | python3 -m pip install . + - name: Lint with flake8 run: | python3 -m pip install flake8 @@ -39,18 +35,7 @@ jobs: flake8 ./composites --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 ./composites --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest and coverage report - if: env.USE_COVERAGE == 'true' - run: | - coverage run -m pytest tests - coverage report + - name: Test with pytest - if: env.USE_COVERAGE == 'false' run: | pytest tests - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_UPLOAD_TOKEN }} - fail_ci_if_error: true - verbose: true