Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Migrate to the flat layout #488

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/ci-community.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ on:
push:
branches: [ main ]
paths:
- "modules/**"
- "testcontainers/**"
- "!testcontainers/core/**"
pull_request:
branches: [ main ]
paths:
- "modules/**"
- "testcontainers/**"
- "!testcontainers/core/**"

jobs:
track-modules:
Expand All @@ -24,15 +26,15 @@ jobs:
id: changed-files
uses: tj-actions/changed-files@v42
with:
path: "./modules"
path: "./testcontainers"
diff_relative: true
dir_names: true
dir_names_exclude_current_dir: true
json: true
- name: Compute modules from files
id: compute-changes
run: |
modules=$(echo "${{ steps.changed-files.outputs.all_changed_files }}" | jq '.[] | split("/") | first' | jq -s -c '. | unique')
modules=$(echo "${{ steps.changed-files.outputs.all_changed_files }}" | jq '.[] | split("/") | first' | jq -s -c '[.[] | select(. != "core")] | unique'))
echo "computed_modules=$modules"
echo "computed_modules=$modules" >> $GITHUB_OUTPUT
outputs:
Expand All @@ -56,4 +58,4 @@ jobs:
- name: Install Python dependencies
run: poetry install -E ${{ matrix.module }}
- name: Run tests
run: make modules/${{ matrix.module }}/tests
run: make tests/${{ matrix.module }}
2 changes: 1 addition & 1 deletion .github/workflows/ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
- name: Run twine check
run: poetry build && poetry run twine check dist/*.tar.gz
- name: Run tests
run: make core/tests
run: make tests/core
46 changes: 23 additions & 23 deletions INDEX.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@ testcontainers-python facilitates the use of Docker containers for functional an

.. toctree::

core/README
modules/arangodb/README
modules/azurite/README
modules/clickhouse/README
modules/elasticsearch/README
modules/google/README
modules/influxdb/README
modules/kafka/README
modules/keycloak/README
modules/localstack/README
modules/minio/README
modules/mongodb/README
modules/mssql/README
modules/mysql/README
modules/neo4j/README
modules/nginx/README
modules/opensearch/README
modules/oracle/README
modules/postgres/README
modules/rabbitmq/README
modules/redis/README
modules/selenium/README
modules/k3s/README
testcontainers/core/README
testcontainers//arangodb/README
testcontainers//azurite/README
testcontainers//clickhouse/README
testcontainers//elasticsearch/README
testcontainers//google/README
testcontainers//influxdb/README
testcontainers//kafka/README
testcontainers//keycloak/README
testcontainers//localstack/README
testcontainers//minio/README
testcontainers//mongodb/README
testcontainers//mssql/README
testcontainers//mysql/README
testcontainers//neo4j/README
testcontainers//nginx/README
testcontainers//opensearch/README
testcontainers//oracle/README
testcontainers//postgres/README
testcontainers//rabbitmq/README
testcontainers//redis/README
testcontainers//selenium/README
testcontainers//k3s/README

Getting Started
---------------
Expand Down
50 changes: 16 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,54 @@ PYTHON_VERSIONS = 3.9 3.10 3.11
PYTHON_VERSION ?= 3.10
IMAGE = testcontainers-python:${PYTHON_VERSION}
RUN = docker run --rm -it
# Get all directories that contain a setup.py and get the directory name.
PACKAGES = core $(addprefix modules/,$(notdir $(wildcard modules/*)))
TEST_NAMES := $(notdir $(wildcard tests/*))

# All */dist folders for each of the packages.
DISTRIBUTIONS = $(addsuffix /dist,${PACKAGES})
UPLOAD = $(addsuffix /upload,${PACKAGES})
# All */tests folders for each of the test suites.
TESTS = $(addsuffix /tests,$(filter-out meta,${PACKAGES}))
TESTS := $(addprefix tests/,$(TEST_NAMES))
TESTS_DIND = $(addsuffix -dind,${TESTS})
DOCTESTS = $(addsuffix /doctest,$(filter-out meta,${PACKAGES}))
# All linting targets.
LINT = $(addsuffix /lint,${PACKAGES})

# Targets to build a distribution for each package.
dist: ${DISTRIBUTIONS}
${DISTRIBUTIONS} : %/dist : %/setup.py
cd $* \
&& python setup.py bdist_wheel \
&& twine check dist/*
dist:
poetry build \
&& poetry run twine check dist/*.tar.gz

# Targets to run the test suite for each package.
tests : ${TESTS}
${TESTS} : %/tests :
poetry run pytest -v --cov=testcontainers.$* $*/tests
${TESTS} : tests/% :
poetry run pytest -v --cov=testcontainers.$* tests/$*

