Skip to content

fix: Handle architecture-specific license dependencies - #1581

Merged
SamMorrowDrums merged 5 commits into
mainfrom
fix/arch-specific-licenses
Dec 12, 2025
Merged

fix: Handle architecture-specific license dependencies#1581
SamMorrowDrums merged 5 commits into
mainfrom
fix/arch-specific-licenses

Conversation

@SamMorrowDrums

Copy link
Copy Markdown
Collaborator

Summary

This PR improves the license script to handle architecture-specific dependency differences. Some dependencies have different module graphs for different GOARCH values (e.g., x/sys/cpu vs x/sys/unix), which can result in different licenses being exported per architecture.

Problem

As discovered in github/cli, some deps change which changes the mod graph for different GOARCH values. For example:

  • amd64 might have x/sys/cpu and x/sys/unix so the common ancestor is x/sys
  • arm64 might just have x/sys/unix so the common ancestor is x/sys/unix

This means license reports can differ between architectures on the same platform.

Solution

Updated script/licenses to:

  1. Check all architectures per platform - linux (amd64, arm64, 386), darwin (amd64, arm64), windows (amd64, arm64, 386)
  2. Group identical results - Architectures with the same dependencies are grouped together with comma-separated headers
  3. Show divergent lists - Only shows separate sections when architectures actually differ
  4. Add index at top - Each platform file now has a table of contents linking to each architecture section
  5. Save per-arch licenses - Each architecture's licenses are saved in the third-party folder

Changes

  • script/licenses: Enhanced to handle multi-architecture license generation with grouping
  • third-party-licenses.*.md: Updated with architecture sections and index
  • third-party/: Contains architecture-specific license folders

Example Output

When all architectures have the same deps:

## Index

- [amd64, arm64, 386](#amd64-arm64-386)

## amd64, arm64, 386

| Module | License |
|--------|---------|
| ... | ... |

When architectures differ:

## Index

- [amd64](#amd64)
- [arm64, 386](#arm64-386)

## amd64

| Module | License |
|--------|---------|
| ... | ... |

## arm64, 386

| Module | License |
|--------|---------|
| ... | ... |

The licenses script now:
- Generates separate license reports per GOOS/GOARCH combination
- Groups identical reports together (comma-separated arch names)
- Adds a Table of Contents at the top of each platform file
- Handles cases where different architectures have different dependencies
  (e.g., x/sys/unix vs x/sys/windows, mousetrap on Windows only)

This addresses the issue discovered in cli/cli where some deps changed
which changed the mod graph for different GOARCH and affected the
exported licenses because go-licenses tries to find common ancestors.
@SamMorrowDrums
SamMorrowDrums requested a review from a team as a code owner December 12, 2025 10:43
Copilot AI review requested due to automatic review settings December 12, 2025 10:43

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 enhances the license generation script to properly handle architecture-specific dependency differences across GOOS/GOARCH combinations. The script now generates separate reports per architecture, groups identical results with comma-separated headers, and adds a table of contents to each platform file.

Key changes:

  • Multi-architecture license generation for Linux (amd64, arm64, 386), Darwin (amd64, arm64), and Windows (amd64, arm64, 386)
  • Grouping logic that consolidates architectures with identical dependency lists
  • Automated table of contents generation with anchor links

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
script/licenses Complete rewrite to support multi-architecture license generation with grouping logic, TOC generation, and per-arch report handling
third-party-licenses.linux.md Restructured with TOC and architecture sections; packages reordered alphabetically
third-party-licenses.darwin.md Restructured with TOC and architecture sections; packages reordered alphabetically
third-party-licenses.windows.md Restructured with TOC and architecture sections; packages reordered alphabetically

Comment thread script/licenses Outdated
Comment thread script/licenses Outdated
Comment thread script/licenses Outdated
Comment thread script/licenses Outdated
Comment thread script/licenses Outdated