Add `copyright` job for ensuring source files have licence headers
This job scans all the source files in a project, attempting to ensure they each have a header identifying the licence terms under which the file may be distributed. The job prints a list of the files that fail its check to the job log, and exits with failure status if the list is non-empty.
There is no standard format for licence headers, however one thing they do have in common is that they all feature a copyright notice. Upon scanning all the source files hosted by ROOL, very few files failed this test, and those that did either genuinely lacked licence terms, or had unusual ones where the author had waived copyright and placed the code into the public domain.
A few files used hard spaces around the word "Copyright" so the test uses
grep -w
which considers hard spaces to constitute a word boundary.
Although not (yet?) in use by any of our sources, the ISO SPDX standard
advocates using SPDX-FileCopyrightText
in source files in place of a
copyright declaration. Therefore, this patch pre-emptively permits this as
an alternative.
To cater for waived-copyright cases, a .gitlab-ci.yml
file can define
COPYRIGHT_WHITELIST
to specify files for which this test should be skipped.
This follows the same file naming pattern as WHITESPACE_WHITELIST
.