Skip to content

ci: add third-party license notices - #2268

Open
Tantanz20020918 wants to merge 19 commits into
mainfrom
ci/third-party-notices
Open

ci: add third-party license notices#2268
Tantanz20020918 wants to merge 19 commits into
mainfrom
ci/third-party-notices

Conversation

@Tantanz20020918

@Tantanz20020918 Tantanz20020918 commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add a deterministic third-party license notice document and require it to stay in sync with production Go and npm dependencies. The release and preview package workflows now validate that notices are current and included in published packages.

Changes

  • Add scripts/third_party_notices.py, tests, and a local Git hook for deterministic dependency notices
  • Add THIRD_PARTY_NOTICES.md to npm, preview, and GoReleaser package contents
  • Gate CI and release workflows on make check-third-party-notices before signing or publication

Test Plan

  • python3 scripts/third_party_notices.test.py passed
  • bash scripts/third_party_notices_hook.test.sh passed
  • bash scripts/pkg-pr-new-workflow.test.sh and bash scripts/release-workflow.test.sh passed
  • manual verification: git diff --check origin/main...HEAD passed
  • skipped: make unit-test was not run for this publication review

Related Issues

N/A

Summary by CodeRabbit

  • New Features

    • Added comprehensive third-party dependency notices covering Go and JavaScript components, licenses, sources, and copyrights.
    • Published packages and release archives now include the notices file.
    • Added commands to generate and validate notices.
  • Bug Fixes

    • Updated an indirect Go dependency.
  • Documentation

    • Documented notice generation, review, and verification requirements.
  • Chores

    • Added automated license-compliance checks to CI and release workflows.
    • Added safeguards requiring notices when dependency metadata changes.

@github-actions github-actions Bot added the size/L Large or sensitive change across domains or core paths label Aug 10, 2026
Comment thread scripts/third_party_notices.test.py Fixed
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The repository adds deterministic third-party notice generation, local dependency-change enforcement, CI validation, pinned workflow tooling, and release artifact checks. It also includes the generated notices document and tests for parsing, safety, workflow contracts, and Git hook behavior.

Changes

Third-party notice compliance

Layer / File(s) Summary
Notice generation and validation
scripts/third_party_notices.py, scripts/third_party_notices.test.py, THIRD_PARTY_NOTICES.md, go.mod
The repository collects Go and npm dependencies, validates licenses and paths, renders deterministic notices, checks freshness, and tests failure cases and output stability.
Local notice enforcement
.githooks/pre-commit, Makefile, scripts/third_party_notices_hook.test.sh, README.md
The hook requires staged notices for staged dependency changes. Make targets generate and validate notices, install hooks, and run related tests.
CI and package workflow compliance
.github/workflows/ci.yml, .github/workflows/pkg-pr-new.yml, scripts/ci-workflow.test.sh, scripts/pkg-pr-new-workflow.test.sh
CI and package preview workflows use pinned Node and npm versions, run notice checks, and enforce workflow contracts.
Release compliance and artifact validation
.github/workflows/release.yml, .goreleaser.yml, package.json, scripts/build-pkg-pr-new.sh, scripts/release-workflow.test.sh
Release jobs validate the preflight commit, notice checks, and notice files in archives and npm packages. Retry guidance reports license-compliance failures.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Preflight
  participant LicenseCompliance
  participant BuildSignNotarize
  participant ReleaseArtifacts
  Preflight->>LicenseCompliance: provide validated source commit
  LicenseCompliance->>LicenseCompliance: run make check-third-party-notices
  LicenseCompliance->>BuildSignNotarize: allow build after compliance succeeds
  BuildSignNotarize->>ReleaseArtifacts: create release archives and npm package
  ReleaseArtifacts->>BuildSignNotarize: verify THIRD_PARTY_NOTICES.md
Loading

Suggested reviewers: liangshuo-1

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.32% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding third-party license notices and related enforcement.
Description check ✅ Passed The description includes all required sections and clearly explains the changes, tests, and the skipped unit-test run.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/third-party-notices

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@4fe1315d8c877911899f40b66cc078f05fe4e334

🧩 Skill update

