-
-
Notifications
You must be signed in to change notification settings - Fork 586
docs: Add project structure map for contributors #1020
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,36 @@ | ||||||
| # Project structure | ||||||
|
|
||||||
| This is a map of the repository for contributors. Hook *usage* stays in the [README](../README.md). How to add a hook, run tests, and open a PR is in [`.github/CONTRIBUTING.md`](../.github/CONTRIBUTING.md). | ||||||
|
|
||||||
| ## Layout | ||||||
|
|
||||||
| | Path | Role | | ||||||
| | --- | --- | | ||||||
| | `hooks/` | Bash entry points (`<hook_name>.sh`) and shared `_common.sh` | | ||||||
| | `src/pre_commit_terraform/` | Python package: CLI parsing, env expansion, `__GIT_WORKING_DIR__`, `terraform_docs_replace` | | ||||||
| | `tests/pytest/` | Python unit tests (`pytest`) | | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may make sense to specify that we use pytest also as black-box testing for shell hooks functionality |
||||||
| | `tools/entrypoint.sh` | Docker image entrypoint | | ||||||
| | `tools/install/` | Per-tool install scripts used when building the Docker image | | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is also used in the recently added https://github.com/antonbabenko/pre-commit-terraform#most-hooks-pin-a-specific-tool-version |
||||||
| | `dependencies/lock-files/` | Pinned Python constraints for reproducible image builds | | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, not sure that we need to document this 🤔 You know what - let's split this table in a few:
There may be more tables. Some entities may appear in multiple tables as well. |
||||||
| | `.pre-commit-hooks.yaml` | Hook definitions consumed by the [pre-commit framework](https://pre-commit.com/) | | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's mention here https://prek.j178.dev/ as well |
||||||
| | `pyproject.toml` / `hatch.toml` | Python project and build config | | ||||||
| | `tox.ini` | Test environment matrix | | ||||||
| | `.github/workflows/ci-cd.yml` | PR checks, tox, image build; release on merge to `master` | | ||||||
|
|
||||||
| ## Hook types | ||||||
|
|
||||||
| **Shell hooks** (most of them) live in `hooks/<hook_name>.sh`: | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| - Source `_common.sh` for `--args`, `--hook-config`, `--env-vars`, env expansion, `__GIT_WORKING_DIR__`, parallelism, and `terraform init` | ||||||
| - Define `per_dir_hook_unique_part()` for per-directory work | ||||||
| - Call `common::per_dir_hook` instead of splitting arguments by hand | ||||||
|
|
||||||
| **Python hooks** run as `python -m pre_commit_terraform <subcommand>`: | ||||||
|
|
||||||
| - Modules live under `src/pre_commit_terraform/` | ||||||
| - Each subcommand implements `invoke_cli_app()`, `populate_argument_parser()`, and `CLI_SUBCOMMAND_NAME` | ||||||
| - Register new subcommands in `_cli_subcommands.py` and add a hook entry in `.pre-commit-hooks.yaml` | ||||||
|
|
||||||
| ## Local checks | ||||||
|
|
||||||
| Install pre-commit and run the repo's own hooks before you push. Python tests run with `tox`. Do not hand-edit `CHANGELOG.md`; releases own that file. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.