RFR: 7449: Add GitHub action to verify copyright year
Alex Macdonald
aptmac at openjdk.org
Wed Nov 1 02:30:39 UTC 2023
This PR looks to address JMC-7449 [[0]](https://bugs.openjdk.org/browse/JMC-7449), 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](https://github.com/aptmac/jmc/commit/d854e14109d775a8228d729c099463ac8b3a6b8a)) 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
-------------
Commit messages:
- 7449: Add GitHub action to verify copyright year
Changes: https://git.openjdk.org/jmc/pull/530/files
Webrev: https://webrevs.openjdk.org/?repo=jmc&pr=530&range=00
Issue: https://bugs.openjdk.org/browse/JMC-7449
Stats: 39 lines in 2 files changed: 39 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/jmc/pull/530.diff
Fetch: git fetch https://git.openjdk.org/jmc.git pull/530/head:pull/530
PR: https://git.openjdk.org/jmc/pull/530
More information about the jmc-dev
mailing list