You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/contributing.md
+72-47Lines changed: 72 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,71 +1,96 @@
1
-
# Contributing
1
+
# Contributing to `testcontainers-python`
2
2
3
-
`Testcontainers for Go` is open source, and we love to receive contributions from our community — you!
3
+
Welcome to the `testcontainers-python` community!
4
+
This should give you an idea about how we build, test and release `testcontainers-python`!
4
5
5
-
There are many ways to contribute, from writing tutorials or blog posts, improving the documentation, submitting bug reports and feature requests, or writing code for the core library or for a technology module.
6
+
Highly recommended to read this document thoroughly to understand what we're working on right now
7
+
and what our priorities are before you are trying to contribute something.
6
8
7
-
In any case, if you like the project, please star the project on [GitHub](https://github.com/testcontainers/testcontainers-go/stargazers) and help spread the word :)
8
-
Also join our [Slack workspace](http://slack.testcontainers.org) to get help, share your ideas, and chat with the community.
9
+
This will greatly increase your chances of getting prompt replies as the maintainers are volunteers themselves.
9
10
10
-
## Questions
11
+
## Before you begin
11
12
12
-
GitHub is reserved for bug reports and feature requests; it is not the place for general questions.
13
-
If you have a question or an unconfirmed bug, please visit our [Slack workspace](https://testcontainers.slack.com/);
14
-
feedback and ideas are always welcome.
13
+
We recommend following these steps:
15
14
16
-
## Code contributions
15
+
1. Finish reading this document.
16
+
2. Read the [recently updated issues](https://github.com/testcontainers/testcontainers-python/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc){:target="\_blank"}
17
+
3. Look for existing issues on the subject you are interested in - we do our best to label everything correctly
17
18
18
-
If you have a bug fix or new feature that you would like to contribute, please find or open an [issue](https://github.com/testcontainers/testcontainers-go/issues) first.
19
-
It's important to talk about what you would like to do, as there may already be someone working on it,
20
-
or there may be context to be aware of before implementing the change.
19
+
## Local development
21
20
22
-
Next would be to fork the repository and make your changes in a feature branch. **Please do not commit changes to the `main` branch**,
23
-
otherwise we won't be able to contribute to your changes directly in the PR.
21
+
### Pre-Requisites
24
22
25
-
### Submitting your changes
23
+
You need to have the following tools available to you:
26
24
27
-
Please just be sure to:
25
+
-`make` - You'll need a GNU Make for common developer activities
26
+
-`poetry` - This is the primary package manager for the project
27
+
-`pyenv`**Recommended**: For installing python versions for your system.
28
+
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`.
28
29
29
-
- follow the style, naming and structure conventions of the rest of the project.
30
-
- make commits atomic and easy to merge.
31
-
- use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) for the PR title. This will help us to understand the nature of the changes, and to generate the changelog after all the commits in the PR are squashed.
32
-
- Please use the `feat!`, `chore!`, `fix!`... types for breaking changes, as these categories are considered as `breaking change` in the changelog. Please use the `!` to denote a breaking change.
33
-
- Please use the `security` type for security fixes, as these categories are considered as `security` in the changelog.
34
-
- Please use the `feat` type for new features, as these categories are considered as `feature` in the changelog.
35
-
- Please use the `fix` type for bug fixes, as these categories are considered as `bug` in the changelog.
36
-
- Please use the `docs` type for documentation updates, as these categories are considered as `documentation` in the changelog.
37
-
- Please use the `chore` type for housekeeping commits, including `build`, `ci`, `style`, `refactor`, `test`, `perf` and so on, as these categories are considered as `chore` in the changelog.
38
-
- Please use the `deps` type for dependency updates, as these categories are considered as `dependencies` in the changelog.
30
+
### Build and test
39
31
40
-
!!!important
41
-
There is a GitHub Actions workflow that will check if your PR title follows the conventional commits convention. If not, it contributes a failed check to your PR.
42
-
To know more about the conventions, please refer to the [workflow file](https://github.com/testcontainers/testcontainers-go/blob/main/.github/workflows/conventions.yml).
32
+
- Run `make install` to get `poetry` to install all dependencies and set up `pre-commit`
33
+
-**Recommended**: Run `make` or `make help` to see other commands available to you.
34
+
- After this, you should have a working virtual environment and proceed with writing code with your favorite IDE
35
+
-**TIP**: You can run `make core/tests` or `make modules/<my-module>/tests` to run the tests specifically for that to speed up feedback cycles
36
+
- You can also run `make lint` to run the `pre-commit` for the entire codebase.
43
37
44
-
- use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) for your commit messages, as it improves the readability of the commit history, and the review process. Please follow the above conventions for the PR title.
45
-
- unless necessary, please try to **avoid pushing --force** to the published branch you submitted a PR from, as it makes it harder to review the changes from a given previous state.
46
-
- apply format running `make lint-all`. It will run `golangci-lint` for the core and modules with the configuration set in the root directory of the project. Please be aware that the lint stage on CI could fail if this is not done.
47
-
- For linting just the modules: `make -C modules lint-modules`
48
-
- For linting just the examples: `make -C examples lint-examples`
49
-
- For linting just the modulegen: `make -C modulegen lint`
50
-
- verify all tests are passing. Build and test the project with `make test-all` to do this.
51
-
_ For a given module or example, go to the module or example directory and run `make test`.
52
-
_ If you find an `ld warning` message on MacOS, you can ignore it. It is indeed a warning: https://github.com/golang/go/issues/61229
38
+
## Adding new modules
53
39
54
-
> === Errors
55
-
> ld: warning: '/private/var/folders/3y/8hbf585d4yl6f8j5yzqx6wz80000gn/T/go-link-2319589277/000018.o' has malformed LC_DYSYMTAB, expected 98 undefined symbols to start at index 1626, found 95 undefined symbols starting at index 1626
40
+
We have an [issue template](https://github.com/testcontainers/testcontainers-python/blob/main/.github/ISSUE_TEMPLATE/new-container.md){:target="\_blank"} for adding new module containers, please refer to that for more information.
41
+
Once you've talked to the maintainers (we do our best to reply!) then you can proceed with contributing the new container.
56
42
57
-
- when updating the `go.mod` file, please run `make tidy-all` to ensure all modules are updated.
43
+
!!!WARNING
44
+
45
+
Please raise an issue before you try to contribute a new container! It helps maintainersunderstand your use-case and motivation.
46
+
This way we can keep pull requests forced on the "how", not the "why"! :pray:
47
+
It also gives maintainers a chance to give you last-minute guidance on caveats orexpectations, particularly with
48
+
new extra dependencies and how to manage them.
49
+
50
+
### Module documentation
51
+
52
+
Leave examples for others with your mew module such as `modules/<new_module>/basic_example.py`. You can create as many examples as you want.
53
+
54
+
Create a new `docs/modules/<new_module>.md` describing the basic use of the new container. There is a [starter template provided here](https://raw.githubusercontent.com/testcontainers/testcontainers-python/blob/main/docs/modules/template.md){:target="\_blank"}.
55
+
56
+
!!! important
57
+
58
+
Make sure to add your new module to the sidebar nav in the `mkdocs.yml`
59
+
60
+
## Raising issues
61
+
62
+
We have [Issue Templates](https://raw.githubusercontent.com/testcontainers/testcontainers-python/refs/heads/main/.github/ISSUE_TEMPLATE/new-container.md){:target="\_blank"} to cover most cases, please try to adhere to them, they will guide you through the process.
63
+
Try to look through the existing issues before you raise a new one.
64
+
65
+
## Releasing versions
66
+
67
+
We have automated Semantic Versioning and release via [release-please](https://github.com/testcontainers/testcontainers-python/blob/main/.github/workflows/release-please.yml){:target="\_blank"}.
68
+
This takes care of:
69
+
70
+
- Detecting the next version, based on the commits that landed on `main`
71
+
- When a Release PR has been merged
72
+
- Create a GitHub Release with the CHANGELOG included
73
+
- Update the [CHANGELOG](https://github.com/testcontainers/testcontainers-python/blob/main/CHANGELOG.md){:target="\_blank"}, similar to the GitHub Release
74
+
- Release to PyPI via a [trusted publisher](https://docs.pypi.org/trusted-publishers/using-a-publisher/){:target="\_blank"}
75
+
- Automatically script updates in files where it's needed instead of hand-crafting it (i.e. in `pyproject.toml`)
76
+
77
+
!!!DANGER
78
+
79
+
Community modules are supported on a best-effort basis and for maintenance reasons, any change to them
80
+
is only covered under minor and patch changes.
81
+
Community modules changes DO NOT contribute to major version changes!
82
+
If your community module container was broken by a minor or patch version change, check out the change logs!
58
83
59
84
## Documentation contributions
60
85
61
-
The _Testcontainers for Go_ documentation is a static site built with [MkDocs](https://www.mkdocs.org/).
62
-
We use the [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) theme, which offers a number of useful extensions to MkDocs.
86
+
The _Testcontainers for Go_ documentation is a static site built with [MkDocs](https://www.mkdocs.org/){:target="\_blank"}.
87
+
We use the [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/){:target="\_blank"} theme, which offers a number of useful extensions to MkDocs.
63
88
64
89
We publish our documentation using Netlify.
65
90
66
91
### Adding code snippets
67
92
68
-
To include code snippets in the documentation, we use the [codeinclude plugin](https://github.com/rnorth/mkdocs-codeinclude-plugin), which uses the following syntax:
93
+
To include code snippets in the documentation, we use the [codeinclude plugin](https://github.com/rnorth/mkdocs-codeinclude-plugin){:target="\_blank"}, which uses the following syntax:
69
94
70
95
> <!--codeinclude--><br/> > [Human readable title for snippet](./relative_path_to_example_code.go) targeting_expression<br/> > [Human readable title for snippet](./relative_path_to_example_code.go) targeting_expression<br/> > <!--/codeinclude--><br/>
71
96
@@ -75,7 +100,7 @@ in the snippet, and each `targeting_expression` would be:
75
100
-`block:someString` or
76
101
-`inside_block:someString`
77
102
78
-
Please refer to the [codeinclude plugin documentation](https://github.com/rnorth/mkdocs-codeinclude-plugin) for more information.
103
+
Please refer to the [codeinclude plugin documentation](https://github.com/rnorth/mkdocs-codeinclude-plugin){:target="\_blank"} for more information.
79
104
80
105
### Previewing rendered content
81
106
@@ -93,7 +118,7 @@ Once finished, you can destroy the container with the following command:
93
118
make clean-docs
94
119
```
95
120
96
-
### PR Preview deployments
121
+
### PR preview deployments
97
122
98
123
Note that documentation for pull requests will automatically be published by Netlify as 'deploy previews'.
99
124
These deployment previews can be accessed via the `deploy/netlify` check that appears for each pull request.
_Testcontainers for Go_ will attempt to detect the Docker environment and configure everything to work automatically.
8
+
9
+
However, sometimes customization is required. _Testcontainers for Go_ will respect the following order:
10
+
11
+
1. Read the **tc.host** property in the `~/.testcontainers.properties` file. E.g. `tc.host=tcp://my.docker.host:1234`
12
+
13
+
2. Read the **DOCKER_HOST** environment variable. E.g. `DOCKER_HOST=unix:///var/run/docker.sock`
14
+
See [Docker environment variables](https://docs.docker.com/engine/reference/commandline/cli/#environment-variables) for more information.
15
+
16
+
3. Read the Go context for the **DOCKER_HOST** key. E.g. `ctx.Value("DOCKER_HOST")`. This is used internally for the library to pass the Docker host to the resource reaper.
17
+
18
+
4. Read the default Docker socket path, without the unix schema. E.g. `/var/run/docker.sock`
19
+
20
+
5. Read the **docker.host** property in the `~/.testcontainers.properties` file. E.g. `docker.host=tcp://my.docker.host:1234`
21
+
22
+
6. Read the rootless Docker socket path, checking in the following alternative locations:
23
+
24
+
1.`${XDG_RUNTIME_DIR}/.docker/run/docker.sock`.
25
+
2.`${HOME}/.docker/run/docker.sock`.
26
+
3.`${HOME}/.docker/desktop/docker.sock`.
27
+
4.`/run/user/${UID}/docker.sock`, where `${UID}` is the user ID of the current user.
28
+
29
+
7. The library panics if none of the above are set, meaning that the Docker host was not detected.
0 commit comments