Skip to content

[INFRA] Cover XML files in license header check and fix Dockerfile pattern - #12770

Merged
zhouyuan merged 3 commits into
apache:mainfrom
philo-he:fix-license-header-check
Aug 14, 2026
Merged

[INFRA] Cover XML files in license header check and fix Dockerfile pattern#12770
zhouyuan merged 3 commits into
apache:mainfrom
philo-he:fix-license-header-check

Conversation

@philo-he

Copy link
Copy Markdown
Member

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.

Copilot AI lite review requested due to automatic review settings August 14, 2026 06:06
@github-actions github-actions Bot added the INFRA label Aug 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 *.dockfile extension pattern to Dockerfile* (covers Dockerfile and suffixed variants).
  • Add *.yaml support and make wrapper selection more flexible by adding a glob-pattern fallback in get_wrapper.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings August 14, 2026 06:24
@philo-he
philo-he requested a review from weiting-chen August 14, 2026 06:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@philo-he
philo-he force-pushed the fix-license-header-check branch from 5bf4606 to 02dda93 Compare August 14, 2026 07:31
Copilot AI review requested due to automatic review settings August 14, 2026 07:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 returns None when no pattern matches, but its caller (check_license_header) unconditionally accesses wrap.wrapper, which would raise an AttributeError with 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 handle None.
    # 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
zhouyuan merged commit 3cc98da into apache:main Aug 14, 2026
4 checks passed
@philo-he
philo-he deleted the fix-license-header-check branch August 14, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants