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

7449: Add GitHub action to verify copyright year #530

Closed
wants to merge 1 commit into from

Conversation

aptmac
Copy link
Member

@aptmac aptmac commented Nov 1, 2023

This PR looks to address JMC-7449 [0], in which it'd be nice to have a GitHub action that checks the copyright year of changed files (useful for PR reviews).

I've added a check_copyright_year job to the github workflow, that checks out the repository and then runs a bash script. This bash script lives alongside the updatecopyrightyear.sh script and other build-related scripts in /scripts. By using fetch-depth: 0 on the workflow job, we're able to do a git diff against origin/master to get a list of all files that have been altered in a given PR. From there it does a similar file extension check to what updatecopyrightyear.sh does, and then uses sed to get the "latest" copyright years (there can be multiple if the header has multiple company names). It compares those years to the current year, and if there is not a match then it prints out the filename to the console and increases a counter that gets printed out when the script returns 1.

I made a quick test commit (link) that changed a handful of files without updating their headers, the GH workflow can be found here: https://github.com/aptmac/jmc/actions/runs/6712104409/job/18240941002
Example of what the workflow looks like:

Run ./scripts/checkcopyrightyear.sh
Requires update: agent/src/main/java/org/openjdk/jmc/agent/impl/MalformedConverterException.java
Requires update: agent/src/main/java/org/openjdk/jmc/agent/jfr/impl/package-info.java
Requires update: agent/src/main/java/org/openjdk/jmc/agent/jfr/impl/package-info.java
Requires update: application/org.openjdk.jmc.browser/pom.xml
Requires update: application/org.openjdk.jmc.browser/src/main/java/org/openjdk/jmc/browser/JVMBrowserPlugin.java
Requires update: application/org.openjdk.jmc.docs/html/toc.htm
Requires update: application/org.openjdk.jmc.rjmx/build.properties
There is a total of 7 copyright year(s) that require updating.
Error: Process completed with exit code 1.

[0] https://bugs.openjdk.org/browse/JMC-7449


Progress

  • Commit message must refer to an issue
  • Change must be properly reviewed (1 review required, with at least 1 Committer)

Issue

  • JMC-7449: Add GitHub action to verify copyright year (Enhancement - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jmc.git pull/530/head:pull/530
$ git checkout pull/530

Update a local copy of the PR:
$ git checkout pull/530
$ git pull https://git.openjdk.org/jmc.git pull/530/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 530

View PR using the GUI difftool:
$ git pr show -t 530

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jmc/pull/530.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 1, 2023

👋 Welcome back aptmac! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr label Nov 1, 2023
@mlbridge
Copy link

mlbridge bot commented Nov 1, 2023

Webrevs

Copy link
Member

@thegreystone thegreystone left a comment

Choose a reason for hiding this comment

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

An improvement could be to check for having the mandatory copyright header for new files.

@openjdk
Copy link

openjdk bot commented Nov 17, 2023

@aptmac This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

7449: Add GitHub action to verify copyright year

Reviewed-by: hirt, clanger

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 3 new commits pushed to the master branch:

  • d734567: 7192: Event browser should be able to search and show event type ids
  • 2a076d2: 8145: Upgrade Jetty to version 10.0.17
  • 0d0df70: 8129: Add tool to simplify platform upgrades

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Nov 17, 2023
Copy link
Collaborator

@RealCLanger RealCLanger 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 good addition for formal correctness.

@aptmac
Copy link
Member Author

aptmac commented Dec 1, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Dec 1, 2023

Going to push as commit 51e952e.
Since your change was applied there have been 6 commits pushed to the master branch:

  • 8dd7683: 4262: Duplicate headers when copying thread dump text to clipboard
  • fea5d67: 8144: Add rule to detect GC Inverted Parallelism
  • 48162df: 7307: Move org.openjdk.jmc.flightrecorder.configuration bundle from application to core
  • d734567: 7192: Event browser should be able to search and show event type ids
  • 2a076d2: 8145: Upgrade Jetty to version 10.0.17
  • 0d0df70: 8129: Add tool to simplify platform upgrades

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated label Dec 1, 2023
@openjdk openjdk bot closed this Dec 1, 2023
@openjdk openjdk bot removed ready rfr labels Dec 1, 2023
@openjdk
Copy link

openjdk bot commented Dec 1, 2023

@aptmac Pushed as commit 51e952e.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@aptmac aptmac deleted the check-copyright-year branch December 13, 2023 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants