Skip to content

Merge pull request #1452 from fractal-analytics-platform/1451-make-ge… #4721

Merge pull request #1452 from fractal-analytics-platform/1451-make-ge…

Merge pull request #1452 from fractal-analytics-platform/1451-make-ge… #4721

Workflow file for this run

name: ci
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
tests_v1:
name: "V1 - Python ${{ matrix.python-version }} - ${{ matrix.db }}"
runs-on: ubuntu-22.04
timeout-minutes: 30
strategy:
matrix:
python-version: ["3.9", "3.10"]
db: ["sqlite", "postgres"]
services:
postgres:
# Disable postgres service when using sqlite, through the workaround
# described in https://github.com/actions/runner/issues/822
image: ${{ (matrix.db == 'postgres') && 'postgres' || '' }}
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: fractal_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry==1.8.2
- name: Set up Python 3.9 (only needed to avoid issue \#498)
if: ${{ matrix.python-version != '3.9' }}
uses: actions/setup-python@v5
with:
python-version: 3.9
cache: "poetry"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
- name: Install dependencies
run: |
if [[ ${{ matrix.db }} == "postgres" ]]; then
DB="-E postgres"
fi
poetry install --with dev --without docs --no-interaction -E gunicorn $DB
- name: Test with pytest
run: poetry run coverage run --concurrency=thread,greenlet,multiprocessing -m pytest --ignore tests/no_version --ignore tests/v2
- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: coverage-data
path: ".coverage*"
tests_v2:
name: "V2 - Python ${{ matrix.python-version }} - ${{ matrix.db }}"
runs-on: ubuntu-22.04
timeout-minutes: 30
strategy:
matrix:
python-version: ["3.9", "3.10"]
db: ["sqlite", "postgres"]
services:
postgres:
# Disable postgres service when using sqlite, through the workaround
# described in https://github.com/actions/runner/issues/822
image: ${{ (matrix.db == 'postgres') && 'postgres' || '' }}
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: fractal_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry==1.8.2
- name: Set up Python 3.9 (only needed to avoid issue \#498)
if: ${{ matrix.python-version != '3.9' }}
uses: actions/setup-python@v5
with:
python-version: 3.9
cache: "poetry"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
- name: Install dependencies
run: |
if [[ ${{ matrix.db }} == "postgres" ]]; then
DB="-E postgres"
fi
poetry install --with dev --without docs --no-interaction -E gunicorn $DB
- name: Test with pytest
run: poetry run coverage run --concurrency=thread,greenlet,multiprocessing -m pytest tests/v2 tests/no_version --ignore tests/v1
- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: coverage-data
path: ".coverage*"
coverage:
name: Coverage
runs-on: ubuntu-22.04
needs: [tests_v1, tests_v2]
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: python -m pip install --upgrade coverage[toml]
- name: Download data
uses: actions/download-artifact@v3
with:
name: coverage-data
- name: Add coverage comment to Pull Requests
id: coverage_comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}
MERGE_COVERAGE_FILES: true
MINIMUM_GREEN: 90
MINIMUM_ORANGE: 60
ANNOTATE_MISSING_LINES: true
ANNOTATION_TYPE: notice