-
Notifications
You must be signed in to change notification settings - Fork 604
ci: add addlicense linter to CI workflow for license checks #2625
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @Aswinr24, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request introduces a new CI check using addlicense
to ensure all source files have the correct license headers. It downloads the addlicense
tool, configures it to check for the 'Google LLC' copyright holder, and fails the CI if any files are missing or have incorrect headers. The PR also depends on a fix in the upstream addlicense
repository.
Highlights
- License Header Enforcement: Adds a CI check to enforce consistent license headers across the project using the
addlicense
tool. - CI Workflow Integration: Integrates
addlicense
into the existing CI workflow to automatically verify license headers on each pull request. - Dependency on Upstream Fix: Highlights the dependency on a specific pull request in the
addlicense
repository that fixes copyright holder checks and adds support for spec files.
Changelog
- .github/workflows/tests.yml
- Adds a new job to the CI workflow to download, install, and run
addlicense
. - Configures
addlicense
to check for the 'Google LLC' copyright holder. - Fails the CI if any files are missing license headers or have incorrect ones.
- Adds steps to download and extract the addlicense binary from GitHub releases.
- Adds a check to verify if
git status --porcelain
returns any changes after runningaddlicense
, indicating missing or incorrect headers.
- Adds a new job to the CI workflow to download, install, and run
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A license header, small and neat,
Ensures our code is bittersweet.
With copyright clear,
There's naught to fear,
And contributions we can greet.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This PR introduces a license header check to the CI workflow, which is a valuable addition for maintaining code quality and compliance. The implementation is straightforward, but there are a few areas where it can be improved for robustness and user experience.
Summary of Findings
- Error Handling in CI Workflow: The CI workflow includes a check for license headers, but the error message could be improved to provide more specific guidance to the user. Suggesting a direct command to fix the issue would be beneficial.
- Downloading addlicense Binary: The CI workflow downloads the
addlicense
binary usingcurl
andgrep
. This approach is fragile and depends on the structure of the GitHub API response. A more robust method, such as using the GitHub CLI or a dedicated action, would be preferable.
Merge Readiness
The PR is almost ready for merging. Addressing the error handling and binary download method would significantly improve the reliability and user-friendliness of the CI workflow. I am unable to directly approve the pull request, and other reviewers should also review and approve this code before merging. I recommend that the pull request not be merged until the high severity issues are addressed.
Description:
This PR adds addlicense as a linter in the CI workflow to enforce copyright and license headers across the project. It ensures that all source files include the necessary license headers, and the CI will fail if any file is missing or incorrect.
Related Issues:
Closes #2558
Linked PRs:
This PR depends on the following fix in addlicense:
google/addlicense#172 (Fixes copyright holder check, ignores empty files, and adds support for spec files)
The current implementation remains unaffected since specific files are manually excluded. However, once a new version of addlicense incorporating the changes from the referenced PR is released, explicitly defining exclusions (such as empty init.py files) may no longer be necessary.
Changes Made:
Checklist