8000 Ensure lint workflow checks whether 3rd party license and code is up to date by andyfeller · Pull Request #11047 · cli/cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Ensure lint workflow checks whether 3rd party license and code is up to date #11047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 23, 2025

Conversation

andyfeller
Copy link
Member

fixes #9422
fixes github/cli#111

This pull request addresses GitHub CLI obligation to comply with the licenses of our 3rd party dependencies.

These changes update the lint workflow to verify license information is up to date including source code certain licenses require redistributing source code around.

Additionally, this pull request introduces scripts/license and scripts/license-check to help maintainers and contributors regenerate this information easily.

This commit introduces the use of `go-licenses` within CI/CD and manual processes for generating / updating the license information used by GitHub CLI including the code required by license to be redistributed.

During GitHub CLI pull requests, the `lint` workflow will notify users if this information is not updated.
@Copilot Copilot AI review requested due to automatic review settings May 30, 2025 16:54
@andyfeller andyfeller requested a review from a team as a code owner May 30, 2025 16:54
@andyfeller andyfeller requested a review from babakks May 30, 2025 16:54
Copy link
Contributor
@Copilot Copilot AI left a comment

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 adds automated checks and tooling to ensure third-party license information is kept up to date, including source files for licenses that require redistribution.

  • Introduce script/licenses to generate license reports and copy necessary license files
  • Add script/licenses-check and update .github/workflows/lint.yml to fail CI if license docs aren’t current
  • Add documentation (docs/license-compliance.md) and a Go-licenses template for consistent output

Reviewed Changes

Copilot reviewed 1028 out of 1028 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.github/workflows/lint.yml Include license compliance paths and add a “Check licenses” step
script/licenses New script to generate third-party license files
script/licenses-check New script to verify license documentation is up to date
docs/license-compliance.md Documentation for maintaining and checking license compliance
.github/licenses.tmpl Go-licenses template for generating markdown listings
Comments suppressed due to low confidence (2)

script/licenses-check:1

  • Ensure this script file has execute permissions (e.g., chmod +x script/licenses-check) so that CI and local invocations can run it directly.
#!/bin/bash

script/licenses:1

  • Ensure this script file has execute permissions (e.g., chmod +x script/licenses) so it can be executed in CI and by contributors.
#!/bin/bash

8000
With these changes, `cli/cli` will be redistributing code as-is due to license compliance, which we will not change or address issues around.  Without these changes, our pull requests are getting a bunch of false positive annotations we cannot and will not fix directly.
@andyfeller andyfeller requested a review from BagToad June 20, 2025 20:55
@vovong92

This comment was marked as spam.

Copy link
Member
@BagToad BagToad left a comment

Choose a reason for hiding this comment

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

LGTM! I don't think anything is blocking enough to avoid merge this 👏

I would like to understand the versioning strategy a bit more, but I don't think that blocks this PR - more details in my comment on script/licenses :)

@@ -0,0 +1,25 @@
#!/bin/bash

go install github.com/google/go-licenses@latest
Copy link
Member

Choose a reason for hiding this comment

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

Question: Are we comfortable with always using the latest here, or should we pin to a sha for stability/security etc?

I know that pinning comes with the "when does this get updated then?" question, and I don't know the answer to that either :P

Copy link
Member

Choose a reason for hiding this comment

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

I guess this is especially in my mind with this script being used in actions... 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

@BagToad : what do you think about conditionalizing this to skip installing this if CI, leaving that to the workflow?

otherwise, everything running the script has to manage its installation. conditionalizing it will make it easy for contributors and maintainers.

Comment on lines +9 to +12
# Clear third-party source code to avoid stale content
rm -rf third-party
mkdir -p third-party

Copy link
Member

Choose a reason for hiding this comment

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

Question: Should we check successes (exit codes) here? Are we okay with this maybe failing but then continuing?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not worried about these commands failing, but if there is a concern then we might want to set -e so any errors cause the whole script to fail.


# Setup temporary directory to collect updated third-party source code
export TEMPDIR="$(mktemp -d)"
trap "rm -fr ${TEMPDIR}" EXIT
Copy link
Member

Choose a reason for hiding this comment

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

(praise) Smart!

echo "Generating licenses for ${goos}..."
GOOS="${goos}" go-licenses save ./... --save_path="${TEMPDIR}/${goos}" --force || echo "Ignore warnings"
GOOS="${goos}" go-licenses report ./... --template .github/licenses.tmpl --ignore github.com/cli/cli > third-party-licenses.${goos}.md || echo "Ignore warnings"
cp -fR "${TEMPDIR}/${goos}"/* third-party/
Copy link
Member

Choose a reason for hiding this comment

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

Question: Similar question here - should we check exit codes here or keep going even if something failed?

@andyfeller andyfeller merged commit f721856 into trunk Jun 23, 2025
17 checks passed
@andyfeller andyfeller deleted the andyfeller/9422-license-compliance branch June 23, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apache 2.0 usage without preservation of copyright and license notices
4 participants
0