Skip to content

Commit

Permalink
Merge branch 'master' into skip-recommendation
Browse files Browse the repository at this point in the history
  • Loading branch information
sduenas authored Nov 20, 2024
2 parents dec31e1 + 6720315 commit 776ceda
Show file tree
Hide file tree
Showing 10 changed files with 431 additions and 213 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ jobs:
tests:
needs: [build]
runs-on: ubuntu-latest
services:
mysql:
image: mariadb:10.5
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

name: Python ${{ matrix.python-version }}
strategy:
Expand Down Expand Up @@ -71,13 +63,6 @@ jobs:
run: |
poetry install --only dev --no-root
- name: Set MySQL mode
env:
DB_HOST: 127.0.0.1
DB_PORT: ${{ job.services.mysql.ports[3306] }}
run: |
mysql --host $DB_HOST --port $DB_PORT -uroot -proot -e "SET GLOBAL sql_mode = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'";
- name: Test package backend
run: |
PACKAGE=`(cd dist && ls *whl)` && echo $PACKAGE
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ on:
jobs:

backend:

services:
mysql:
image: mariadb:10.5
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
Expand All @@ -44,12 +34,6 @@ jobs:
run: |
poetry install -vvv
poetry run pip install -r requirements_dev.txt
- name: Set MySQL mode
env:
DB_HOST: 127.0.0.1
DB_PORT: ${{ job.services.mysql.ports[3306] }}
run: |
mysql --host $DB_HOST --port $DB_PORT -uroot -proot -e "SET GLOBAL sql_mode = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'";
- name: Lint with flake8
run: |
poetry run flake8
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Releases

## sortinghat 1.5.1 - (2024-11-13)

* Update Poetry's package dependencies

## sortinghat 1.5.0 - (2024-10-15)

**New features:**
Expand Down
2 changes: 2 additions & 0 deletions config/settings/config_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
}
}

TEST_DATABASE_IMAGE = "mariadb:11.4"

TEST_RUNNER = 'tests.runners.SkipMultiTenantTestRunner'

USE_TZ = True
Expand Down
539 changes: 362 additions & 177 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sortinghat"
version = "1.5.0"
version = "1.5.1"
description = "A tool to manage identities."
authors = [
"GrimoireLab Developers"
Expand Down Expand Up @@ -77,6 +77,7 @@ google-auth = "^2.18.0"
fakeredis = "^2.0.0"
httpretty = "^1.1.4"
flake8 = "^7.1.1"
testcontainers = "^4.8.1"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
3 changes: 3 additions & 0 deletions releases/1.5.1-rc.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## sortinghat 1.5.1-rc.1 - (2024-11-13)

* Update Poetry's package dependencies
3 changes: 3 additions & 0 deletions releases/1.5.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## sortinghat 1.5.1 - (2024-11-13)

* Update Poetry's package dependencies
4 changes: 2 additions & 2 deletions sortinghat/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# File auto-generated by semverup on 2024-10-15 07:09:26.543073
__version__ = "1.5.0"
# File auto-generated by semverup on 2024-11-13 15:55:33.726362
__version__ = "1.5.1"
55 changes: 53 additions & 2 deletions tests/runners.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,71 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) Bitergia
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

from django.conf import settings
from django.test.runner import DiscoverRunner
from testcontainers.mysql import MySqlContainer
from unittest.suite import TestSuite


class TestContainersRunner(DiscoverRunner):
_mysql_container: MySqlContainer = None

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

db_image = getattr(settings, "TEST_DATABASE_IMAGE", "mariadb:latest")

self._mysql_container = MySqlContainer(image=db_image,
root_password="root")

def _setup_container(self):
self._mysql_container.start()

for database in settings.DATABASES:
settings.DATABASES[database]["HOST"] = "127.0.0.1"
settings.DATABASES[database]["PORT"] = self._mysql_container.get_exposed_port(3306)
settings.DATABASES[database]["USER"] = "root"
settings.DATABASES[database]["PASSWORD"] = self._mysql_container.root_password

def _teardown_container(self):
self._mysql_container.stop()

def setup_databases(self, **kwargs):
self._setup_container()
return super().setup_databases(**kwargs)

def teardown_databases(self, old_config, **kwargs):
super().teardown_databases(old_config, **kwargs)
self._teardown_container()


def from_tenant_module(test):
return test.__module__.startswith('tests.tenants')


class SkipMultiTenantTestRunner(DiscoverRunner):
class SkipMultiTenantTestRunner(TestContainersRunner):
def build_suite(self, test_labels=None, extra_tests=None, **kwargs):
suite = super().build_suite(test_labels=test_labels, extra_tests=extra_tests, **kwargs)
tests = [t for t in suite._tests if not from_tenant_module(t)]
return TestSuite(tests=tests)


class OnlyMultiTenantTestRunner(DiscoverRunner):
class OnlyMultiTenantTestRunner(TestContainersRunner):
def build_suite(self, test_labels=None, extra_tests=None, **kwargs):
suite = super().build_suite(test_labels=test_labels, extra_tests=extra_tests, **kwargs)
tests = [t for t in suite._tests if from_tenant_module(t)]
Expand Down

0 comments on commit 776ceda

Please sign in to comment.