Skip to content

Commit

Permalink
Add copyright header check to CI. (#463)
Browse files Browse the repository at this point in the history
* Add copyright header check to CI.

* Debug CI failure.

* Add explicit ripgrep search path.

* Remove CI debug code.

* Add invalid shader license.

* Add invalid license capitalization.

* Remove all CI testing changes.

* Add more robust multi-author support.

* Escape the dot in the copyright regex.
  • Loading branch information
xStrom authored Feb 26, 2024
1 parent ac6d632 commit 7ef9226
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
37 changes: 37 additions & 0 deletions .github/copyright.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/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 Vello Authors( and .+)?$\n^// SPDX-License-Identifier: Apache-2\.0 OR MIT$\n\n" --files-without-match --multiline -g "*.rs" -g "!{shader,src/cpu_shader}" .)

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 Vello Authors"
echo "// SPDX-License-Identifier: Apache-2.0 OR MIT"
echo -e "\n... rest of the file ...\n"
exit 1
fi

# Check all the shaders, both WGSL and CPU shaders in Rust, as they also have Unlicense
output=$(rg "^// Copyright (19|20)[\d]{2} (.+ and )?the Vello Authors( and .+)?$\n^// SPDX-License-Identifier: Apache-2\.0 OR MIT OR Unlicense$\n\n" --files-without-match --multiline -g "{shader,src/cpu_shader}/**/*.{rs,wgsl}" .)

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

echo "All files have correct copyright headers."
exit 0

8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ jobs:
- name: cargo fmt
run: cargo fmt --all --check

- name: install ripgrep
run: |
sudo apt update
sudo apt install ripgrep
- name: check copyright headers
run: bash .github/copyright.sh

test-stable:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
2 changes: 1 addition & 1 deletion shader/shared/clip.wgsl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2022 the Vello Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense

struct Bic {
a: u32,
b: u32,
Expand Down

0 comments on commit 7ef9226

Please sign in to comment.