Skip to content

[#270] CI: Add tests to ci pipeline #2

[#270] CI: Add tests to ci pipeline

[#270] CI: Add tests to ci pipeline #2

Workflow file for this run

name: ci
on: [push, pull_request, workflow_dispatch]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
requirements:
# Ubunty latest @ 13-Sep-23:
# Ubuntu 22.04.3 LTS | Python 3.10.12 | Pipx 1.2.0 | No poetry | PostgreSQL 14.9
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up python using the poetry config
id: setup-python
uses: actions/setup-python@v4
with:
python-version-file: 'pyproject.toml'
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv, if cache exists
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-
- name: Install dependencies, if cache does not exist
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-root --no-interaction
- name: Install root project, if required
run: poetry install --root --no-interaction
- name: Run tests
run: |
source .venv/bin/activate
poetry -V
poetry check
ruff:
runs-on: ubuntu-latest
needs: [requirements]
steps:
- uses: actions/checkout@v4
- run: python -m pipx install poetry
- name: Set up Python version from Poetry config
uses: actions/setup-python@v4
with:
python-version-file: 'pyproject.toml'
cache: 'poetry' # caching poetry dependencies
# Warning: poetry cache is not found
- run: poetry install --root --no-interaction --only dev
- name: Ruff linting
uses: chartboost/ruff-action@v1
with:
args: --config=pyproject.toml
black:
runs-on: ubuntu-latest
needs: [requirements]
steps:
- uses: actions/checkout@v4
#- run: python -m pipx install poetry
- uses: actions/setup-python@v4
with:
python-version-file: 'pyproject.toml'
cache: 'poetry' # caching poetry dependencies
# Warning: poetry cache is not found
- run: poetry install --root --no-interaction --only dev
- name: Black style formatting
uses: psf/black@stable
with:
options: --check --diff --color --config=pyproject.toml
# env:
# CHANGED_FILES: ${{ steps.file_changes.outputs.added_modified }}
test:
runs-on: ubuntu-latest
needs: [ruff, black]
steps:
- uses: actions/checkout@v4
- run: python -m pipx install poetry
- name: Set up Python version from Poetry config
uses: actions/setup-python@v4
with:
python-version-file: 'pyproject.toml'
cache: 'poetry' # caching poetry dependencies
# Warning: poetry cache is not found
- run: poetry install --root --no-interaction --only test
- name: Unit testing
run: |
poetry -V
poetry run pytest
poetry run coverage report