Skip to content

Commit

Permalink
Add copyright header check to CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
xStrom committed Mar 1, 2024
1 parent d515bb9 commit 14b9e6f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
23 changes: 23 additions & 0 deletions .github/copyright.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# If there are new files with headers that can't match the conditions here,
# then the files can be ignored by an additional glob argument via the -g flag.
# For example:
# -g "!src/special_file.rs"
# -g "!src/special_directory"

# Check all the standard Rust source files
output=$(rg "^// Copyright (19|20)[\d]{2} (.+ and )?the Druid Authors( and .+)?$\n^// SPDX-License-Identifier: Apache-2\.0 OR MIT$\n\n" --files-without-match --multiline -g "*.rs" .)

if [ -n "$output" ]; then
echo -e "The following files lack the correct copyright header:\n"
echo $output
echo -e "\n\nPlease add the following header:\n"
echo "// Copyright $(date +%Y) the Druid Authors"
echo "// SPDX-License-Identifier: Apache-2.0 OR MIT"
echo -e "\n... rest of the file ...\n"
exit 1
fi

echo "All files have correct copyright headers."
exit 0
5 changes: 4 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ jobs:
- name: Install deps
run: |
sudo apt-get update
sudo apt-get install libgtk-3-dev
sudo apt-get install libgtk-3-dev ripgrep
- name: Check copyright headers
run: bash .github/copyright.sh

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
Expand Down

0 comments on commit 14b9e6f

Please sign in to comment.