Compare commits

...

14 Commits

Author SHA1 Message Date
Raphael Michel
df3fc1bef1 Remove fail-fast 2024-10-25 13:19:48 +02:00
Raphael Michel
022cd8dff7 Try n=3 but no reruns 2024-10-25 12:54:38 +02:00
Raphael Michel
e9c3af9016 Stable order of event lists 2024-10-25 12:54:38 +02:00
Raphael Michel
6744371417 Fix tz bug 2024-10-25 12:54:38 +02:00
Raphael Michel
b4005b7fe5 Add debug modes for test running 2024-10-25 12:54:38 +02:00
Raphael Michel
ff22b893f1 Experimental fixture 2024-10-25 12:54:38 +02:00
Raphael Michel
e37aba4f80 Remove mention of travis CI, it is long dead 2024-10-25 12:54:38 +02:00
Raphael Michel
f9ae2fd62a Use uv for all jobs 2024-10-25 12:54:38 +02:00
Raphael Michel
621c84951f Add -y to all apt lines 2024-10-25 12:54:38 +02:00
Raphael Michel
4d9f03dd2f use uv pip --system 2024-10-25 12:54:38 +02:00
Raphael Michel
9ac9a5aeef Speed up process with uv 2024-10-25 12:54:38 +02:00
Raphael Michel
d5714e12f8 Allow running with "act" 2024-10-25 12:54:38 +02:00
Raphael Michel
4f2cae5880 Map PostgreSQL port 2024-10-25 12:54:38 +02:00
Raphael Michel
c9913a0153 GH Actions: Fix PostgreSQL issues 2024-10-25 12:54:38 +02:00
12 changed files with 54 additions and 25 deletions

View File

@@ -38,7 +38,7 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-
- name: Install system dependencies
run: sudo apt update && sudo apt install gettext unzip
run: sudo apt update && sudo apt install -y gettext unzip
- name: Install Python dependencies
run: pip3 install -U setuptools build pip check-manifest
- name: Run check-manifest

View File

@@ -37,7 +37,7 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-
- name: Install system packages
run: sudo apt update && sudo apt install enchant-2 hunspell aspell-en
run: sudo apt update && sudo apt install -y enchant-2 hunspell aspell-en
- name: Install Dependencies
run: pip3 install -Ur requirements.txt
working-directory: ./doc

View File

@@ -35,9 +35,9 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-
- name: Install system packages
run: sudo apt update && sudo apt install gettext
run: sudo apt update && sudo apt install -y gettext
- name: Install Dependencies
run: pip3 install -e ".[dev]"
run: pip3 install uv && uv pip install --system -e ".[dev]"
- name: Compile messages
run: python manage.py compilemessages
working-directory: ./src
@@ -60,9 +60,9 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-
- name: Install system packages
run: sudo apt update && sudo apt install enchant-2 hunspell hunspell-de-de aspell-en aspell-de
run: sudo apt update && sudo apt install -y enchant-2 hunspell hunspell-de-de aspell-en aspell-de
- name: Install Dependencies
run: pip3 install -e ".[dev]"
run: pip3 install uv && uv pip install --system -e ".[dev]"
- name: Spellcheck translations
run: potypo
working-directory: ./src

View File

@@ -35,7 +35,7 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-
- name: Install Dependencies
run: pip3 install -e ".[dev]" psycopg2-binary
run: pip3 install uv && uv pip install --system -e ".[dev]" psycopg2-binary
- name: Run isort
run: isort -c .
working-directory: ./src
@@ -55,7 +55,7 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-
- name: Install Dependencies
run: pip3 install -e ".[dev]" psycopg2-binary
run: pip3 install uv && uv pip install --system -e ".[dev]" psycopg2-binary
- name: Run flake8
run: flake8 .
working-directory: ./src

View File

