Skip to content

Prepare update-db-script for v2.6.0 #5930

Prepare update-db-script for v2.6.0

Prepare update-db-script for v2.6.0 #5930

Workflow file for this run

name: ci
on:
push:
branches: ["main", "1774-introduce-user-settings"]
pull_request:
branches: ["main", "1774-introduce-user-settings"]
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: ["postgres"]
services:
postgres:
# Disable postgres service when using sqlite, through the workaround
# described in https://github.com/actions/runner/issues/822
image: ${{ (matrix.db != 'sqlite') && '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: Cache SLURM Docker images
id: cache-docker-slurm-multipy
uses: actions/cache@v4
with:
path: ci/cache/docker/slurm-multipy
key: cache-docker-slurm-multipy
- name: Use SLURM Docker Image Cache if cache hit
if: steps.cache-docker-slurm-multipy.outputs.cache-hit == 'true'
run: docker image load --input ./ci/cache/docker/slurm-multipy/slurm-multipy.tar
- name: Update SLURM Docker Image Cache if cache miss
if: steps.cache-docker-slurm-multipy.outputs.cache-hit != 'true'
run: docker pull ghcr.io/fractal-analytics-platform/ubuntu22-slurm-multipy:0.1 && mkdir -p ci/cache/docker/slurm-multipy && docker image save ghcr.io/fractal-analytics-platform/ubuntu22-slurm-multipy:0.1 --output ./ci/cache/docker/slurm-multipy/slurm-multipy.tar
- name: Install poetry
run: pipx install poetry==1.8.2
- 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"
else
DB="-E postgres-psycopg-binary"
fi
poetry install --with dev --without docs --no-interaction -E gunicorn $DB
- name: Test with pytest
env:
COVERAGE_FILE: coverage-data-v1-${{ matrix.python-version }}-${{ matrix.db }}
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@v4
with:
name: coverage-data-v1-${{ matrix.python-version }}-${{ matrix.db }}
path: coverage-data-v1-${{ matrix.python-version }}-${{ matrix.db }}*
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", "3.11"]
db: ["sqlite", "postgres", "postgres-psycopg"]
exclude:
- python-version: "3.11"
db: "sqlite"
- python-version: "3.11"
db: "postgres"
services:
postgres:
# Disable postgres service when using sqlite, through the workaround
# described in https://github.com/actions/runner/issues/822
image: ${{ (matrix.db != 'sqlite') && '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: Cache SLURM Docker images
id: cache-docker-slurm-multipy
uses: actions/cache@v4
with:
path: ci/cache/docker/slurm-multipy
key: cache-docker-slurm-multipy
- name: Use SLURM Docker Image Cache if cache hit
if: steps.cache-docker-slurm-multipy.outputs.cache-hit == 'true'
run: docker image load --input ./ci/cache/docker/slurm-multipy/slurm-multipy.tar
- name: Update SLURM Docker Image Cache if cache miss
if: steps.cache-docker-slurm-multipy.outputs.cache-hit != 'true'
run: docker pull ghcr.io/fractal-analytics-platform/ubuntu22-slurm-multipy:0.1 && mkdir -p ci/cache/docker/slurm-multipy && docker image save ghcr.io/fractal-analytics-platform/ubuntu22-slurm-multipy:0.1 --output ./ci/cache/docker/slurm-multipy/slurm-multipy.tar
- name: Install poetry
run: pipx install poetry==1.8.2
- 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"
elif [[ ${{ matrix.db }} == "postgres-psycopg" ]]; then
DB="-E postgres-psycopg-binary"
fi
poetry install --with dev --without docs --no-interaction -E gunicorn $DB
- name: Test with pytest
env:
COVERAGE_FILE: coverage-data-v2-${{ matrix.python-version }}-${{ matrix.db }}
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@v4
with:
name: coverage-data-v2-${{ matrix.python-version }}-${{ matrix.db }}
path: coverage-data-v2-${{ matrix.python-version }}-${{ matrix.db }}*
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@v4
with:
pattern: coverage-data-*
merge-multiple: true
- name: Combine coverage
# Combines all the downloaded coverage artifacts in a single `.coverage` file,
# which will then be used by `py-cov-action/python-coverage-comment-action`.
# We added this step to replace the variable `MERGE_COVERAGE_FILES: true`
# in the next step, which had started to raise errors
# (https://github.com/fractal-analytics-platform/fractal-server/pull/1725).
run: coverage combine 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 }}
MINIMUM_GREEN: 90
MINIMUM_ORANGE: 60
ANNOTATE_MISSING_LINES: true
ANNOTATION_TYPE: notice