Compare commits

..

1 commit

Author SHA1 Message Date
ZoopaMario c60d0eeb83 Add workflows verifying bash and commit messages
Some checks failed
Check Commit Messages / check-commit-message (pull_request) Failing after 45s
This PR adds the first two workflows:
1. Bash linter
2. Commit message verification
2024-12-29 04:49:17 +01:00

View file

@ -22,7 +22,7 @@ jobs:
run: | run: |
echo "Checking if the subject starts correctly..." echo "Checking if the subject starts correctly..."
commit_message=$(git log -1 --pretty=%B) commit_message=$(git log -1 --pretty=%B)
if ! echo "$commit_message" | grep -Eq "^([A-Z]|\S+:|git subrepo (clone|pull))"; then if ! [[ "$commit_message" =~ ^([A-Z]|\S+:|git\ subrepo\ (clone|pull)) ]]; then
echo "Error: The subject does not start with a capital letter, a tag, or a valid 'git subrepo' command." echo "Error: The subject does not start with a capital letter, a tag, or a valid 'git subrepo' command."
exit 1 exit 1
fi fi
@ -32,7 +32,7 @@ jobs:
run: | run: |
echo "Checking commit message type and format..." echo "Checking commit message type and format..."
commit_message=$(git log -1 --pretty=%B) commit_message=$(git log -1 --pretty=%B)
if ! echo "$commit_message" | grep -Eq "^(feat|fix|chore|docs|style|refactor|test|perf):"; then if ! [[ "$commit_message" =~ ^(feat|fix|chore|docs|style|refactor|test|perf): ]]; then
echo "Error: Commit message does not follow the required format: <type>: <subject>" echo "Error: Commit message does not follow the required format: <type>: <subject>"
exit 1 exit 1
fi fi
@ -42,7 +42,7 @@ jobs:
run: | run: |
echo "Checking subject length..." echo "Checking subject length..."
commit_subject=$(git log -1 --pretty=%B | head -n 1) commit_subject=$(git log -1 --pretty=%B | head -n 1)
if [ ${#commit_subject} -gt 72 ]; then if [[ ${#commit_subject} -gt 72 ]]; then
echo "Error: Commit message subject exceeds 72 characters." echo "Error: Commit message subject exceeds 72 characters."
exit 1 exit 1
fi fi
@ -52,7 +52,7 @@ jobs:
run: | run: |
echo "Checking subject ending..." echo "Checking subject ending..."
commit_subject=$(git log -1 --pretty=%B | head -n 1) commit_subject=$(git log -1 --pretty=%B | head -n 1)
if echo "$commit_subject" | grep -q "\.$"; then if [[ "$commit_subject" =~ \.$ ]]; then
echo "Error: Commit message subject should not end with a dot." echo "Error: Commit message subject should not end with a dot."
exit 1 exit 1
fi fi
@ -62,7 +62,7 @@ jobs:
run: | run: |
echo "Checking for an empty line after the title..." echo "Checking for an empty line after the title..."
commit_body=$(git log -1 --pretty=%B | tail -n +2) commit_body=$(git log -1 --pretty=%B | tail -n +2)
if [ -n "$commit_body" ] && ! echo "$commit_body" | grep -q "^$"; then if [[ -n "$commit_body" && ! "$commit_body" =~ ^$ ]]; then
echo "Error: There must be an empty line between the title and description." echo "Error: There must be an empty line between the title and description."
exit 1 exit 1
fi fi