Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions .github/workflows/code-validator.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# Workflow to validify the consistency of the codes
# Validate the consistency of the codes.
#
# It checks:
#
# 1. PSL_strings.h is up-to-date
# 2. gmt_enum_dict.h is up-to-date
# 3. Module purposes are up-to-date
# 4. GMT_VERSION_YEAR matches the current year
# 5. Bash scripts have executable permissions
# 6. Bash scripts have correct shebang (#!/usr/bin/env bash)

on:
push:
Expand Down Expand Up @@ -56,25 +65,21 @@ jobs:

- name: Check execute permission of bash scripts
run: |
error=0
echo "Following bash scripts may not have execute permission:"
# exclude share/tools/gmt_functions.sh
for file in $(find . -name "*.sh" ! -path "./share/tools/gmt_functions.sh"); do
if [[ ! -x "$file" ]]; then
((++error))
echo "$error: $file"
fi
done
exit $error
scripts=$(find . -name "*.sh" ! -path "./share/tools/gmt_functions.sh" ! -executable)
if [[ -n "$scripts" ]]; then
echo "Following bash scripts do not have execute permission:"
echo "$scripts"
exit 1
fi

- name: Check shebang of bash scripts
run: |
error=0
echo "Following bash scripts don't start with the shebang '#!/usr/bin/env bash'"
echo "Checking shebang in bash scripts..."
for file in $(find . -name "*.sh" ! -path "./share/tools/gmt_functions.sh" ! -path "./test/invalidate_modules.sh"); do
if [[ "$(head -n1 $file)" != "#!/usr/bin/env bash" ]]; then
if [[ "$(head -n1 "$file")" != '#!/usr/bin/env bash' ]]; then
((++error))
echo "$error: $file"
echo "$file: incorrect shebang '$(head -n1 "$file")'"
fi
done
exit $error
if [[ $error -gt 0 ]]; then echo "Found $error files with incorrect shebang"; exit 1; fi