Skip to content

Move from login.kiwix.org to ory.login.kiwix.org #179

Move from login.kiwix.org to ory.login.kiwix.org

Move from login.kiwix.org to ory.login.kiwix.org #179

Workflow file for this run

name: Backend Tests
on:
pull_request:
paths:
- "backend/**"
push:
paths:
- "backend/**"
branches:
- main
jobs:
run-tests:
runs-on: ubuntu-24.04
services:
postgresdb:
image: postgres:16.3-bookworm
env:
POSTGRES_DB: cmstest
POSTGRES_PASSWORD: cmspass
POSTGRES_PORT: 5432
POSTGRES_USER: cms
ports:
- 5432:5432
# Set health checks to wait until postgresdb has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
DATABASE_URL: postgresql+psycopg://cms:cmspass@localhost:5432/cmstest
ALEMBIC_UPGRADE_HEAD_ON_START: false
STAGING_WAREHOUSE_ID: 11111111-1111-1111-1111-111111111111
STAGING_BASE_PATH: staging
QUARANTINE_WAREHOUSE_ID: 11111111-1111-1111-1111-111111111111
QUARANTINE_BASE_PATH: quarantine
steps:
- name: Retrieve source code
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version-file: backend/pyproject.toml
architecture: x64
- name: Install dependencies (and project)
working-directory: backend
run: |
pip install -U pip
pip install -e .[test,scripts,maint-scripts]
- name: Create extensions on the PostgreSQL database
run: >-
psql -c 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";'
"host=localhost port=5432 dbname=cmstest user=cms password=cmspass"
- name: Run Alembic Migrations
working-directory: backend/src/cms_backend
run: alembic upgrade head
- name: Build backend mill Docker image
working-directory: backend
run: docker build -t cms-backend-mill:test -f Dockerfile-mill .
- name: Build backend shuttle Docker image
working-directory: backend
run: docker build -t cms-backend-shuttle:test -f Dockerfile-shuttle .
- name: Build backend API Docker image
working-directory: backend
run: docker build -t cms-backend-api:test -f Dockerfile-api .
- name: Run backend api container
run: |
docker run -d --name cms-backend-test \
--network host \
-e DATABASE_URL=$DATABASE_URL \
-e JWT_SECRET=DH8kSxcflUVfNRdkEiJJCn2dOOKI3qfw \
-e STAGING_WAREHOUSE_ID=11111111-1111-1111-1111-111111111111 \
-e QUARANTINE_WAREHOUSE_ID=11111111-1111-1111-1111-111111111111 \
-p 8000:80 \
cms-backend-api:test
# wait for container to be ready
for i in {1..10}; do
http_code=$(curl -s -o /dev/null -w "%{http_code}" 'http://localhost:80/v1/healthcheck' || echo 0000)
if [ "$http_code" -ge 200 ] && [ "$http_code" -lt 300 ]; then
echo "Backend API is up!"
exit 0
else
echo "Waiting for backend API... ($i/10)"
sleep 3
fi
done
echo "Backend API failed to start:"
docker logs cms-backend-test
exit 1
- name: Run mill container
run: |
docker run -d --name cms-mill-test \
--network host \
-e DATABASE_URL=$DATABASE_URL \
-e QUARANTINE_WAREHOUSE_ID=11111111-1111-1111-1111-111111111111 \
-e STAGING_WAREHOUSE_ID=11111111-1111-1111-1111-111111111111 \
cms-backend-mill:test cms-mill --help
- name: Run shuttle container
run: |
docker run -d --name cms-shuttle-test \
--network host \
-e DATABASE_URL=$DATABASE_URL \
-e QUARANTINE_WAREHOUSE_ID=11111111-1111-1111-1111-111111111111 \
-e STAGING_WAREHOUSE_ID=11111111-1111-1111-1111-111111111111 \
cms-backend-shuttle:test cms-shuttle --help
- name: Run tests
working-directory: backend
env:
JWT_SECRET: DH8kSxcflUVfNRdkEiJJCn2dOOKI3qfw
AUTH_MODES: local
run: inv coverage --args "-vvv"
- name: Upload coverage report to codecov
uses: codecov/codecov-action@v5
with:
directory: backend
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}