Skip to content
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

Add automatic copyright notice verification #963

Merged
merged 36 commits into from
Jun 21, 2023
Merged

Conversation

maltekliemann
Copy link
Member

@maltekliemann maltekliemann commented Feb 2, 2023

This didn't turn out as good as I wanted it to and currently has a couple of limitations (see below). How to use this currently:

Current limitations:

  • We don't check for the presence of the GPL license. This can easily be implemented by checking if the File object's blob starts with the proper string. It might be helpful to remove the leading "// ".
  • Different file types can be handled by extending the File class a little bit. We may want to do that in the future.
  • The checker doesn't dig deep into the git log to verify if old copyrights are correct. Can be done, but totally not within the scope of this PR.

You can see the workflow fail due to a missing copyright in a Rust file here: https://github.com/zeitgeistpm/zeitgeist/actions/runs/4085940425/jobs/7044586744.

Blocked by #964, which needs to be merged before merging this PR to ensure that we're starting off with a correct state. Closes #925.

@maltekliemann maltekliemann added the s:in-progress The pull requests is currently being worked on label Feb 2, 2023
@maltekliemann maltekliemann self-assigned this Feb 2, 2023
@codecov-commenter
Copy link

codecov-commenter commented Feb 2, 2023

Codecov Report

Merging #963 (72dc01a) into main (45edad6) will not change coverage.
The diff coverage is n/a.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@           Coverage Diff           @@
##             main     #963   +/-   ##
=======================================
  Coverage   94.39%   94.39%           
=======================================
  Files          93       93           
  Lines       21060    21060           
=======================================
  Hits        19880    19880           
  Misses       1180     1180           
Flag Coverage Δ
tests 94.39% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
zrml/court/src/lib.rs 87.41% <0.00%> (ø)
zrml/swaps/src/lib.rs 95.76% <0.00%> (ø)
zrml/court/src/mock.rs 33.33% <0.00%> (ø)
zrml/swaps/src/mock.rs 30.90% <0.00%> (ø)
primitives/src/asset.rs 41.17% <0.00%> (ø)
primitives/src/types.rs 3.12% <0.00%> (ø)
zrml/court/src/tests.rs 99.20% <0.00%> (ø)
zrml/swaps/src/tests.rs 99.96% <0.00%> (ø)
zrml/swaps/src/utils.rs 98.03% <0.00%> (ø)
primitives/src/market.rs 71.42% <0.00%> (ø)
... and 41 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@maltekliemann maltekliemann mentioned this pull request Feb 3, 2023
@maltekliemann maltekliemann added the s:blocked The pull requests awaits resolution of dependencies (state what it depends on) label Feb 3, 2023
@maltekliemann maltekliemann added the s:review-needed The pull request requires reviews label Feb 3, 2023
@maltekliemann maltekliemann removed the s:in-progress The pull requests is currently being worked on label Feb 3, 2023
@maltekliemann maltekliemann added this to the v0.3.9 milestone Feb 3, 2023
@maltekliemann maltekliemann removed the s:blocked The pull requests awaits resolution of dependencies (state what it depends on) label Feb 6, 2023
Copy link
Member

@sea212 sea212 left a comment

Choose a reason for hiding this comment

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

This is a partial review, I'll do the rest soon.

Comment on lines +37 to +56
copyright:
name: Copyright Notices
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
- name: Install check-license and dependencies
run: |
pip install scripts/check-license
pip install -r scripts/check-license/requirements.txt
- name: Query files changed
id: files_changed
uses: Ana06/[email protected]
with:
filter: '*.rs$'
- name: Check copyright notices
run: check-license ${{ steps.files_changed.outputs.added_modified }}

Copy link
Member

Choose a reason for hiding this comment

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

The script does offer the option to correct those errors, what's your position to automatically adding a commit with the updated license headers and optionally passing the workflow log in a comment in the PR?

Copy link
Member

Choose a reason for hiding this comment

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

Writing would just trigger in the case of a PR that should be merged into main.

Copy link
Member Author

Choose a reason for hiding this comment

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

And the commit is triggered by placing a label?

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 okay with automating the process, but I have to caution everyone to double-check the diff everytime they do this. And just to prove my point, I botched the test for the File.write function because I forgot how mock works...

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe just a quick argument against automating the write: It probably takes just as much time to execute the write locally and then push the changes manually as it takes to trigger the write remotely, but its much safer to make the changes locally and run git diff once just to check if there's been a mistake.

Comment on lines 1 to 11
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
Copy link
Member

Choose a reason for hiding this comment

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

I see the point of adding the .gitignore in that folder and I think its sufficient for almost any case. However, maybe someone decides to initialize a pyenv within the root to cover anything from the root which will create a .python-version file in the root which is tracked by git. I think it would be better if we include either those rules in the repositories root .gitignore.

Copy link
Member Author

Choose a reason for hiding this comment

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

@maltekliemann maltekliemann added s:in-progress The pull requests is currently being worked on and removed s:review-needed The pull request requires reviews labels Feb 11, 2023
@maltekliemann maltekliemann added s:review-needed The pull request requires reviews and removed s:in-progress The pull requests is currently being worked on labels Feb 12, 2023
Copy link
Member

@sea212 sea212 left a comment

Choose a reason for hiding this comment

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

Didn't expect such a complex solution, beware copyright notices 😄

@sea212 sea212 added s:accepted This pull request is ready for merge and removed s:review-needed The pull request requires reviews labels Jun 21, 2023
@maltekliemann maltekliemann merged commit 5e953c4 into main Jun 21, 2023
1 check passed
@maltekliemann maltekliemann deleted the mkl-license-checker branch June 21, 2023 10:49
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s:accepted This pull request is ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

License headers should be automatically updated
3 participants