[INFRA] Cover XML files in license header check and fix Dockerfile pattern - #12770
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the GitHub Actions license-header utility to (1) correctly detect Dockerfile naming patterns and (2) extend license header handling to additional file formats (notably XML), while preserving required file prologues like XML declarations and script shebangs.
Changes:
- Add XML-aware header wrapping (
<!-- ... -->with~leaders) and ensure headers are inserted after an XML declaration when present. - Fix Dockerfile matching by switching from an incorrect
*.dockfileextension pattern toDockerfile*(coversDockerfileand suffixed variants). - Add
*.yamlsupport and make wrapper selection more flexible by adding a glob-pattern fallback inget_wrapper.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
philo-he
force-pushed
the
fix-license-header-check
branch
from
August 14, 2026 07:31
5bf4606 to
02dda93
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (2)
.github/workflows/util/license-header.py:140
- The XML prologue regex only matches LF ("\n"). If an XML file uses CRLF or has no trailing newline after the declaration, the prologue won’t be detected and the license header will be inserted before the XML declaration, producing invalid XML. Consider making the newline optional and accepting CRLF (and optionally a UTF-8 BOM).
"*.xml": attrdict(
{
"wrapper": wrapper_tilde,
"hashbang": False,
"prologue": r"^<\?xml.*?\?>[ \t]*\n",
}
.github/workflows/util/license-header.py:177
get_wrapper()now returnsNonewhen no pattern matches, but its caller (check_license_header) unconditionally accesseswrap.wrapper, which would raise anAttributeErrorwith a confusing message if this ever happens (e.g., due to a future file_types/file_pattern mismatch). Prefer failing fast with a clear exception, or update the caller to handleNone.
# Fall back to glob matching, for keys such as 'Dockerfile*' that are neither an
# exact name nor an extension.
for pattern, attributes in file_types.items():
if fnmatch.fnmatch(filename, pattern):
return attributes
return None
zhouyuan
approved these changes
Aug 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes are proposed in this pull request?
See title.
How was this patch tested?
Local verified.
Was this patch authored or co-authored using generative AI tooling?
Claude Opus 5 co-authored.