| 1 |
# Contributing to this project |
| 2 |
|
| 3 |
In this guide, you will find information relevant for code contributions, though any other kinds of contribution mentioned in the [Ansible Contributing guidelines](https://docs.ansible.com/projects/ansible/devel/community/index.html) are equally appreciated and valuable. |
| 4 |
|
| 5 |
If you have any questions after reading, please contact the community via one or more of the [available channels](https://github.com/ansible-collections/community.clickhouse#communication). Any feedback on this guide is very welcome. |
| 6 |
|
| 7 |
## Reviewing open issue and pull requests |
| 8 |
|
| 9 |
Refer to the [review checklist](https://docs.ansible.com/projects/ansible/devel/community/collection_contributors/collection_reviewing.html) when triaging issues or reviewing pull requests (hereinafter PRs). |
| 10 |
|
| 11 |
Most important things to pay attention to: |
| 12 |
|
| 13 |
- Do not let major/breaking changes sneak into a minor/bugfix release! All such changes should be discussed in a dedicated issue, added to a corresponding milestone (which can be found or created in the project's Issues), and merged right before the major release. Take a look at similar issues to see what needs to be done and reflect on the steps you did/need to do in the issue. |
| 14 |
- Every PR (except doc, refactoring, test-related, or a PR containing a new module/plugin) contains a [changelog fragment](https://docs.ansible.com/projects/ansible/latest/community/development_process.html#creating-a-changelog-fragment). Let's give users a chance to know about the changes. |
| 15 |
- Every new module `DOCUMENTATION` section contains the `version_added: 'x.y.z'` field. Besides the informative purpose, it is used by the changelog-generating tool to add a corresponding entry to the changelog. As the project follows SemVer, it is typically a next minor (x.y.0) version. |
| 16 |
- Every new module argument contains the `version_added: 'x.y.z'` field. As the project follows SemVer, it is typically a next minor (x.y.0) version. |
| 17 |
- Non-refactoring code changes (bugfixes, new features) are covered with, at least, integration tests! There can be exceptions but generally it is a requirement. |
| 18 |
|
| 19 |
## Commit and PR guidelines |
| 20 |
|
| 21 |
- **Focused changes**: keep each PR focused on solving a single, specific issue or adding a single feature. Do not mix unrelated changes (e.g., a bugfix and an unrelated refactoring) in the same PR. This makes reviews faster and reverts safer. |
| 22 |
- **Atomic commits**: use [Conventional Commits](https://www.conventionalcommits.org/) prefixes in your commit messages: `feat:`, `fix:`, `docs:`, `test:`, `refactor:`, `chore:`, `ci:`. For example: `fix: handle empty database list in clickhouse_info`. |
| 23 |
|
| 24 |
## Code contributions |
| 25 |
|
| 26 |
If you want to submit a bugfix or new feature, refer to the [Quick-start development guide](https://docs.ansible.com/projects/ansible/devel/community/create_pr_quick_start.html) first. |
| 27 |
|
| 28 |
## Project-specific info |
| 29 |
|
| 30 |
We assume you have read the [Quick-start development guide](https://docs.ansible.com/projects/ansible/devel/community/create_pr_quick_start.html). |
| 31 |
|
| 32 |
In order for any submitted PR to get merged, this project requires sanity, unit, and integration tests to pass. |
| 33 |
Codecov job is there but not required. |
| 34 |
We use the GitHub Actions platform to run the tests. |
| 35 |
You can see the result in the bottom of every PR in the box listing the jobs and their results: |
| 36 |
|
| 37 |
- Green checkmark: the test has been passed, no more action is needed. |
| 38 |
- Red cross: the test has failed. You can see the reason by clicking the ``Details`` link. Fix them locally and push the commit. |
| 39 |
|
| 40 |
Generally, all jobs must be green. |
| 41 |
Sometimes, there can be failures unrelated to a PR, for example, when a test container is unavailable or there is another part of the code that does not satisfy recently introduced additional sanity checks. |
| 42 |
If you think the failure does not relate to your changes, put a comment about it. |
| 43 |
|
| 44 |
## CI testing |
| 45 |
|
| 46 |
The jobs are launched automatically by GitHub Actions in every PR based on the [matrix](https://github.com/ansible-collections/community.clickhouse/blob/main/.github/workflows/ansible-test-plugins.yml). |
| 47 |
|
| 48 |
As the project is included in `ansible` community package, it is a requirement for us to test against all supported `ansible-core` versions and corresponding Python versions. |
| 49 |
To keep the matrix relevant, we are subscribed to the [news-for-maintainers](https://github.com/ansible-collections/news-for-maintainers) repository and the [Collection maintainers & contributors](https://forum.ansible.com/g/CollectionMaintainer) forum group to track announcements affecting CI. |
| 50 |
|
| 51 |
If our matrix is permanently outdated, for example, when supported `ansible-core` versions are missed, the collections can get excluded from the package, so keep it updated! |
| 52 |
|
| 53 |
## Adding tests |
| 54 |
|
| 55 |
If you are new here, read the [Quick-start development guide](https://docs.ansible.com/projects/ansible/devel/community/create_pr_quick_start.html) first. |
| 56 |
|
| 57 |
When fixing a bug, first reproduce it by adding a task as reported to a suitable file under the ``tests/integration/targets/<module_name>/tasks/`` directory and run the integration tests as described below. The same is relevant for new features. |
| 58 |
|
| 59 |
It is not necessary but if you want you can also add unit tests to a suitable file under the ``tests/units/`` directory and run them as described below. |
| 60 |
|
| 61 |
## Checking your code locally |
| 62 |
|
| 63 |
It will make your and other people's life a bit easier if you run the tests locally and fix all failures before pushing. If you're unable to run the tests locally, please create your PR as a **draft** to avoid reviewers being added automatically. |
| 64 |
|
| 65 |
If you are new here, read the [Quick-start development guide](https://docs.ansible.com/projects/ansible/devel/community/create_pr_quick_start.html) first. |
| 66 |
|
| 67 |
We assume you [prepared your local environment](https://docs.ansible.com/projects/ansible/devel/community/create_pr_quick_start.html#prepare-your-environment) as described in the guide before running the following commands. Otherwise, the command will fail. |
| 68 |
|
| 69 |
### Sanity tests |
| 70 |
|
| 71 |
``` console |
| 72 |
$ ansible-test sanity path/to/changed_file.py --docker -v |
| 73 |
``` |
| 74 |
|
| 75 |
### Integration tests |
| 76 |
|
| 77 |
``` console |
| 78 |
$ ansible-test integration <module_name you changed> --docker <container, e.g. ubuntu2204> -v |
| 79 |
``` |
| 80 |
|
| 81 |
### Unit tests |
| 82 |
|
| 83 |
``` console |
| 84 |
$ ansible-test units tests/unit/plugins/unit_test_file.py --docker |
| 85 |
``` |