npx skills add larksuite/cli#ci/third-party-notices -y -g

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.githooks/pre-commit:
- Around line 8-9: Update the pre-commit condition to trigger notice
regeneration only when staged manifest changes affect dependency declarations,
rather than any edit to go.mod, go.sum, package.json, or package-lock.json.
Preserve the existing THIRD_PARTY_NOTICES.md exemption, and add a regression
test covering a non-dependency manifest edit that should not reject the commit.

In `@README.md`:
- Around line 321-324: Update the “Third-party dependency notices” section to
describe the repository hook as local enforcement: state that it blocks commits
when dependency metadata changes without a staged notice file, while CI
independently verifies notice freshness.

In `@scripts/third_party_notices.py`:
- Around line 188-200: Update _detect_license_ids and the supported-license
detection helpers to reject incomplete license text by requiring all mandatory
clauses for MIT, Apache-2.0, BSD, and ISC before adding an identifier. Preserve
valid complete-license detection, and add negative tests covering truncated MIT,
Apache, BSD, and ISC notices.
- Around line 236-244: Update _copyright_lines to exclude lines whose normalized
text starts with “copyright notice” or “copyright license” before collecting
attribution lines, while preserving existing © handling, deduplication, and the
“Not specified” fallback.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d891dbf0-1e37-455c-b8e3-3c502ff1325e

📥 Commits

Reviewing files that changed from the base of the PR and between 2016120 and e13418d.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (19)
  • .githooks/pre-commit
  • .github/workflows/ci.yml
  • .github/workflows/pkg-pr-new.yml
  • .github/workflows/release.yml
  • .goreleaser.yml
  • Makefile
  • README.md
  • THIRD_PARTY_NOTICES.md
  • go.mod
  • package.json
  • scripts/build-pkg-pr-new.sh
  • scripts/ci-workflow.test.sh
  • scripts/pkg-pr-new-workflow.test.sh
  • scripts/release-workflow.test.sh
  • scripts/testdata/third_party_notices/mit-package/LICENSE
  • scripts/testdata/third_party_notices/mit-package/package.json
  • scripts/third_party_notices.py
  • scripts/third_party_notices.test.py
  • scripts/third_party_notices_hook.test.sh

Comment thread .githooks/pre-commit Outdated
Comment thread README.md
Comment thread scripts/third_party_notices.py
Comment thread scripts/third_party_notices.py
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.47%. Comparing base (2016120) to head (4fe1315).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2268      +/-   ##
==========================================
+ Coverage   76.36%   76.47%   +0.10%     
==========================================
  Files        1011     1013       +2     
  Lines      111269   112079     +810     
==========================================
+ Hits        84970    85707     +737     
- Misses      19815    19859      +44     
- Partials     6484     6513      +29     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Tantanz20020918

Copy link
Copy Markdown
Collaborator Author

Implemented in 53651d4a.

  • The hook now compares actual Go/npm production dependency declarations; Go version and npm metadata-only edits are allowed, with regression coverage for both paths.
  • The README describes the hook as local enforcement and CI as the independent freshness check.
  • License detection now requires the essential clauses for MIT, Apache-2.0, BSD-2/3-Clause, and ISC; truncated-text cases are covered by tests.
  • Copyright metadata no longer includes license clauses beginning with copyright notice or copyright license.
  • Simplified the test imports and added the missing repository license headers.

Validated with python3 scripts/third_party_notices.test.py, bash scripts/third_party_notices_hook.test.sh, make check-third-party-notices, and make script-test.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (4)
scripts/third_party_notices_hook.test.sh (2)

50-53: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Strengthen the index-only hook check.

The regex matches forbidden commands only at the start of a physical line. It misses forms such as if python3 ..., env python3 ..., git -C ... add, and command substitutions. A forbidden hook change can pass this test. Use a shell-aware check or a strict allow-list for executable commands.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/third_party_notices_hook.test.sh` around lines 50 - 53, Strengthen
the pre-commit validation in scripts/third_party_notices_hook.test.sh beyond the
current line-start regex so it detects forbidden execution or staging commands
in shell contexts such as conditionals, env invocations, git -C ... add, and
command substitutions. Prefer a shell-aware parser or strict allow-list of
permitted executable commands, while preserving the existing failure message and
exit behavior.

35-49: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Cover optionalDependencies explicitly.

The hook compares both dependencies and optionalDependencies, but these cases populate only dependencies. Add an optional dependency to the rejection, acceptance, and metadata-only scenarios.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/third_party_notices_hook.test.sh` around lines 35 - 49, Update the
test scenarios around the pre-commit hook to include an optionalDependencies
entry alongside dependencies in the missing-notices rejection, notices-present
acceptance, and metadata-only acceptance cases. Keep the existing expected
commit outcomes unchanged while ensuring both dependency sections are covered.
scripts/third_party_notices.test.py (2)

