Skip to content

Add pre-commit framework with insert-license hook to enforce SPDX headers #7

Description

@janhoy

Summary

There is currently no automated enforcement of the ASF SPDX license header on source files.
Add the pre-commit framework with the
insert-license 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions