Skip to content

Harden workflows

Harden workflows #1089

Workflow file for this run

name: test
on: [pull_request]
jobs:
test-shared:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ matrix.python-version }}
- name: Install UV
run: pip install uv
- name: Load cached venv
id: cached-uv-dependencies
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/uv.lock') }}
- name: Install dependencies
if: steps.cached-uv-dependencies.outputs.cache-hit != 'true'
working-directory: app/shared
run: |
uv venv
source .venv/bin/activate
uv pip install -e ".[dev,test]"
- name: Test with pytest UV
working-directory: app/shared
run: |
source .venv/bin/activate
pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=. test | tee pytest-coverage.txt
- name: Pytest coverage comment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: app/shared/pytest-coverage.txt
junitxml-path: app/shared/pytest.xml
test-workers:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ matrix.python-version }}
- name: Install UV
run: pip install uv
- name: Load cached venv
id: cached-uv-dependencies
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/uv.lock') }}
- name: Install dependencies
if: steps.cached-uv-dependencies.outputs.cache-hit != 'true'
working-directory: app/workers
run: |
uv venv
source .venv/bin/activate
uv pip install -e ".[dev,test]"
- name: Test with pytest UV
working-directory: app/workers
run: |
source .venv/bin/activate
pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=. test | tee pytest-coverage.txt
- name: Pytest coverage comment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: app/workers/pytest-coverage.txt
junitxml-path: app/workers/pytest.xml
test-django:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
django-version: ["4.2", "5"]
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ matrix.python-version }}
- name: Install UV
run: pip install uv
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/uv.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
working-directory: app/api
run: |
uv venv
source .venv/bin/activate
uv pip install -e ".[dev,test]"
- name: Install django ${{ matrix.django-version }}
working-directory: app/api
run: |
source .venv/bin/activate
uv pip install "Django==${{ matrix.django-version }}"
- name: Test with Django
env:
SECRET_KEY: "test"
ALLOWED_HOSTS: "['localhost']"
DB_ENGINE: "django.db.backends.postgresql"
DB_HOST: "localhost"
DB_NAME: "test"
DB_PASSWORD: "postgres"
DB_PORT: "5432"
DB_USER: "postgres"
STORAGE_TYPE: "minio"
MINIO_ENDPOINT: "minio:9000"
MINIO_ACCESS_KEY: "minioadmin"
MINIO_SECRET_KEY: "minioadmin"
working-directory: app/api
run: |
uv run pytest