# Target to lint the code.
lint:
pre-commit run -a

# Targets to publish packages.
upload : ${UPLOAD}
${UPLOAD} : %/upload :
if [ ${TWINE_REPOSITORY}-$* = testpypi-meta ]; then \
echo "Cannot upload meta package to testpypi because of missing permissions."; \
else \
twine upload --non-interactive --skip-existing $*/dist/*; \
fi
upload :
poetry run twine upload --non-interactive --skip-existing dist/*

# Targets to build docker images
image:
mkdir -p build/
poetry export -f requirements.txt -o build/requirements.txt
docker build --build-arg version=${PYTHON_VERSION} -t ${IMAGE} .

# Targets to run tests in docker containers
tests-dind : ${TESTS_DIND}

${TESTS_DIND} : %/tests-dind : image
${TESTS_DIND} : tests/%-dind : image
${RUN} -v /var/run/docker.sock:/var/run/docker.sock ${IMAGE} \
bash -c "make $*/lint $*/tests"
bash -c "make lint tests/$*"

# Target to build the documentation
docs :
poetry run sphinx-build -nW . docs/_build

doctest : ${DOCTESTS}
doctest :
poetry run sphinx-build -b doctest . docs/_build

${DOCTESTS} : %/doctest :
poetry run sphinx-build -b doctest -c doctests $* docs/_build

# Remove any generated files.
clean :
rm -rf docs/_build
rm -rf */build
rm -rf */dist
rm -rf build
rm -rf dist
rm -rf */*.egg-info

# Targets that do not generate file-level artifacts.
.PHONY : clean dists ${DISTRIBUTIONS} docs doctests image tests ${TESTS}
.PHONY : clean dists docs doctests image tests ${TESTS}
51 changes: 0 additions & 51 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,6 @@ classifiers = [
"Operating System :: Unix",
"Operating System :: MacOS",
]
# testcontainers-core is a proper package dependency - only modules needed here
packages = [
{ include = "testcontainers", from = "core" },
{ include = "testcontainers", from = "modules/arangodb" },
{ include = "testcontainers", from = "modules/azurite" },
{ include = "testcontainers", from = "modules/clickhouse" },
{ include = "testcontainers", from = "modules/elasticsearch" },
{ include = "testcontainers", from = "modules/google" },
{ include = "testcontainers", from = "modules/influxdb" },
{ include = "testcontainers", from = "modules/k3s" },
{ include = "testcontainers", from = "modules/kafka" },
{ include = "testcontainers", from = "modules/keycloak" },
{ include = "testcontainers", from = "modules/localstack" },
{ include = "testcontainers", from = "modules/minio" },
{ include = "testcontainers", from = "modules/mongodb" },
{ include = "testcontainers", from = "modules/mssql" },
{ include = "testcontainers", from = "modules/mysql" },
{ include = "testcontainers", from = "modules/neo4j" },
{ include = "testcontainers", from = "modules/nginx" },
{ include = "testcontainers", from = "modules/opensearch" },
{ include = "testcontainers", from = "modules/oracle" },
{ include = "testcontainers", from = "modules/postgres" },
{ include = "testcontainers", from = "modules/rabbitmq" },
{ include = "testcontainers", from = "modules/redis" },
{ include = "testcontainers", from = "modules/selenium" }
]

[tool.poetry.urls]
"GitHub" = "https://github.com/testcontainers/testcontainers-python"
Expand Down Expand Up @@ -215,31 +189,6 @@ pretty = true
show_error_codes = true
strict = true
fast_module_lookup = true
modules = ["testcontainers.core"]
mypy_path = [
"core",
# "modules/arangodb",
# "modules/azurite",
# "modules/clickhouse",
# "modules/elasticsearch",
# "modules/google",
# "modules/k3s",
# "modules/kafka",
# "modules/keycloak",
# "modules/localstack",
# "modules/minio",
# "modules/mongodb",
# "modules/mssql",
# "modules/mysql",
# "modules/neo4j",
# "modules/nginx",
# "modules/opensearch",
# "modules/oracle",
# "modules/postgres",
# "modules/rabbitmq",
# "modules/redis",
# "modules/selenium"
]
enable_error_code = [
"ignore-without-code",
"redundant-expr",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.