Compare commits

..

10 Commits

Author SHA1 Message Date
Raphael Michel
a779ba7819 CI: Do not fail if codecov upload fails
This happens all the time with external PRs until https://github.com/codecov/engineering-team/issues/1574 is solved and is doing more harm than good. We still see if there is no coverage attached.
2024-10-25 21:14:15 +02:00
dependabot[bot]
ae5111ee7e Update zeep requirement from ==4.2.* to ==4.3.* (#4567)
Updates the requirements on [zeep](https://github.com/mvantellingen/python-zeep) to permit the latest version.
- [Release notes](https://github.com/mvantellingen/python-zeep/releases)
- [Changelog](https://github.com/mvantellingen/python-zeep/blob/main/CHANGES)
- [Commits](https://github.com/mvantellingen/python-zeep/compare/4.2.0...4.3.1)

---
updated-dependencies:
- dependency-name: zeep
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-25 20:53:11 +02:00
dependabot[bot]
d8bf3065d0 Update redis requirement from ==5.1.* to ==5.2.* (#4565)
Updates the requirements on [redis](https://github.com/redis/redis-py) to permit the latest version.
- [Release notes](https://github.com/redis/redis-py/releases)
- [Changelog](https://github.com/redis/redis-py/blob/master/CHANGES)
- [Commits](https://github.com/redis/redis-py/compare/v5.1.0a1...v5.2.0)

---
updated-dependencies:
- dependency-name: redis
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-25 20:51:30 +02:00
Raphael Michel
54f077665c CI: Remove mentions of travis CI, we have migrated away years ago (#4562) 2024-10-25 17:47:04 +02:00
Raphael Michel
482a66c546 CI: Run PostgreSQL as a native service (#4560)
* GH Actions: Fix PostgreSQL issues

* Map PostgreSQL port
2024-10-25 17:18:42 +02:00
Raphael Michel
e4cef6e46b CI: Make sure apt is non-interactive (to not break act) (#4559) 2024-10-25 17:06:11 +02:00
Raphael Michel
cbee1b71fe CI: Install dependencies with uv for speedup (#4558) 2024-10-25 17:05:58 +02:00
Raphael Michel
0cd1290624 Tests: Fix two flaky tests (#4557)
* Test: Fix test that relies on unstable database result order

* Tests: Fix test that fails between 0am and 1am
2024-10-25 17:04:16 +02:00
Raphael Michel
565f5e2ea7 Tests: Run fakeredis on different virtual ports per pytest worker (#4555) 2024-10-25 16:44:22 +02:00
Raphael Michel
b46c0eba0c pytest: Fix failure with fakeserver and xdist 2024-10-25 14:32:28 +02:00
7 changed files with 25 additions and 36 deletions

View File

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

View File

@@ -22,7 +22,6 @@ jobs:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
name: Tests name: Tests
strategy: strategy:
fail-fast: false
matrix: matrix:
python-version: ["3.9", "3.10", "3.11"] python-version: ["3.9", "3.10", "3.11"]
database: [sqlite, postgres] database: [sqlite, postgres]
@@ -71,7 +70,7 @@ jobs:
run: make all compress run: make all compress
- name: Run tests - name: Run tests
working-directory: ./src working-directory: ./src
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 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 - name: Run concurrency tests
working-directory: ./src working-directory: ./src
run: PRETIX_CONFIG_FILE=tests/ci_${{ 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
@@ -81,5 +80,5 @@ jobs:
with: with:
file: src/coverage.xml file: src/coverage.xml
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true fail_ci_if_error: false
if: matrix.database == 'postgres' && matrix.python-version == '3.11' if: matrix.database == 'postgres' && matrix.python-version == '3.11'

View File

@@ -88,7 +88,7 @@ dependencies = [
"pytz-deprecation-shim==0.1.*", "pytz-deprecation-shim==0.1.*",
"pyuca", "pyuca",
"qrcode==8.0", "qrcode==8.0",
"redis==5.1.*", "redis==5.2.*",
"reportlab==4.2.*", "reportlab==4.2.*",
"requests==2.31.*", "requests==2.31.*",
"sentry-sdk==2.17.*", "sentry-sdk==2.17.*",
@@ -102,7 +102,7 @@ dependencies = [
"vat_moss_forked==2020.3.20.0.11.0", "vat_moss_forked==2020.3.20.0.11.0",
"vobject==0.9.*", "vobject==0.9.*",
"webauthn==2.2.*", "webauthn==2.2.*",
"zeep==4.2.*" "zeep==4.3.*"
] ]
[project.optional-dependencies] [project.optional-dependencies]

View File

@@ -19,6 +19,7 @@
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see # You should have received a copy of the GNU Affero General Public License along with this program. If not, see
# <https://www.gnu.org/licenses/>. # <https://www.gnu.org/licenses/>.
# #
import os
from contextlib import contextmanager from contextlib import contextmanager
import fakeredis import fakeredis
@@ -38,4 +39,9 @@ def mocker_context():
def get_redis_connection(alias="default", write=True): def get_redis_connection(alias="default", write=True):
return fakeredis.FakeStrictRedis(server=fakeredis.FakeServer.get_server("127.0.0.1:None:v(7, 0)", (7, 0), server_type="redis")) worker_id = os.environ.get("PYTEST_XDIST_WORKER")
if worker_id.startswith("gw"):
redis_port = 1000 + int(worker_id.replace("gw", ""))
else:
redis_port = 1000
return fakeredis.FakeStrictRedis(server=fakeredis.FakeServer.get_server(f"127.0.0.1:{redis_port}:redis:v(7, 0)", (7, 0), server_type="redis"))

View File

@@ -95,5 +95,5 @@ class DisableMigrations(object):
return None 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() MIGRATION_MODULES = DisableMigrations()

View File

@@ -23,7 +23,6 @@ import inspect
import os import os
import pytest import pytest
from django.db import connection
from django.test import override_settings from django.test import override_settings
from django.utils import translation from django.utils import translation
from django_scopes import scopes_disabled from django_scopes import scopes_disabled
@@ -38,8 +37,8 @@ CRASHED_ITEMS = set()
@pytest.hookimpl(trylast=True) @pytest.hookimpl(trylast=True)
def pytest_configure(config): def pytest_configure(config):
""" """
Somehow, somewhere, our test suite causes a segfault in SQLite, but only when run Somehow, somewhere, our test suite causes a segfault in SQLite in the past, but only when run
on Travis CI in full. Therefore, we monkeypatch pytest-xdist to retry segfaulted 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. tests and keep fingers crossed that this doesn't turn into an infinite loop.
""" """
@@ -84,27 +83,32 @@ def reset_locale():
@pytest.fixture @pytest.fixture
def fakeredis_client(monkeypatch): def fakeredis_client(monkeypatch):
worker_id = os.environ.get("PYTEST_XDIST_WORKER")
if worker_id.startswith("gw"):
redis_port = 1000 + int(worker_id.replace("gw", ""))
else:
redis_port = 1000
with override_settings( with override_settings(
HAS_REDIS=True, HAS_REDIS=True,
REAL_CACHE_USED=True, REAL_CACHE_USED=True,
CACHES={ CACHES={
'redis': { 'redis': {
'BACKEND': 'django.core.cache.backends.redis.RedisCache', 'BACKEND': 'django.core.cache.backends.redis.RedisCache',
'LOCATION': 'redis://127.0.0.1', 'LOCATION': f'redis://127.0.0.1:{redis_port}',
'OPTIONS': { 'OPTIONS': {
'connection_class': FakeConnection 'connection_class': FakeConnection
} }
}, },
'redis_session': { 'redis_session': {
'BACKEND': 'django.core.cache.backends.redis.RedisCache', 'BACKEND': 'django.core.cache.backends.redis.RedisCache',
'LOCATION': 'redis://127.0.0.1', 'LOCATION': f'redis://127.0.0.1:{redis_port}',
'OPTIONS': { 'OPTIONS': {
'connection_class': FakeConnection 'connection_class': FakeConnection
} }
}, },
'default': { 'default': {
'BACKEND': 'django.core.cache.backends.redis.RedisCache', 'BACKEND': 'django.core.cache.backends.redis.RedisCache',
'LOCATION': 'redis://127.0.0.1', 'LOCATION': f'redis://127.0.0.1:{redis_port}',
'OPTIONS': { 'OPTIONS': {
'connection_class': FakeConnection 'connection_class': FakeConnection
} }
@@ -115,23 +119,3 @@ def fakeredis_client(monkeypatch):
redis.flushall() redis.flushall()
monkeypatch.setattr('django_redis.get_redis_connection', get_redis_connection, raising=False) monkeypatch.setattr('django_redis.get_redis_connection', get_redis_connection, raising=False)
yield redis 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")

View File

@@ -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 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 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. skipped to avoid causing additional crashes in real runs.
""" """
if os.path.exists('crashed.tmp'): if os.path.exists('crashed.tmp'):