Add workflows verifying bash and commit messages
Some checks failed
Check Commit Messages / check-commit-message (pull_request) Failing after 16s
Some checks failed
Check Commit Messages / check-commit-message (pull_request) Failing after 16s
This PR adds the first two workflows: 1. Bash linter 2. Commit message verification
This commit is contained in:
parent
f0fd008e1d
commit
ba9b69350e
70
.forgejo/workflows/check-commit-message.yml
Normal file
70
.forgejo/workflows/check-commit-message.yml
Normal file
|
@ -0,0 +1,70 @@
|
|||
name: Check Commit Messages
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- '!master'
|
||||
|
||||
jobs:
|
||||
check-commit-message:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: node:16-bullseye
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # Fetch the entire history to analyze commit messages
|
||||
|
||||
- name: Check Subject Beginning
|
||||
run: |
|
||||
echo "Checking if the subject starts correctly..."
|
||||
commit_message=$(git log -1 --pretty=%B)
|
||||
if ! echo "$commit_message" | grep -Eq "^([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."
|
||||
exit 1
|
||||
fi
|
||||
echo "Subject start check passed."
|
||||
|
||||
- name: Check Commit Message Type and Format
|
||||
run: |
|
||||
echo "Checking commit message type and format..."
|
||||
commit_message=$(git log -1 --pretty=%B)
|
||||
if ! echo "$commit_message" | grep -Eq "^(feat|fix|chore|docs|style|refactor|test|perf):"; then
|
||||
echo "Error: Commit message does not follow the required format: <type>: <subject>"
|
||||
exit 1
|
||||
fi
|
||||
echo "Commit message type and format check passed."
|
||||
|
||||
- name: Check Subject Length
|
||||
run: |
|
||||
echo "Checking subject length..."
|
||||
commit_subject=$(git log -1 --pretty=%B | head -n 1)
|
||||
if [ ${#commit_subject} -gt 72 ]; then
|
||||
echo "Error: Commit message subject exceeds 72 characters."
|
||||
exit 1
|
||||
fi
|
||||
echo "Subject length check passed."
|
||||
|
||||
- name: Check Subject Ending
|
||||
run: |
|
||||
echo "Checking subject ending..."
|
||||
commit_subject=$(git log -1 --pretty=%B | head -n 1)
|
||||
if echo "$commit_subject" | grep -q "\.$"; then
|
||||
echo "Error: Commit message subject should not end with a dot."
|
||||
exit 1
|
||||
fi
|
||||
echo "Subject ending check passed."
|
||||
|
||||
- name: Check Empty Line After Title
|
||||
run: |
|
||||
echo "Checking for an empty line after the title..."
|
||||
commit_body=$(git log -1 --pretty=%B | tail -n +2)
|
||||
if [ -n "$commit_body" ] && ! echo "$commit_body" | grep -q "^$"; then
|
||||
echo "Error: There must be an empty line between the title and description."
|
||||
exit 1
|
||||
fi
|
||||
echo "Empty line check passed."
|
||||
|
31
.forgejo/workflows/lint-bash.yml
Normal file
31
.forgejo/workflows/lint-bash.yml
Normal file
|
@ -0,0 +1,31 @@
|
|||
name: Lint Bash Scripts
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**/*.sh'
|
||||
pull_request:
|
||||
paths:
|
||||
- '**/*.sh'
|
||||
|
||||
jobs:
|
||||
lint-bash:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: node:16-bullseye
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: https://code.forgejo.org/actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # Fetch the entire history to avoid REST API reliance
|
||||
|
||||
- name: Install ShellCheck
|
||||
run: |
|
||||
apt-get update && apt-get install -y shellcheck
|
||||
|
||||
- name: Lint Bash Scripts
|
||||
run: |
|
||||
echo "Linting Bash scripts..."
|
||||
find . -name '*.sh' -print0 | xargs -0 shellcheck
|
||||
|
Loading…
Reference in a new issue