@@ -22,6 +22,7 @@ jobs:
runs-on: ubuntu-22.04
name: Tests
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
database: [sqlite, postgres]
@@ -30,15 +31,21 @@ jobs:
python-version: "3.9"
- database: sqlite
python-version: "3.10"
services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: pretix
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: harmon758/postgresql-action@v1
with:
postgresql version: '15'
postgresql db: 'pretix'
postgresql user: 'postgres'
postgresql password: 'postgres'
if: matrix.database == 'postgres'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
@@ -50,9 +57,9 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-
- name: Install system dependencies
run: sudo apt update && sudo apt install gettext
run: sudo apt update && sudo apt install -y gettext
- name: Install Python dependencies
run: pip3 install --ignore-requires-python -e ".[dev]" psycopg2-binary # We ignore that flake8 needs newer python as we don't run flake8 during tests
run: pip3 install uv && uv pip install --system -e ".[dev]" psycopg2-binary
- name: Run checks
run: python manage.py check
working-directory: ./src
@@ -64,10 +71,10 @@ jobs:
run: make all compress
- name: Run tests
working-directory: ./src
run: PRETIX_CONFIG_FILE=tests/travis_${{ matrix.database }}.cfg py.test -n 3 -p no:sugar --cov=./ --cov-report=xml --reruns 3 tests --maxfail=100
run: PRETIX_CONFIG_FILE=tests/ci_${{ matrix.database }}.cfg py.test -n 3 --stepwise -vv -p no:sugar --cov=./ --cov-report=xml --reruns 0 tests
- name: Run concurrency tests
working-directory: ./src
run: PRETIX_CONFIG_FILE=tests/travis_${{ matrix.database }}.cfg py.test tests/concurrency_tests/ --reruns 0 --reuse-db
run: PRETIX_CONFIG_FILE=tests/ci_${{ matrix.database }}.cfg py.test tests/concurrency_tests/ --reruns 0 --reuse-db
if: matrix.database == 'postgres'
- name: Upload coverage
uses: codecov/codecov-action@v1

View File

@@ -10,7 +10,7 @@ tests:
- cd src
- python manage.py check
- make all compress
- PRETIX_CONFIG_FILE=tests/travis_sqlite.cfg py.test --reruns 3 -n 3 tests --maxfail=100
- PRETIX_CONFIG_FILE=tests/ci_sqlite.cfg py.test --reruns 3 -n 3 tests --maxfail=100
except:
- pypi
pypi:

View File

@@ -156,7 +156,7 @@ def event_list(request):
max_fromto=Greatest(Max('subevents__date_to'), Max('subevents__date_from'))
).annotate(
order_from=Coalesce('min_from', 'date_from'),
).order_by('-order_from')
).order_by('-order_from', 'slug')
total = qs.count()
pagesize = 20
@@ -318,7 +318,7 @@ def nav_context_list(request):
max_fromto=Greatest(Max('subevents__date_to'), Max('subevents__date_from'))
).annotate(
order_from=Coalesce('min_from', 'date_from'),
).order_by('-order_from')
).order_by('-order_from', 'slug')
if request.user.has_active_staff_session(request.session.session_key):
qs_orga = Organizer.objects.all()

View File

@@ -210,7 +210,7 @@ class EventListMixin:
)
).annotate(
order_to=Coalesce('max_fromto', 'max_to', 'max_from', 'date_to', 'date_from'),
).order_by('-order_to')
).order_by('-order_to', 'name', 'slug')
else:
date_q = Q(date_to__gte=now()) | (Q(date_to__isnull=True) & Q(date_from__gte=now()))
qs = qs.filter(
@@ -219,7 +219,7 @@ class EventListMixin:
)
).annotate(
order_from=Coalesce('min_from', 'date_from'),
).order_by('order_from')
).order_by('order_from', 'name', 'slug')
qs = Event.annotated(filter_qs_by_attr(
qs, self.request, match_subevents_with_conditions=Q(active=True) & Q(is_public=True) & date_q
), self.request.sales_channel)

View File

@@ -451,7 +451,7 @@ def test_order_create_invoice(token_client, organizer, event, order):
"invoice_to_vat_id": "DE123",
"invoice_to_beneficiary": "",
"custom_field": None,
'date': now().date().isoformat(),
'date': now().astimezone(event.timezone).date().isoformat(),
'refers': None,
'locale': 'en',
'introductory_text': '',

View File

@@ -20,8 +20,10 @@
# <https://www.gnu.org/licenses/>.
#
import inspect
import os
import pytest
from django.db import connection
from django.test import override_settings
from django.utils import translation
from django_scopes import scopes_disabled
@@ -113,3 +115,23 @@ def fakeredis_client(monkeypatch):
redis.flushall()
monkeypatch.setattr('django_redis.get_redis_connection', get_redis_connection, raising=False)
yield redis
if os.environ.get("GITHUB_WORKFLOW", ""):
@pytest.fixture(autouse=True)
def ensure_healthy_connection(request):
# We have no idea why this is neccessary. It shouldn't be, and it costs some performance.
# However, in ~August 2024 our tests became really flake on GitHub Actions (failing more than 80% of the time)
# for no apparent reason with some error messages related to PostgreSQL connection issues. This appears to
# work around it...
# Check if the test even has DB access
marker = request.node.get_closest_marker("django_db")
# Run actual test
yield
# If yes, do a dummy query at the end of the test
if marker:
with connection.cursor() as cursor:
cursor.execute("SELECT 1")