diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 830873100..e1ff8d98e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ on: push jobs: test: name: Code check and tests - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 steps: - name: Checkout repo uses: actions/checkout@v2 @@ -12,17 +12,14 @@ jobs: - name: Setup Python uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: '3.10' - name: Install pipenv run: pip install pipenv + - name: Check code formatting + uses: pre-commit/action@v2.0.3 - name: Prepare docker-compose override file run: | ln -s docker-compose.override.local.yml docker-compose.override.yml - - name: Check code formatting - run: | - pipenv install pre_commit - pipenv install pyyaml - pipenv run python -m pre_commit run --all-files - name: Export the env variables file run: | cp .env.example .env diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0494ecc37..d5a29a4a2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,7 +23,7 @@ repos: # Sort imports - repo: https://github.com/pycqa/isort - rev: "5.7.0" + rev: "5.10.1" hooks: - id: isort args: ["--profile", "black"] diff --git a/docker-app/qfieldcloud/core/management/commands/dequeue.py b/docker-app/qfieldcloud/core/management/commands/dequeue.py index 21b7fbb2e..99d8f3ce5 100644 --- a/docker-app/qfieldcloud/core/management/commands/dequeue.py +++ b/docker-app/qfieldcloud/core/management/commands/dequeue.py @@ -2,6 +2,8 @@ import signal from time import sleep +from django.conf import settings +from django.contrib.contenttypes.models import ContentType from django.core.management.base import BaseCommand from django.db import transaction from django.db.models import Count, Q @@ -41,6 +43,11 @@ def handle(self, *args, **options): while killer.alive: with use_test_db_if_exists(): + # the worker wrapper caches outdated ContentType ids during tests since it runs in a separate + # container than the tests, which then the tests. + if settings.DATABASES["default"]["NAME"].startswith("test_"): + ContentType.objects.clear_cache() + queued_job = None with transaction.atomic():