Open AtkinsSJ opened 7 months ago
I would suggest something like that
name: Check Copyright Notices
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
check-copyright:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check Copyright Notices
run: |
# Exclude files and directories that we shouldn't be checked
exclude_patterns=(
"<place_it_here>"
"<place_it_here>"
)
# We Loop through all files in the repository except excluded patterns.
for file in $(find . -type f | grep -vE "$(IFS='|'; echo "${exclude_patterns[*]}")"); do
# Look for css and js files
if [[ $file == *.js || $file == *.css ]]; then
# Check if the file contains the copyright notice wrapped in /* */
if ! grep -qE '/\*.*Copyright \(C\) 2024 Puter Technologies Inc\..*\*/' "$file"; then
echo "Copyright notice missing in $file"
exit 1
fi
else
# Check if the file contains the exact copyright notice from license_header.txt (for non-js/non-css files)
if ! grep -qF "$(cat puter/doc/license_header.txt)" "$file"; then
echo "Copyright notice missing in $file"
exit 1
fi
fi
done
echo "Copyright notices check passed!"
Any solution to this should use our license header tool (tools/license-headers
), which is more capable than any license checker/updater we've been able to find elsewhere but needs to be documented.
Make sure that files we've created contain the copyright notice in a comment at the top. This often gets forgotten with new code.
Challenges:
/* */
comments around the license, so it's not an exact match to thelicense_header.txt
file.