Skip to content

Restore copyright check - #975

Merged
adpaco merged 4 commits into
model-checking:mainfrom
adpaco:fix-copy
Mar 23, 2022
Merged

adpaco merged 4 commits into
model-checking:mainfrom
adpaco:fix-copy

Conversation

@adpaco

@adpaco adpaco commented Mar 23, 2022 •

Copy link
Copy Markdown
Contributor

Description of changes:

The copyright check has been broken for some time. This PR restores the check by making it work with shallow clones (the reason it broke) and extends the check itself to detect "modified" copyright headers.

Resolved issues:

Resolves #961

Call-outs:

Testing:

  • How is this change tested? Running in CI.

  • Is this a refactor change? No.

Checklist

  • Each commit message has a non-empty body, explaining why the change was made
  • Methods or procedures are documented
  • Regression or unit tests are included, or existing tests cover the modified code
  • My PR is restricted to a single feature or bugfix

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@adpaco
adpaco requested a review from a team as a code owner March 23, 2022 13:28
@@ -0,0 +1,19 @@
.clang-format
.diff
.md

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.

@adpaco adpaco Mar 23, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We can consider it as an enhancement, either by switching to other tools to retrieve the list of files (git ls-files exlcude options only work with "ignored" or "other" files) or doing that ourselves. But I think it is out of scope for this PR.

Note that this is just a file for the (extended) patterns we had in our workflow: https://github.com/model-checking/kani/blob/main/.github/workflows/format-check.yml#L16

@celinval celinval 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.

It looks good to me. Thanks for jumping on this one.

One improvement we should do later is to detect if the file has a previous copyright statement. I think this would fail today, but it should be OK to have an original copyright statement followed by our modified copyright statement.

Comment thread scripts/ci/copyright_check.py Outdated
print('FAIL')

# Convert checks into boolean values to determine the exit code
bool_checks = map(result_into_bool, checks)

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.

nit: Can you just add a variable to the for loop that gets assigned to false if we ever hit the FAIL branch?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, thanks!

@adpaco

adpaco commented Mar 23, 2022

Copy link
Copy Markdown
Contributor Author

It looks good to me. Thanks for jumping on this one.

One improvement we should do later is to detect if the file has a previous copyright statement. I think this would fail today, but it should be OK to have an original copyright statement followed by our modified copyright statement.

Yes, because it expects the headers to be in an (almost) fixed set of lines in the file. But I agree, there are lots of room for improvement here (e.g., using a sliding window to detect headers instead).

@adpaco
adpaco merged commit a3da924 into model-checking:main Mar 23, 2022
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 26, 2022
* Add script for copyright check and extend for modified headers

* Simplify copyright step in workflow

* Add copyright header to files that were missing it

* Use variable to determine exit code
tedinski pushed a commit that referenced this pull request Apr 27, 2022
* Add script for copyright check and extend for modified headers

* Simplify copyright step in workflow

* Add copyright header to files that were missing it

* Use variable to determine exit code
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.

Copyright check is not working

3 participants