Skip to content

Re-add logic to prepare sbatch script #8352

Re-add logic to prepare sbatch script

Re-add logic to prepare sbatch script #8352

Workflow file for this run

name: ci
on:
push:
branches: ["main", "dev-2.14"]
pull_request:
branches: ["main", "dev-2.14"]
permissions: {}
jobs:
tests_api:
name: "V2 - API - Python ${{ matrix.python-version }}"
runs-on: ubuntu-22.04
timeout-minutes: 30
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
exclude:
- python-version: ${{ github.ref != 'refs/heads/main' && '3.11' }}
- python-version: ${{ github.ref != 'refs/heads/main' && '3.12' }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Start Postgres
run: |
sudo systemctl start postgresql.service
sudo --login -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'postgres';"
sudo --login -u postgres createdb fractal_test
- name: Install poetry
run: pipx install poetry==2.1.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
- name: Install dependencies
run: |
poetry install --with dev --no-interaction
- name: Test with pytest
env:
COVERAGE_FILE: coverage-data-api-${{ matrix.python-version }}
DO_NOT_USE_DOCKER: 1
run: poetry run coverage run --concurrency=thread,greenlet,multiprocessing -m pytest -vv -m "not container" tests/v2/test_03_api --durations 0
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-data-api-${{ matrix.python-version }}
path: coverage-data-api-${{ matrix.python-version }}*
tests_not_api:
name: "V2 - not API - Python ${{ matrix.python-version }}"
runs-on: ubuntu-22.04
timeout-minutes: 30
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
exclude:
- python-version: ${{ github.ref != 'refs/heads/main' && '3.11' }}
- python-version: ${{ github.ref != 'refs/heads/main' && '3.12' }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Start Postgres
run: |
sudo systemctl start postgresql.service
sudo --login -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'postgres';"
sudo --login -u postgres createdb fractal_test
- name: Install poetry
run: pipx install poetry==2.1.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
- name: Install dependencies
run: |
poetry install --with dev --no-interaction
- name: Test with pytest
env:
COVERAGE_FILE: coverage-data-not-api-${{ matrix.python-version }}
DO_NOT_USE_DOCKER: 1
run: poetry run coverage run --concurrency=thread,greenlet,multiprocessing -m pytest -vv -m "not container" --ignore tests/v2/test_03_api --durations 0
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-data-not-api-${{ matrix.python-version }}
path: coverage-data-not-api-${{ matrix.python-version }}*
tests_containers:
name: "V2 - Containers - Python ${{ matrix.python-version }}"
runs-on: ubuntu-22.04
timeout-minutes: 30
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Start Postgres
run: |
sudo systemctl start postgresql.service
sudo --login -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'postgres';"
sudo --login -u postgres createdb fractal_test
- 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==2.1.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
- name: Install dependencies
run: |
poetry install --with dev --no-interaction
- name: Test with pytest
env:
COVERAGE_FILE: coverage-data-containers-${{ matrix.python-version }}
run: echo "skipping for now - FIXME"
# run: poetry run coverage run --concurrency=thread,greenlet,multiprocessing -m pytest -vv -m "container" -m "not ssh" --durations 0
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-data-containers-${{ matrix.python-version }}
path: coverage-data-containers-${{ matrix.python-version }}*
coverage:
name: Coverage
runs-on: ubuntu-22.04
needs: [tests_api, tests_not_api, tests_containers]
permissions:
pull-requests: write
contents: write
steps:
# Note: we cannot add `persist-credentials: false`, since credentials
# are needed for a `git push` operation within
# py-cov-action/python-coverage-comment-action@v3
- uses: actions/checkout@v4
- run: pipx install poetry==2.1.0
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "poetry"
- name: Install dependencies
run: poetry install --only dev
- 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: poetry 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