From 482a66c546b38303d324443f00bc17f9d86fc3f7 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Fri, 25 Oct 2024 17:18:42 +0200 Subject: [PATCH 1/2] CI: Run PostgreSQL as a native service (#4560) * GH Actions: Fix PostgreSQL issues * Map PostgreSQL port --- .github/workflows/tests.yml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 67f2204314..a15eddcc53 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,15 +30,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: From 54f077665c1163edc50296f1b4774667cda2eb01 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Fri, 25 Oct 2024 17:47:04 +0200 Subject: [PATCH 2/2] CI: Remove mentions of travis CI, we have migrated away years ago (#4562) --- .github/workflows/tests.yml | 4 ++-- .gitlab-ci.yml | 2 +- src/pretix/testutils/settings.py | 2 +- src/tests/{travis_postgres.cfg => ci_postgres.cfg} | 0 src/tests/{travis_sqlite.cfg => ci_sqlite.cfg} | 0 src/tests/conftest.py | 4 ++-- src/tests/test_crashing.py | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) rename src/tests/{travis_postgres.cfg => ci_postgres.cfg} (100%) rename src/tests/{travis_sqlite.cfg => ci_sqlite.cfg} (100%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a15eddcc53..27fa506987 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -70,10 +70,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 -p no:sugar --cov=./ --cov-report=xml --reruns 3 tests --maxfail=100 - 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 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a9d4ef9f54..487eec3082 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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: diff --git a/src/pretix/testutils/settings.py b/src/pretix/testutils/settings.py index daeb557eca..9c5bf7145a 100644 --- a/src/pretix/testutils/settings.py +++ b/src/pretix/testutils/settings.py @@ -95,5 +95,5 @@ class DisableMigrations(object): return None -if not os.environ.get("TRAVIS", "") and not os.environ.get("GITHUB_WORKFLOW", ""): +if not os.environ.get("GITHUB_WORKFLOW", ""): MIGRATION_MODULES = DisableMigrations() diff --git a/src/tests/travis_postgres.cfg b/src/tests/ci_postgres.cfg similarity index 100% rename from src/tests/travis_postgres.cfg rename to src/tests/ci_postgres.cfg diff --git a/src/tests/travis_sqlite.cfg b/src/tests/ci_sqlite.cfg similarity index 100% rename from src/tests/travis_sqlite.cfg rename to src/tests/ci_sqlite.cfg diff --git a/src/tests/conftest.py b/src/tests/conftest.py index 9480872cab..07bd446bee 100644 --- a/src/tests/conftest.py +++ b/src/tests/conftest.py @@ -37,8 +37,8 @@ CRASHED_ITEMS = set() @pytest.hookimpl(trylast=True) def pytest_configure(config): """ - Somehow, somewhere, our test suite causes a segfault in SQLite, but only when run - on Travis CI in full. Therefore, we monkeypatch pytest-xdist to retry segfaulted + Somehow, somewhere, our test suite causes a segfault in SQLite in the past, but only when run + on CI in full. Therefore, we monkeypatch pytest-xdist to retry segfaulted tests and keep fingers crossed that this doesn't turn into an infinite loop. """ diff --git a/src/tests/test_crashing.py b/src/tests/test_crashing.py index c199f0a918..a6db06e44d 100644 --- a/src/tests/test_crashing.py +++ b/src/tests/test_crashing.py @@ -29,7 +29,7 @@ def test_crash(): """ This is a test that crashes with SIGKILL every (n+1)-th time it runs (n = 0, 1, 2, …). This is useful for debugging our pytest-xdist monkeypatch that we apply in conftest.py - to deal with random test crashes on Travis CI using SQLite. Usually, this test is + to deal with random test crashes on CI using SQLite. Usually, this test is skipped to avoid causing additional crashes in real runs. """ if os.path.exists('crashed.tmp'):