Skip to content

Commit

Permalink
refactored pytest github action
Browse files Browse the repository at this point in the history
  • Loading branch information
deeenes committed Jul 1, 2024
1 parent 6ed872a commit 2c1dd20
Showing 1 changed file with 38 additions and 28 deletions.
66 changes: 38 additions & 28 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,57 +1,67 @@
name: Test
name: Unit tests (fast suite)

on:
push:
branches: [main]
branches: [main, dev]
pull_request:
branches: [main]
branches: [main, dev]
types: [ opened, synchronize, reopened, ready_for_review ]

jobs:

test:
tests:

runs-on: ${{ matrix.os }}

defaults:
run:
shell: bash -e {0}

strategy:
fail-fast: false
matrix:
python: [3.8, 3.9, 3.10]
python: [3.9, 3.10, 3.11]
os: [ubuntu-latest, macos-latest]

env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python }}

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
- name: Check out
uses: actions/checkout@main
- name: Setup Python
uses: actions/setup-python@v5
- name: Install Poetry
uses: snok/install-poetry@v1
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: '**/pyproject.toml'

- name: Install test dependencies
run: |
python -m pip install --upgrade pip wheel
pip install codecov
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Install library
run: poetry install --no-interaction
- name: Tests and coverage
if: ${{ github.event_name == 'push' }}
run: |
pip install ".[dev,test]"
- name: Install pip dependencies
run: |
python -m pip install --upgrade pip
- name: Test
env:
MPLBACKEND: agg
PLATFORM: ${{ matrix.os }}
DISPLAY: :42
pytest -v --cov --color=yes --durations=0
- name: Tests
if: ${{ github.event_name == 'pull_request' }}
run: |
pytest -v --cov --color=yes
- name: Upload coverage
pytest -v --cov --color=yes --durations=0
- name: Upload coverage reports to Codecov
if: ${{ github.event_name == 'push' }}
env:
CODECOV_NAME: ${{ matrix.python }}-${{ matrix.os }}
run: |
codecov --no-color --required --flags unittests
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov --no-color --required -F fast -t ${{ secrets.CODECOV_TOKEN }}

0 comments on commit 2c1dd20

Please sign in to comment.