Files
calminer/.gitea/workflows/test.yml
zwitschi 50446c4248
Some checks failed
Run Tests / Lint (push) Failing after 4s
Run Tests / Unit Tests (push) Failing after 5s
Run Tests / E2E Tests (push) Successful in 8m42s
feat: Refactor test workflow to separate lint, unit, and e2e jobs with health checks for PostgreSQL service
2025-10-28 06:49:22 +01:00

126 lines
3.4 KiB
YAML

name: Run Tests
on: [push]
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Export PYTHONPATH
shell: bash
run: |
set -euo pipefail
echo "PYTHONPATH=${{ github.workspace }}" >> "$GITHUB_ENV"
- name: Prepare Python environment
uses: ./.gitea/actions/setup-python-env
with:
use-system-python: 'true'
run-db-setup: 'false'
- name: Run lint checks
run: ruff check .
unit:
name: Unit Tests
runs-on: ubuntu-latest
env:
DATABASE_DRIVER: postgresql
DATABASE_HOST: postgres
DATABASE_PORT: '5432'
DATABASE_NAME: calminer_ci
DATABASE_USER: calminer
DATABASE_PASSWORD: secret
DATABASE_SCHEMA: public
DATABASE_SUPERUSER: calminer
DATABASE_SUPERUSER_PASSWORD: secret
DATABASE_SUPERUSER_DB: calminer_ci
DATABASE_URL: postgresql+psycopg2://calminer:secret@postgres:5432/calminer_ci
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: calminer_ci
POSTGRES_USER: calminer
POSTGRES_PASSWORD: secret
options: >-
--health-cmd "pg_isready -U calminer -d calminer_ci"
--health-interval 10s
--health-timeout 5s
--health-retries 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Export PYTHONPATH
shell: bash
run: |
set -euo pipefail
echo "PYTHONPATH=${{ github.workspace }}" >> "$GITHUB_ENV"
- name: Prepare Python environment
uses: ./.gitea/actions/setup-python-env
with:
use-system-python: 'true'
- name: Run unit tests
run: pytest tests/unit
e2e:
name: E2E Tests
runs-on: ubuntu-latest
container: mcr.microsoft.com/playwright/python:v1.55.0-jammy
env:
DATABASE_DRIVER: postgresql
DATABASE_HOST: postgres
DATABASE_PORT: '5432'
DATABASE_NAME: calminer_ci
DATABASE_USER: calminer
DATABASE_PASSWORD: secret
DATABASE_SCHEMA: public
DATABASE_SUPERUSER: calminer
DATABASE_SUPERUSER_PASSWORD: secret
DATABASE_SUPERUSER_DB: calminer_ci
DATABASE_URL: postgresql+psycopg2://calminer:secret@postgres:5432/calminer_ci
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: calminer_ci
POSTGRES_USER: calminer
POSTGRES_PASSWORD: secret
options: >-
--health-cmd "pg_isready -U calminer -d calminer_ci"
--health-interval 10s
--health-timeout 5s
--health-retries 10
steps:
- name: Install Node.js runtime
shell: bash
run: |
set -euo pipefail
export DEBIAN_FRONTEND=noninteractive
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt-get install -y nodejs
- name: Checkout code
uses: actions/checkout@v4
- name: Export PYTHONPATH
shell: bash
run: |
set -euo pipefail
echo "PYTHONPATH=${{ github.workspace }}" >> "$GITHUB_ENV"
- name: Prepare Python environment
uses: ./.gitea/actions/setup-python-env
with:
use-system-python: 'true'
install-playwright: 'true'
- name: Run e2e tests
run: pytest tests/e2e