mirror of
https://github.com/taiki-e/install-action.git
synced 2026-04-08 18:05:42 +08:00
Update scripts
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
set -euxo pipefail
|
||||
IFS=$'\n\t'
|
||||
cd "$(dirname "$0")"/..
|
||||
|
||||
1
main.sh
1
main.sh
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
|
||||
1
tools/.tidy-check-license-headers
Normal file
1
tools/.tidy-check-license-headers
Normal file
@@ -0,0 +1 @@
|
||||
git ls-files '*.sh' # TODO: check more files
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
cd "$(dirname "$0")"/..
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
cd "$(dirname "$0")"/..
|
||||
|
||||
@@ -201,6 +201,44 @@ else
|
||||
warn "'shellcheck' is not installed"
|
||||
fi
|
||||
|
||||
# License check
|
||||
# TODO: This check is still experimental and does not track all files that should be tracked.
|
||||
if [[ -f tools/.tidy-check-license-headers ]]; then
|
||||
info "checking license headers (experimental)"
|
||||
failed_files=''
|
||||
for p in $(eval $(<tools/.tidy-check-license-headers)); do
|
||||
# TODO: More file types?
|
||||
case "$(basename "${p}")" in
|
||||
*.sh) prefix=("# ") ;;
|
||||
*.rs | *.c | *.h | *.cpp | *.hpp | *.s | *.S) prefix=("// " "/* ") ;;
|
||||
*.ld | *.x) prefix=("/* ") ;;
|
||||
*) error "unrecognized file type: ${p}" ;;
|
||||
esac
|
||||
# TODO: The exact line number is not actually important; it is important
|
||||
# that it be part of the top-level comments of the file.
|
||||
line="1"
|
||||
case "${p}" in
|
||||
*.sh) line="2" ;; # shebang
|
||||
esac
|
||||
header_found=''
|
||||
for pre in "${prefix[@]}"; do
|
||||
if [[ "$(grep -E -n "${pre}SPDX-License-Identifier: " "${p}")" == "${line}:${pre}SPDX-License-Identifier: "* ]]; then
|
||||
header_found='1'
|
||||
continue
|
||||
fi
|
||||
done
|
||||
if [[ -z "${header_found}" ]]; then
|
||||
failed_files+="${p}:${line}"$'\n'
|
||||
fi
|
||||
done
|
||||
if [[ -n "${failed_files}" ]]; then
|
||||
error "license-check failed: please add SPDX-License-Identifier to the following files"
|
||||
echo "======================================="
|
||||
echo -n "${failed_files}"
|
||||
echo "======================================="
|
||||
fi
|
||||
fi
|
||||
|
||||
# Spell check (if config exists)
|
||||
if [[ -f .cspell.json ]]; then
|
||||
info "spell checking"
|
||||
|
||||
Reference in New Issue
Block a user