Merge pull request #968 from fractal-analytics-platform/957-fix-defin… #3077
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
jobs: | |
tests: | |
name: "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.5.1 | |
- name: Set up Python 3.9 (only needed to avoid issue \#498) | |
if: ${{ matrix.python-version != '3.9' }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
cache: "poetry" | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: "poetry" | |
- name: Run pre-commit | |
if: ${{ matrix.python-version == '3.10' }} | |
uses: pre-commit/[email protected] | |
- name: Install dependencies | |
run: | | |
if [[ ${{ matrix.db }} == "postgres" ]]; then | |
DB="-E postgres" | |
fi | |
poetry install --with dev --without docs --no-interaction -E slurm -E gunicorn $DB | |
- name: Test with pytest | |
run: poetry run coverage run --concurrency=thread,greenlet,multiprocessing -m pytest | |
- name: Upload coverage data | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-data | |
path: ".coverage*" | |
coverage: | |
name: Coverage | |
runs-on: ubuntu-20.04 | |
needs: tests | |
permissions: | |
pull-requests: write | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v4 | |
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 |