Skip to content

chore: enforce commit message format #127

chore: enforce commit message format

chore: enforce commit message format #127

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
commit-messages:
name: Commit Messages
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate commit messages
shell: bash
run: |
set -euo pipefail
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
range="${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}"
else
before="${{ github.event.before }}"
if [[ "$before" == "0000000000000000000000000000000000000000" ]]; then
range="${{ github.sha }}"
else
range="$before..${{ github.sha }}"
fi
fi
commits=$(git rev-list --no-merges "$range")
if [[ -z "$commits" ]]; then
echo "No non-merge commits to validate."
exit 0
fi
tmp=$(mktemp)
trap 'rm -f "$tmp"' EXIT
while IFS= read -r commit; do
[[ -n "$commit" ]] || continue
git show -s --format=%B "$commit" > "$tmp"
echo "check $commit"
scripts/commit-msg.sh "$tmp"
done <<< "$commits"
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Download dependencies
run: go mod download
- name: Build
run: go build -v ./...
- name: Test with coverage
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.out
fail_ci_if_error: false
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest