Skip to content

Commit

Permalink
Run tests using Testcontainers
Browse files Browse the repository at this point in the history
This commit simplifies the process of running SortingHat
tests by using Testcontainers. With Testcontainers, we
can now easily set up containerized services, creating
a consistent testing environment and reducing setup
complexity.

Signed-off-by: Jose Javier Merchante <jjmerchante@bitergia.com>
  • Loading branch information
jjmerchante committed Nov 15, 2024
1 parent 7b44ec9 commit f08cde6
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 38 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
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
190 changes: 185 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit f08cde6

Please sign in to comment.