-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically check for SPDX headers and linting (#40)
- Loading branch information
1 parent
05226a4
commit ca8031b
Showing
16 changed files
with
134 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
--style=google | ||
--indent=spaces | ||
--indent-preproc-define | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Last matching pattern has precedence | ||
|
||
# Default owner | ||
* @pq-code-package/pqcp-embedded-maintainers-aarch64 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
|
||
# Contributing | ||
|
||
to be completed | ||
to be completed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
|
||
# Governance | ||
|
||
to be documented | ||
to be documented |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
CC ?= /usr/bin/cc | ||
INCLUDE_FIPS202 = -I fips202 | ||
INCLUDE_MLKEM = -I mlkem | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
|
||
# Support | ||
|
||
To be written. | ||
To be written. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env bash | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -o errexit | ||
set -o errtrace | ||
set -o nounset | ||
set -o pipefail | ||
|
||
# consts | ||
ROOT="$(realpath "$(dirname "$0")"/../../)" | ||
|
||
checkerr() | ||
{ | ||
if [[ $? == 127 ]]; then | ||
SUCCESS=false | ||
return | ||
fi | ||
|
||
if [[ ${#1} != 0 ]]; then | ||
echo "$1" | while read -r file line; do | ||
echo "::error file=$file,line=${line:-1},title=Format error::$file require to be formatted" | ||
done | ||
SUCCESS=false | ||
fi | ||
} | ||
|
||
# Formatting | ||
SUCCESS=true | ||
|
||
echo "::group::Linting nix files with nixpkgs-fmt" | ||
checkerr "$(nixpkgs-fmt --check "$ROOT")" | ||
echo "::endgroup::" | ||
|
||
echo "::group::Linting shell scripts with shfmt" | ||
checkerr "$(shfmt -s -l -i 2 -ci -fn $(shfmt -f $(git grep -l '' :/)))" | ||
echo "::endgroup::" | ||
|
||
echo "::group::Linting c files with astyle" | ||
checkerr "$(astyle $(git ls-files ":/*.c" ":/*.h") --options="$ROOT/.astylerc" --dry-run --formatted | awk '{print $2}')" | ||
echo "::endgroup::" | ||
|
||
check-eol-dry-run() | ||
{ | ||
for file in $(git ls-files -- ":/"); do | ||
if [[ $(tail -c1 "$file" | wc -l) == 0 ]]; then | ||
l=$(wc -l <"$file") | ||
echo "$file $l" | ||
fi | ||
done | ||
} | ||
echo "::group::Checking eol" | ||
checkerr "$(check-eol-dry-run)" | ||
echo "::endgroup::" | ||
|
||
check-spdx() | ||
{ | ||
for file in $(git ls-files -- ":/" ":/!:*LICENSE*" ":/!:.git*" ":/!:flake.lock"); do | ||
if [[ $(grep "SPDX-License-Identifier:" $file | wc -l) == 0 ]]; then | ||
echo "$file is missing SPDX License header" | ||
SUCCESS=false | ||
fi | ||
done | ||
} | ||
echo "::group::Checking SPDX headers" | ||
check-spdx | ||
echo "::endgroup::" | ||
|
||
# | ||
if ! $SUCCESS; then | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -o errexit | ||
set -o errtrace | ||
set -o nounset | ||
set -o pipefail | ||
|
||
# consts | ||
ROOT="$(realpath "$(dirname "$0")"/../)" | ||
|
||
GREEN="$(tput setaf 2)" | ||
NORMAL="$(tput sgr0)" | ||
|
||
# utility | ||
info() | ||
{ | ||
printf "%s %b\n" "${GREEN}info" "${NORMAL}${*}" | ||
} | ||
|
||
info "Formatting nix files" | ||
nixpkgs-fmt "$ROOT" | ||
|
||
info "Formatting shell scripts" | ||
shfmt -s -w -l -i 2 -ci -fn $(shfmt -f $(git grep -l '' :/)) | ||
|
||
info "Formatting c files" | ||
astyle $(git ls-files ":/*.c" ":/*.h") --options="$ROOT/.astylerc" --formatted | awk '{print $2}' | ||
|
||
info "Checking for eol" | ||
check-eol() | ||
{ | ||
for file in $(git ls-files -- ":/"); do | ||
if [[ $(tail -c1 "$file" | wc -l) == 0 ]]; then | ||
echo "" >>"$file" | ||
echo "$file" | ||
fi | ||
done | ||
} | ||
check-eol |