Merge pull request #781 from fractal-analytics-platform/test-branch #2407
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 }}" | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 30 | |
strategy: | |
matrix: | |
python-version: ["3.10", "3.11", "3.12"] | |
steps: | |
- name: Start Postgres | |
run: | | |
sudo systemctl start postgresql.service | |
sudo --login -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'postgres';" | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Install poetry | |
run: pipx install poetry==2.0.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-${{ matrix.python-version }} | |
GHA_FRACTAL_SERVER_LOG: /tmp | |
run: poetry run coverage run -m pytest | |
- name: Log server STDOUT if pytest failed | |
if: failure() | |
run: cat /tmp/server_out | |
- name: Log server STDERR if pytest failed | |
if: failure() | |
run: cat /tmp/server_err | |
- name: Upload coverage data | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-data-${{ matrix.python-version }} | |
path: coverage-data-${{ matrix.python-version }}* | |
coverage: | |
name: Coverage | |
runs-on: ubuntu-22.04 | |
needs: tests | |
steps: | |
- uses: actions/checkout@v4 | |
- run: pipx install poetry==2.0.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 |