Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a052137
Run the tests in wger/core/tests/api
rolandgeider Dec 3, 2026
2050155
Stop matching short strings against whole pages
rolandgeider Dec 3, 2026
7586325
Check the foreign-user delete before the owner deletes
rolandgeider Dec 3, 2026
36ab0aa
Generate nutrition dummy data for one user in the generator test
rolandgeider Dec 3, 2026
89f5a12
Measure coverage of product code with branches
rolandgeider Dec 3, 2026
0753661
Widen the CI triggers and run the tests shuffled and buffered
rolandgeider Dec 3, 2026
6721062
Write every model field into the test fixtures
rolandgeider Dec 3, 2026
57d19f3
Check that API overviews only list the user's own objects
rolandgeider Dec 3, 2026
1f7694f
Read back the stored values in the generic API write tests
rolandgeider Dec 3, 2026
8e92598
Test the trophy checker params and the signal error handling
rolandgeider Dec 3, 2026
1c45c65
Fail the tests on RuntimeWarnings and fix the naive datetimes
rolandgeider Dec 3, 2026
b86d7cd
Test the thin management commands and Celery tasks
rolandgeider Dec 3, 2026
e02ffc3
Move the trophy all-users loops into the services
rolandgeider Dec 3, 2026
efccd56
Move the gallery check and thumbnail pruning logic into functions
rolandgeider Dec 3, 2026
1c63ab4
Read gallery images through the storage backend in check_gallery_images
rolandgeider Dec 3, 2026
27f51cb
Move the logic of the remaining management commands into functions
rolandgeider Dec 3, 2026
047e2fe
Run the PostgreSQL-only tests in their own CI job
rolandgeider Dec 3, 2026
dabcd31
Drop the nutrition diary URL without a date
rolandgeider Dec 3, 2026
2b02073
Skip users without a gym in gym-user-config
rolandgeider Dec 3, 2026
6a90118
Save the last bucket in the insert mode of the product imports
rolandgeider Dec 3, 2026
5a54d0f
Catch the logged errors of the tests that provoke them
rolandgeider Dec 3, 2026
aa8d579
Disable ingredient images in the CI settings instead of in the code
rolandgeider Dec 3, 2026
6ab655e
Mock the network calls of two tests
rolandgeider Dec 3, 2026
acc7f43
Keep thumbnails of crop=True aliases in prune-thumbnails
rolandgeider Dec 3, 2026
ddf2cc7
Remove the submitted-exercises command
rolandgeider Dec 3, 2026
8dec35c
Move the demo data generators into functions
rolandgeider Dec 3, 2026
652e718
Speed up the demo data generation
rolandgeider Dec 3, 2026
967932b
Fix several bugs found while testing the management commands
rolandgeider Dec 3, 2026
7c13691
Stop leaking test setup into later tests
rolandgeider Dec 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[run]
source = wger
branch = true
omit =
*/migrations/*
*/settings/*
*/tests/*
parallel = true
concurrency = multiprocessing,thread
91 changes: 80 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,24 @@ name: Continuous Integration
on:
push:
branches: [ master, ]
paths:
paths: &ci-paths
- '**.py'
- '**.tpl'
- '**/templates/**'
- '**/fixtures/*.json'
- 'pyproject.toml'
- 'uv.lock'
- '.coveragerc'
- '.github/workflows/ci.yml'
pull_request:
# The branches below must be a subset of the branches above
branches: [ master, ]
paths:
- '**.py'
- 'pyproject.toml'
paths: *ci-paths

# A new push to a pull request cancels the run of the previous one
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
ci-job:
Expand Down Expand Up @@ -48,7 +57,7 @@ jobs:

- name: Install dependencies
run: |
uv sync --group dev --python ${{ matrix.python-version }}
uv sync --locked --group dev --python ${{ matrix.python-version }}
mkdir /tmp/wger-test

# Missing migrations, and two heads in one app (on a PR this runs on the merge commit)
Expand All @@ -57,21 +66,81 @@ jobs:
run: |
uv run ./manage.py makemigrations --check --dry-run

# Only run the tests with coverage for one version of python.
# Only run the tests with coverage for one version of python. 3.14 because the
# low-overhead sysmon tracer supports branch coverage only from there on.
- name: Test the application with coverage
if: matrix.python-version == 3.13
if: matrix.python-version == 3.14
env:
COVERAGE_CORE: sysmon
PYTHONWARNINGS: error::RuntimeWarning
run: |
uv run coverage run --source='.' ./manage.py test --parallel auto
uv run coverage run ./manage.py test --parallel auto --shuffle --buffer
uv run coverage lcov

- name: Test the application
if: matrix.python-version != 3.13
if: matrix.python-version != 3.14
env:
PYTHONWARNINGS: error::RuntimeWarning
run: |
uv run ./manage.py test --parallel auto
uv run ./manage.py test --parallel auto --shuffle --buffer

- name: Coveralls
if: matrix.python-version == 3.13
if: matrix.python-version == 3.14
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: coverage.lcov

# Tests tagged with requires_postgres (search ranking, PowerSync storage). The test
# database is built with the real migrations, so this also checks they apply.
postgres-job:
runs-on: ubuntu-latest
permissions:
contents: read
name: PostgreSQL tests

services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_USER: wger
POSTGRES_PASSWORD: wger
POSTGRES_DB: wger
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 5s
--health-timeout 5s
--health-retries 10

env:
DJANGO_SETTINGS_MODULE: settings.ci_postgres
DATABASE_URL: postgres://wger:wger@localhost:5432/wger
DJANGO_MEDIA_ROOT: /tmp/wger-test

steps:
- uses: actions/checkout@v7
with:
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: '3.13'

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true

- name: Install dependencies
run: |
uv sync --locked --group dev --python 3.13
mkdir /tmp/wger-test

- name: Test the PostgreSQL-only code
env:
PYTHONWARNINGS: error::RuntimeWarning
run: |
uv run ./manage.py test --tag postgres --parallel auto --shuffle --buffer
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ wger/<app>/
- **Base classes:** `WgerTestCase`, `WgerAddTestCase`, `WgerEditTestCase`, `WgerDeleteTestCase`, `WgerAccessTestCase`
in `wger/core/tests/base_testcase.py`; `ApiBaseResourceTestCase` and the `Api*TestCase` mixins in
`wger/core/tests/api_base_test.py`. Use them, and the `test-*.json` fixtures, instead of building setup by hand.
- **PostgreSQL-only tests:** decorate them with `requires_postgres` (`base_testcase.py`), it tags them for the
PostgreSQL CI job and skips them on SQLite. Run them locally with `DJANGO_SETTINGS_MODULE=settings.ci_postgres`
and `DATABASE_URL=postgres://...` plus `--tag postgres`.
- **Cross-cutting API tests as mixins:** wire a new behavior check into the existing per-model `*CustomApiTestCase`
via a mixin instead of duplicating URLs and payloads in a new class.
- **Bug fixes need regression tests** that fail on the old code and pass on the new.
Expand Down
4 changes: 4 additions & 0 deletions settings/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import environ

# wger
from wger.utils.constants import DOWNLOAD_INGREDIENT_NONE

from .settings_global import *

env = environ.Env()
Expand Down Expand Up @@ -47,6 +49,8 @@
WGER_SETTINGS['ALLOW_UPLOAD_VIDEOS'] = False
WGER_SETTINGS['MIN_ACCOUNT_AGE_TO_TRUST'] = 21 # in days
WGER_SETTINGS['EXERCISE_CACHE_TTL'] = 3600 # in seconds
# No ingredient images from the internet
WGER_SETTINGS['DOWNLOAD_INGREDIENTS_FROM'] = DOWNLOAD_INGREDIENT_NONE

DATABASES = {
'default': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,16 @@
#
# You should have received a copy of the GNU Affero General Public License

# Django
from django.core.management.base import BaseCommand
# ruff: noqa: F405, F403

# wger
from wger.exercises.models import Translation
from .ci import *

"""
Settings for the PostgreSQL CI job: like settings.ci, but on PostgreSQL and
with the real migrations, the connection comes from DATABASE_URL
"""

class Command(BaseCommand):
"""
Read out the user submitted exercise.

Used to generate the AUTHORS file for a release
"""

help = 'Read out the user submitted exercise'

def handle(self, **options):
exercises = Translation.objects.all()
usernames = []
for exercise in exercises:
if exercise.user not in usernames:
usernames.append(exercise.user)
self.stdout.write(exercise.user)
DATABASES = {
'default': env.db_url('DATABASE_URL', default='postgres://wger:wger@localhost:5432/wger'),
}
48 changes: 18 additions & 30 deletions wger/core/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,20 @@
# Django
from django.contrib.auth import authenticate
from django.contrib.auth.models import User
from django.core.management import call_command
from django.http import HttpRequest

# wger
from wger.manager.generators import (
generate_routines,
generate_workout_diary,
)
from wger.measurements.generators import (
generate_body_weight,
generate_measurement_categories,
generate_measurements,
)
from wger.nutrition.generators import generate_nutrition_plans


logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -51,32 +62,9 @@ def create_demo_entries(user):
"""
Creates some demo data for temporary users
"""
call_command(
'dummy-generator-routines',
'--routines=4',
f'--user-id={user.id}',
)
call_command(
'dummy-generator-workout-diary',
f'--user-id={user.id}',
)
call_command(
'dummy-generator-body-weight',
'--nr-entries=40',
f'--user-id={user.id}',
)
call_command(
'dummy-generator-nutrition',
'--plans=5',
f'--user-id={user.id}',
)
call_command(
'dummy-generator-measurement-categories',
'--nr-categories=4',
f'--user-id={user.id}',
)
call_command(
'dummy-generator-measurements',
'--nr-measurements=10',
f'--user-id={user.id}',
)
generate_routines(user, 4)
generate_workout_diary(user, weeks=8)
generate_body_weight(user, 40)
generate_nutrition_plans(user, 5, nr_diary_entries=3)
generate_measurement_categories(user, 4)
generate_measurements(user, 10)
Loading