RFR: 7449: Add GitHub action to verify copyright year

Christoph Langer clanger at openjdk.org
Wed Nov 29 22:10:20 UTC 2023


On Wed, 1 Nov 2023 02:24:20 GMT, Alex Macdonald <aptmac at openjdk.org> wrote:

> 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

This is a good addition for formal correctness.

-------------

Marked as reviewed by clanger (Committer).

PR Review: https://git.openjdk.org/jmc/pull/530#pullrequestreview-1756300037


More information about the jmc-dev mailing list