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 GrimoireLab
core 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 8d19bd8 commit 913111b
Show file tree
Hide file tree
Showing 6 changed files with 577 additions and 348 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,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:
matrix:
Expand Down Expand Up @@ -57,13 +48,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.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 config/settings/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
}
}

TEST_DATABASE_IMAGE = "mariadb:11.4"

TEST_RUNNER = 'tests.runners.TestContainersRunner'


# Configuration to pretend there is a Redis service
# available. We need to set up the connection before
Expand Down
Loading

0 comments on commit 913111b

Please # to comment.