Skip to content

Commit 776ceda

Browse files
authored
Merge branch 'master' into skip-recommendation
2 parents dec31e1 + 6720315 commit 776ceda

File tree

10 files changed

+431
-213
lines changed

10 files changed

+431
-213
lines changed

.github/workflows/release.yml

-15
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@ jobs:
3434
tests:
3535
needs: [build]
3636
runs-on: ubuntu-latest
37-
services:
38-
mysql:
39-
image: mariadb:10.5
40-
env:
41-
MYSQL_ROOT_PASSWORD: root
42-
ports:
43-
- 3306:3306
44-
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
4537

4638
name: Python ${{ matrix.python-version }}
4739
strategy:
@@ -71,13 +63,6 @@ jobs:
7163
run: |
7264
poetry install --only dev --no-root
7365
74-
- name: Set MySQL mode
75-
env:
76-
DB_HOST: 127.0.0.1
77-
DB_PORT: ${{ job.services.mysql.ports[3306] }}
78-
run: |
79-
mysql --host $DB_HOST --port $DB_PORT -uroot -proot -e "SET GLOBAL sql_mode = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'";
80-
8166
- name: Test package backend
8267
run: |
8368
PACKAGE=`(cd dist && ls *whl)` && echo $PACKAGE

.github/workflows/tests.yml

-16
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,6 @@ on:
1313
jobs:
1414

1515
backend:
16-
17-
services:
18-
mysql:
19-
image: mariadb:10.5
20-
env:
21-
MYSQL_ROOT_PASSWORD: root
22-
ports:
23-
- 3306:3306
24-
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
25-
2616
strategy:
2717
matrix:
2818
python-version: ['3.9', '3.10', '3.11', '3.12']
@@ -44,12 +34,6 @@ jobs:
4434
run: |
4535
poetry install -vvv
4636
poetry run pip install -r requirements_dev.txt
47-
- name: Set MySQL mode
48-
env:
49-
DB_HOST: 127.0.0.1
50-
DB_PORT: ${{ job.services.mysql.ports[3306] }}
51-
run: |
52-
mysql --host $DB_HOST --port $DB_PORT -uroot -proot -e "SET GLOBAL sql_mode = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'";
5337
- name: Lint with flake8
5438
run: |
5539
poetry run flake8

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Releases
22

3+
## sortinghat 1.5.1 - (2024-11-13)
4+
5+
* Update Poetry's package dependencies
6+
37
## sortinghat 1.5.0 - (2024-10-15)
48

59
**New features:**

config/settings/config_testing.py

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
}
5858
}
5959

60+
TEST_DATABASE_IMAGE = "mariadb:11.4"
61+
6062
TEST_RUNNER = 'tests.runners.SkipMultiTenantTestRunner'
6163

6264
USE_TZ = True

poetry.lock

+362-177
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "sortinghat"
3-
version = "1.5.0"
3+
version = "1.5.1"
44
description = "A tool to manage identities."
55
authors = [
66
"GrimoireLab Developers"
@@ -77,6 +77,7 @@ google-auth = "^2.18.0"
7777
fakeredis = "^2.0.0"
7878
httpretty = "^1.1.4"
7979
flake8 = "^7.1.1"
80+
testcontainers = "^4.8.1"
8081

8182
[build-system]
8283
requires = ["poetry-core>=1.0.0"]

releases/1.5.1-rc.1.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## sortinghat 1.5.1-rc.1 - (2024-11-13)
2+
3+
* Update Poetry's package dependencies

releases/1.5.1.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## sortinghat 1.5.1 - (2024-11-13)
2+
3+
* Update Poetry's package dependencies

sortinghat/_version.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# File auto-generated by semverup on 2024-10-15 07:09:26.543073
2-
__version__ = "1.5.0"
1+
# File auto-generated by semverup on 2024-11-13 15:55:33.726362
2+
__version__ = "1.5.1"

tests/runners.py

+53-2
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,71 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright (C) Bitergia
4+
#
5+
# This program is free software; you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation; either version 3 of the License, or
8+
# (at your option) any later version.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
#
118

19+
from django.conf import settings
220
from django.test.runner import DiscoverRunner
21+
from testcontainers.mysql import MySqlContainer
322
from unittest.suite import TestSuite
423

524

25+
class TestContainersRunner(DiscoverRunner):
26+
_mysql_container: MySqlContainer = None
27+
28+
def __init__(self, *args, **kwargs):
29+
super().__init__(*args, **kwargs)
30+
31+
db_image = getattr(settings, "TEST_DATABASE_IMAGE", "mariadb:latest")
32+
33+
self._mysql_container = MySqlContainer(image=db_image,
34+
root_password="root")
35+
36+
def _setup_container(self):
37+
self._mysql_container.start()
38+
39+
for database in settings.DATABASES:
40+
settings.DATABASES[database]["HOST"] = "127.0.0.1"
41+
settings.DATABASES[database]["PORT"] = self._mysql_container.get_exposed_port(3306)
42+
settings.DATABASES[database]["USER"] = "root"
43+
settings.DATABASES[database]["PASSWORD"] = self._mysql_container.root_password
44+
45+
def _teardown_container(self):
46+
self._mysql_container.stop()
47+
48+
def setup_databases(self, **kwargs):
49+
self._setup_container()
50+
return super().setup_databases(**kwargs)
51+
52+
def teardown_databases(self, old_config, **kwargs):
53+
super().teardown_databases(old_config, **kwargs)
54+
self._teardown_container()
55+
56+
657
def from_tenant_module(test):
758
return test.__module__.startswith('tests.tenants')
859

960

10-
class SkipMultiTenantTestRunner(DiscoverRunner):
61+
class SkipMultiTenantTestRunner(TestContainersRunner):
1162
def build_suite(self, test_labels=None, extra_tests=None, **kwargs):
1263
suite = super().build_suite(test_labels=test_labels, extra_tests=extra_tests, **kwargs)
1364
tests = [t for t in suite._tests if not from_tenant_module(t)]
1465
return TestSuite(tests=tests)
1566

1667

17-
class OnlyMultiTenantTestRunner(DiscoverRunner):
68+
class OnlyMultiTenantTestRunner(TestContainersRunner):
1869
def build_suite(self, test_labels=None, extra_tests=None, **kwargs):
1970
suite = super().build_suite(test_labels=test_labels, extra_tests=extra_tests, **kwargs)
2071
tests = [t for t in suite._tests if from_tenant_module(t)]

0 commit comments

Comments
 (0)