Background & Motivation
The wpt-gen repository currently uses the addlicense tool (written in Go) to enforce and apply Apache 2.0 license headers to files. This requires downloading and compiling a Go binary during the build/lint phase, adding an unnecessary toolchain dependency to what is otherwise a Python-centric project. By replacing addlicense with a custom Python script, we can simplify our development environment and make the project more portable. This aligns with the approach recently adopted in ChromeStatus (see chromium-dashboard/pull/6271).
Proposed Changes
- Create License Checker Script:
- Add a new Python script at
scripts/check_license.py.
- The script should recursively scan project files, respecting standard ignored directories (e.g.,
.venv/, .git/, dist/, .pytest_cache/, and others currently defined in ADDLICENSE_IGNORE).
- The script must verify that supported source files (such as
.py, .html, .js) contain the appropriate "Google LLC" Apache 2.0 license header.
- Implement a
--fix argument that automatically prepends the correct license header to files that are missing it.
- Add Tests:
- Create a corresponding
scripts/check_license_test.py (or add it to the tests/ directory) to verify the license checker and fixer logic works as expected.
- Update
Makefile:
- Remove the
ADDLICENSE (go run github.com/google/addlicense@latest) and ADDLICENSE_IGNORE variables.
- Update the
license-check target to execute python scripts/check_license.py.
- Update the
license-fix target to execute python scripts/check_license.py --fix.
- Cleanup:
- Ensure all previous references to the Go toolchain and
addlicense are removed from the project's documentation or configuration files.
Acceptance Criteria
This issue description was drafted by Gemini
Background & Motivation
The
wpt-genrepository currently uses theaddlicensetool (written in Go) to enforce and apply Apache 2.0 license headers to files. This requires downloading and compiling a Go binary during the build/lint phase, adding an unnecessary toolchain dependency to what is otherwise a Python-centric project. By replacingaddlicensewith a custom Python script, we can simplify our development environment and make the project more portable. This aligns with the approach recently adopted in ChromeStatus (see chromium-dashboard/pull/6271).Proposed Changes
scripts/check_license.py..venv/,.git/,dist/,.pytest_cache/, and others currently defined inADDLICENSE_IGNORE)..py,.html,.js) contain the appropriate "Google LLC" Apache 2.0 license header.--fixargument that automatically prepends the correct license header to files that are missing it.scripts/check_license_test.py(or add it to thetests/directory) to verify the license checker and fixer logic works as expected.Makefile:ADDLICENSE(go run github.com/google/addlicense@latest) andADDLICENSE_IGNOREvariables.license-checktarget to executepython scripts/check_license.py.license-fixtarget to executepython scripts/check_license.py --fix.addlicenseare removed from the project's documentation or configuration files.Acceptance Criteria
--fixflag.Makefilerelies entirely on the new Python script instead of the Goaddlicensedependency.make lintandmake lint-fixcontinue to verify and fix licenses successfully.addlicenseand its Go dependency are removed from the project.This issue description was drafted by Gemini