202-203: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the release environment for every invocation.

run.call_args checks only the last call. An earlier release target could omit CGO_ENABLED=0 and this test would still pass. Iterate over run.call_args_list and verify the environment and target arguments for every invocation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/third_party_notices.test.py` around lines 202 - 203, Update the test
around the release invocation mock to iterate through run.call_args_list instead
of checking only run.call_args. For every invocation, assert CGO_ENABLED is "0"
and validate the corresponding release target arguments against
notices.RELEASE_TARGETS.

47-61: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Use a complete Apache-2.0 fixture.

APACHE_TEXT contains the header and section headings, but not the license clauses. The accepted component test can therefore accept an incomplete Apache document while the truncated-license test intends to reject incomplete text. Use the complete license text, or separate a minimal detector fixture from the component-preservation fixture.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/third_party_notices.test.py` around lines 47 - 61, Update the
APACHE_TEXT fixture used by the third-party notices tests to contain the
complete Apache-2.0 license clauses, not just its header and section headings.
Preserve the truncated-license test’s ability to reject incomplete text; if a
minimal fixture is still needed for detection, separate it from the complete
component-preservation fixture.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/third_party_notices_hook.test.sh`:
- Around line 31-33: Update the test setup around the go.mod change and the hook
validation to verify regenerated THIRD_PARTY_NOTICES.md output, rather than
treating a go directive-only change as metadata-only. Use the existing hook
invocation and notice-generation comparison path to assert that go.mod changes
producing different notices are rejected.

---

Nitpick comments:
In `@scripts/third_party_notices_hook.test.sh`:
- Around line 50-53: Strengthen the pre-commit validation in
scripts/third_party_notices_hook.test.sh beyond the current line-start regex so
it detects forbidden execution or staging commands in shell contexts such as
conditionals, env invocations, git -C ... add, and command substitutions. Prefer
a shell-aware parser or strict allow-list of permitted executable commands,
while preserving the existing failure message and exit behavior.
- Around line 35-49: Update the test scenarios around the pre-commit hook to
include an optionalDependencies entry alongside dependencies in the
missing-notices rejection, notices-present acceptance, and metadata-only
acceptance cases. Keep the existing expected commit outcomes unchanged while
ensuring both dependency sections are covered.

In `@scripts/third_party_notices.test.py`:
- Around line 202-203: Update the test around the release invocation mock to
iterate through run.call_args_list instead of checking only run.call_args. For
every invocation, assert CGO_ENABLED is "0" and validate the corresponding
release target arguments against notices.RELEASE_TARGETS.
- Around line 47-61: Update the APACHE_TEXT fixture used by the third-party
notices tests to contain the complete Apache-2.0 license clauses, not just its
header and section headings. Preserve the truncated-license test’s ability to
reject incomplete text; if a minimal fixture is still needed for detection,
separate it from the complete component-preservation fixture.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1affd966-82ae-435e-a736-7917e0d9a8a2

📥 Commits

Reviewing files that changed from the base of the PR and between e13418d and 6888bc4.

📒 Files selected for processing (7)
  • .githooks/pre-commit
  • README.md
  • THIRD_PARTY_NOTICES.md
  • scripts/testdata/third_party_notices/mit-package/LICENSE
  • scripts/third_party_notices.py
  • scripts/third_party_notices.test.py
  • scripts/third_party_notices_hook.test.sh
🚧 Files skipped from review as they are similar to previous changes (5)
  • README.md
  • .githooks/pre-commit
  • scripts/testdata/third_party_notices/mit-package/LICENSE
  • THIRD_PARTY_NOTICES.md
  • scripts/third_party_notices.py

Comment thread scripts/third_party_notices_hook.test.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature size/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant