Add pre-commit framework with insert-license hook to enforce SPDX headers
- Dominant language
- Python
- Stars
- 3
- Forks
- 5
- Avg merge
- 1d 23m
- Merged PRs (30d)
- 5
Description
## Summary
There is currently no automated enforcement of the ASF SPDX license header on source files.
Add the [pre-commit](https://pre-commit.com/) framework with the
[`insert-license`](https://github.com/Lucas-C/pre-commit-hooks) hook so that every commit
automatically checks (and optionally inserts) the required header.
## Motivation
- Apache Airflow uses this exact setup to enforce license headers across `.py`, `.sh`,
`.yaml`, `.xml`, `.md` and more via per-type templates in
`scripts/ci/license-templates/`
- Catches missing headers at commit time rather than at release time (when Apache RAT runs)
- ASF policy requires every source file to carry the SPDX Apache-2.0 header
## Proposed changes
1. Add `.pre-commit-config.yaml` with `Lucas-C/pre-commit-hooks` `insert-license` hook
2. Add license header templates under `scripts/ci/license-templates/` (one per file type)
3. Configure hooks for `.py`, `.sh`, `.yaml`/`.yml`, `.toml`, `.cfg`, `.md`
4. Add `pre-commit` to dev dependencies (or document `pip install pre-commit && pre-commit install`)
5. Add a `make pre-commit` target and run in CI
## References
- https://pre-commit.com/
- https://github.com/Lucas-C/pre-commit-hooks
Contributor guide
Assessment
This issue has not been assessed yet.