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

fix: wip #2

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
aa2a420
less verbose starting
May 24, 2024
e3aafdd
bind the minimal set of ports by default
May 24, 2024
c01d02f
run poetry lock --no-update
May 24, 2024
f9508c8
move configuration steps to _configure
May 24, 2024
a2ce740
linting
alexanderankin May 24, 2024
9e5a367
fix make docs - needs to refer to autoclass for enum since its in doc…
alexanderankin May 24, 2024
04f5f5d
actually expose the MongoDB endpoint when requested
May 25, 2024
09a6b0c
remove support for endpoints that are not yet supported in the contai…
May 25, 2024
a7986c5
expose the PEM encoded self signed server certificate
May 25, 2024
e462cbf
wip
May 25, 2024
831cbca
docs: rename classes as to not have the Mongo emulator mistaken for t…
May 26, 2024
fe48bf4
linting
May 26, 2024
8fe2d6d
chore: add .gitattributes file for shell scripts (#581)
saikotek May 27, 2024
78b6f0e
chore(core): Adds integration testing to the private registry auth fe…
Tranquility2 May 27, 2024
c90b36f
skip doctest for the cosmosdb module (the module binds static host po…
May 27, 2024
111bd09
fix(keycloak): realm import (#584)
sebassz May 27, 2024
8917772
fix(k3s): add configuration parameter for disabling cgroup mount to a…
alexanderankin May 31, 2024
a95af7d
chore(main): release testcontainers 4.5.1 (#586)
github-actions[bot] May 31, 2024
54c88cf
feat(core): Image build (Dockerfile support) (#585)
Tranquility2 May 31, 2024
9045c0a
docs(main): Private registry (#598)
Tranquility2 Jun 5, 2024
54822de
chore(core): Display status on readme (#589)
Tranquility2 Jun 5, 2024
2a5a190
fix: move TESTCONTAINERS_HOST_OVERRIDE to config.py (#603)
alexanderankin Jun 7, 2024
f5a019b
docs: Update private registry instructions (#604)
Tranquility2 Jun 8, 2024
ec76df2
fix: Container for Milvus database (#606)
nightblure Jun 13, 2024
59cb6fc
fix(mqtt): Add mqtt.MosquittoContainer (#568) (#599)
f18m Jun 18, 2024
0768490
feat(core): Added ServerContainer (#595)
Tranquility2 Jun 18, 2024
4aff679
fix: Add Cockroach DB Module to Testcontainers (#608)
joelhess Jun 18, 2024
090bd0d
chore(main): release testcontainers 4.6.0 (#594)
github-actions[bot] Jun 20, 2024
762d2a2
fix(kafka): Add Kraft to Kafka containers (#611)
jfmlima Jun 21, 2024
ead0f79
feat(core): allow custom dockerfile path for image build and bypassin…
black-snow Jun 22, 2024
5442d05
feat(core): Add support for ollama module (#618)
bricefotzo Jun 27, 2024
27f2a6b
fix: improve ollama docs, s/ollama_dir/ollama_home/g (#619)
alexanderankin Jun 27, 2024
e711800
feat(core): DockerCompose.stop now stops only services that it starts…
aksel Jun 27, 2024
3519f4b
docs(contributing): add contribution and new-container guide (#460)
totallyzen Jun 28, 2024
e575b28
feat(core): Added Generic module (#612)
Tranquility2 Jun 28, 2024
af58cdd
feat(cosmosdb) : add support for the CosmosDB emulator
May 24, 2024
d57fbcc
poetry.lock - add missing packages from rebase mistake
alexanderankin Jun 28, 2024
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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Shell scripts
*.sh text eol=lf
2 changes: 1 addition & 1 deletion .github/.release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "4.5.0"
".": "4.6.0"
}
82 changes: 82 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Contributing to `testcontainers-python`

Welcome to the `testcontainers-python` community!
This should give you an idea about how we build, test and release `testcontainers-python`!

Highly recommended to read this document thoroughly to understand what we're working on right now
and what our priorities are before you are trying to contribute something.

This will greatly increase your chances of getting prompt replies as the maintainers are volunteers themselves.

## Before you Begin

We recommend following these steps:

1. Finish reading this document.
2. Read the [recently updated issues][1]
3. Look for existing issues on the subject you are interested in - we do our best to label everything correctly


## Local Development

### Pre-Requisites

You need to have the following tools available to you:
- `make` - You'll need a GNU Make for common developer activities
- `poetry` - This is the primary package manager for the project
- `pyenv` **Recommended**: For installing python versions for your system.
Poetry infers the current latest version from what it can find on the `PATH` so you are still fine if you don't use `pyenv`.

### Build and test


- Run `make install` to get `poetry` to install all dependencies and set up `pre-commit`
- **Recommended**: Run `make` or `make help` to see other commands available to you.
- After this, you should have a working virtual environment and proceed with writing code with your favourite IDE
- **TIP**: You can run `make core/tests` or `make module/<my-module>/tests` to run the tests specifically for that to speed up feedback cycles
- You can also run `make lint` to run the `pre-commit` for the entire codebase.


## Adding new containers

We have an [issue template](.github/ISSUE_TEMPLATE/new-container.md) for adding new containers, please refer to that for more information.
Once you've talked to the maintainers (we do our best to reply!) then you can proceed with contributing the new container.

> [!WARNING]
> PLease raise an issue before you try to contribute a new container! It helps maintainers understand your use-case and motivation.
> This way we can keep pull requests foruced on the "how", not the "why"! :pray:
> It also gives maintainers a chance to give you last-minute guidance on caveats or expectations, particularly with
> new extra dependencies and how to manage them.


## Raising Issues

We have [Issue Templates][2] to cover most cases, please try to adhere to them, they will guide you through the process.
Try to look through the existing issues before you raise a new one.


## Releasing Versions

We have automated Semantic Versioning and release via [release-please](workflows/release-please.yml).
This takes care of:
- Detecting the next version, based on the commits that landed on `main`
- When a Release PR has been merged
- Create a GitHub Release with the CHANGELOG included
- Update the [CHANGELOG](../CHANGELOG.md), similar to the GitHub Release
- Release to PyPI via a [trusted publisher](https://docs.pypi.org/trusted-publishers/using-a-publisher/)
- Automatically script updates in files where it's needed instead of hand-crafting it (i.e. in `pyproject.toml`)

> [!CRITICAL]
> Community modules are supported on a best-effort basis and for maintenance reasons, any change to them
> is only covered under minor and patch changes.
>
> Community modules changes DO NOT contribute to major version changes!
>
> If your community module container was broken by a minor or patch version change, check out the change logs!

# Thank you!

Thanks for reading, feedback on documentation is always welcome!

[1]: https://github.com/testcontainers/testcontainers-python/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc "Recently Updated Issues showing you what we're focusing on"
[2]: https://github.com/testcontainers/testcontainers-python/issues/new/choose "List of current issue templates, please use them"
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/new-container.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: New Container
about: Tell the Testcontainers-Python team about a container you'd like to have support for.
title: 'New Container: '
labels: '🚀 enhancement'
assignees: ''

---

<!-- feel free to remove any irrelevant section(s) below -->

**What is the new container you'd like to have?**

Please link some docker containers as well as documentation/arguments to the benefits of having this container.

**Why not just use a generic container for this?**

Please describe why the `DockerContainer("my-image:latest")` approach is not useful enough.

Having a dedicated `TestContainer` usually means the need for some or all of these:
- complicated setup/configuration
- the wait strategy is complex for the container, usually more than just an http wait

**Other references:**

Include any other relevant reading material about the enhancement.
30 changes: 18 additions & 12 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,33 @@ assignees: ''

<!-- feel free to remove any irrelevant section(s) below -->

**What are you trying to do?**
## What are you trying to do?

Ask your question here

**Where are you trying to do it?**
## Where are you trying to do it?

Provide a self-contained code snippet that illustrates the bug or unexpected behavior.
Ideally, include a link to a public repository with a minimal project where someone from the
testcontainers-python can submit a PR with a solution to the problem you are facing with the library.

**Runtime environment**
## Runtime environment

Provide a summary of your runtime environment. Which operating system, python version, and docker version are you using? What is the version of `testcontainers-python` you are using? You can run the following commands to get the relevant information.
Provide a summary of your runtime environment. Which operating system, python version, and docker version are you using?
What is the version of `testcontainers-python` you are using? You can run the following commands to get the relevant information.

Paste the results of the bash below

```bash
uname -a
echo "------"
docker info
echo "------"
poetry run python --version
echo "------"
poetry show --tree
```

```bash
# Get the operating system information (on a unix os).
$ uname -a
# Get the python version.
$ python --version
# Get the docker version and other docker information.
$ docker info
# Get all python packages.
$ pip freeze
paste-me-here
```
48 changes: 40 additions & 8 deletions .github/PULL_REQUEST_TEMPLATE/new_container.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
You have implemented a new container and would like to contribute it? Great! Here are the necessary steps.

- [ ] Create a new feature directory and populate it with the package structure [described in the documentation](https://testcontainers-python.readthedocs.io/en/latest/#package-structure). Copying one of the existing features is likely the best way to get started.
- [ ] Implement the new feature (typically in `__init__.py`) and corresponding tests.
- [ ] Update the feature `README.rst` and add it to the table of contents (`toctree` directive) in the top-level `README.rst`.
- [ ] Add a line `[feature name]` to the list of components in the GitHub Action workflow in `.github/workflows/main.yml` to run tests, build, and publish your package when pushed to the `main` branch.
- [ ] Rebase your development branch on `main` (or merge `main` into your development branch).
- [ ] Add a line `-e file:[feature name]` to `requirements.in` and open a pull request. Opening a pull request will automatically generate lock files to ensure reproducible builds (see the [pip-tools documentation](https://pip-tools.readthedocs.io/en/latest/) for details). Finally, run `python get_requirements.py --pr=[your PR number]` to fetch the updated requirement files (the build needs to have succeeded).
# New Container

<!-- You have implemented a new container and would like to contribute it? Great! Here are the necessary checklist steps. -->

Fixes ...

<!--
Please do not raise a PR for new container without having raised an issue first.
It helps reduce unnecessary work for you and the maintainers!
-->


# PR Checklist

- [ ] Your PR title follows the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) syntax
as we make use of this for detecting Semantic Versioning changes.
- [ ] Your PR allows maintainers to edit your branch, this will speed up resolving minor issues!
- [ ] The new container is implemented under `modules/*`
- Your module follows [PEP 420](https://peps.python.org/pep-0420/) with implicit namespace packages
(if unsure, look at other existing community modules)
- Your package namespacing follows `testcontainers.<modulename>.*`
and you DO NOT have an `__init__.py` above your module's level.
- Your module has it's own tests under `modules/*/tests`
- Your module has a `README.rst` and hooks in the `.. auto-class` and `.. title` of your container
- Implement the new feature (typically in `__init__.py`) and corresponding tests.
- [ ] Your module is added in `pyproject.toml`
- it is declared under `tool.poetry.packages` - see other community modules
- it is declared under `tool.poetry.extras` with the same name as your module name,
we still prefer adding _NO EXTRA DEPENDENCIES_, meaning `mymodule = []` is the preferred addition
(see the notes at the bottom)
- [ ] The `INDEX.rst` at the project root includes your module under the `.. toctree` directive
- [ ] Your branch is up to date (or we'll use GH's "update branch" function through the UI)

# Preferred implementation

- The current consensus among maintainers is to try to avoid enforcing the client library
for the given tools you are triyng to implement.
- This means we want you to avoid adding specific libraries as dependencies to `testcontainers`.
- Therefore, you should implement the configuration and the waiting with as little extra as possible
- You may still find it useful to add your preferred client library as a dev dependency
31 changes: 30 additions & 1 deletion .github/workflows/ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
branches: [main]

jobs:
test:
run-tests-and-coverage:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
Expand All @@ -27,5 +27,34 @@ jobs:
run: poetry build && poetry run twine check dist/*.tar.gz
- name: Run tests
run: make core/tests
- name: Rename coverage file
run: mv .coverage .coverage.${{ matrix.python-version}}
- name: "Save coverage artifact"
uses: actions/upload-artifact@v4
with:
name: "coverage-artifact-${{ matrix.python-version}}"
path: ".coverage.*"
retention-days: 1
- name: Run doctests
run: make core/doctests

coverage-compile:
needs: "run-tests-and-coverage"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: ./.github/actions/setup-env
- name: Install Python dependencies
run: poetry install --all-extras
- name: "Download coverage artifacts"
uses: actions/download-artifact@v4
with:
pattern: "coverage-artifact-*"
merge-multiple: true
- name: Compile coverage
run: make coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# Changelog

## [4.6.0](https://github.com/testcontainers/testcontainers-python/compare/testcontainers-v4.5.1...testcontainers-v4.6.0) (2024-06-18)


### Features

* **core:** Added ServerContainer ([#595](https://github.com/testcontainers/testcontainers-python/issues/595)) ([0768490](https://github.com/testcontainers/testcontainers-python/commit/076849015ad3542384ecf8cf6c205d5d498e4986))
* **core:** Image build (Dockerfile support) ([#585](https://github.com/testcontainers/testcontainers-python/issues/585)) ([54c88cf](https://github.com/testcontainers/testcontainers-python/commit/54c88cf00ad7bb08eb7894c52bed7a9010fd7786))


### Bug Fixes

* Add Cockroach DB Module to Testcontainers ([#608](https://github.com/testcontainers/testcontainers-python/issues/608)) ([4aff679](https://github.com/testcontainers/testcontainers-python/commit/4aff6793f28fbeb8358adcc728283ea9a7b94e5f))
* Container for Milvus database ([#606](https://github.com/testcontainers/testcontainers-python/issues/606)) ([ec76df2](https://github.com/testcontainers/testcontainers-python/commit/ec76df27c3d95ac1b79df3a049b4e2c12539081d))
* move TESTCONTAINERS_HOST_OVERRIDE to config.py ([#603](https://github.com/testcontainers/testcontainers-python/issues/603)) ([2a5a190](https://github.com/testcontainers/testcontainers-python/commit/2a5a1904391020a9da4be17b32f23b36d9385c29)), closes [#602](https://github.com/testcontainers/testcontainers-python/issues/602)
* **mqtt:** Add mqtt.MosquittoContainer ([#568](https://github.com/testcontainers/testcontainers-python/issues/568)) ([#599](https://github.com/testcontainers/testcontainers-python/issues/599)) ([59cb6fc](https://github.com/testcontainers/testcontainers-python/commit/59cb6fc4e7d93870ff2d0d961d14ccd5142a8a05))


### Documentation

* **main:** Private registry ([#598](https://github.com/testcontainers/testcontainers-python/issues/598)) ([9045c0a](https://github.com/testcontainers/testcontainers-python/commit/9045c0aea6029283490c89aea985e625dcdfc7b9))
* Update private registry instructions ([#604](https://github.com/testcontainers/testcontainers-python/issues/604)) ([f5a019b](https://github.com/testcontainers/testcontainers-python/commit/f5a019b6d2552788478e4a10cd17f7a2b453abb9))

## [4.5.1](https://github.com/testcontainers/testcontainers-python/compare/testcontainers-v4.5.0...testcontainers-v4.5.1) (2024-05-31)


### Bug Fixes

* **k3s:** add configuration parameter for disabling cgroup mount to avoid "unable to apply cgroup configuration" ([#592](https://github.com/testcontainers/testcontainers-python/issues/592)) ([8917772](https://github.com/testcontainers/testcontainers-python/commit/8917772d8c90d26086af3b9606657c95928e2b9d))
* **keycloak:** realm import ([#584](https://github.com/testcontainers/testcontainers-python/issues/584)) ([111bd09](https://github.com/testcontainers/testcontainers-python/commit/111bd094428b83233d7eca693d94e10b34ee8ae8))

## [4.5.0](https://github.com/testcontainers/testcontainers-python/compare/testcontainers-v4.4.1...testcontainers-v4.5.0) (2024-05-25)


Expand Down
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
ARG version=3.8
FROM python:${version}
ARG PYTHON_VERSION
FROM python:${version}-slim-bookworm

WORKDIR /workspace
RUN pip install --upgrade pip \
&& apt-get update \
&& apt-get install -y \
freetds-dev \
&& rm -rf /var/lib/apt/lists/*

# install requirements we exported from poetry
COPY build/requirements.txt requirements.txt
COPY setup.py README.rst ./
RUN pip install -r requirements.txt

# copy project source
COPY . .
Loading
Loading