Skip to content

Lint

Lint #9925

Workflow file for this run

---
name: "Lint"
on: # yamllint disable-line rule:truthy
push:
branches:
- "!dependabot/*"
- "main"
pull_request:
branches: ["*"]
merge_group:
types:
- "checks_requested"
permissions:
contents: "read"
jobs:
go-license-check:
name: "License Check"
runs-on: "depot-ubuntu-24.04-small"
steps:
- uses: "actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493" # v4.2.2
- uses: "authzed/actions/setup-go@f00cad69713a135d0b55c16bae64171367f319d5" # main
- name: "Check Licenses"
uses: "authzed/actions/go-license-check@11667c9b2e8b3649ad2af4d788e57d18f8e8eaf1" # main
with:
ignore: "buf.build" # Has no license information
go-lint:
name: "Lint Go"
runs-on: "depot-ubuntu-24.04-4"
steps:
- uses: "actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493" # v4.2.2
- uses: "authzed/actions/setup-go@f00cad69713a135d0b55c16bae64171367f319d5" # main
- name: "Lint Go"
run: "go run mage.go lint:go"
- uses: "chainguard-dev/actions/nodiff@3caedd3784c809ba873cbb8c6a12e2bc6bf6ab09" # main
with:
path: ""
fixup-command: "go run mage.go lint:go"
extra-lint:
name: "Lint YAML & Markdown"
runs-on: "depot-ubuntu-24.04-small"
steps:
- uses: "actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493" # v4.2.2
- uses: "authzed/actions/setup-go@f00cad69713a135d0b55c16bae64171367f319d5" # main
- name: "Lint Everything Else"
run: "go run mage.go lint:extra"
- uses: "chainguard-dev/actions/nodiff@3caedd3784c809ba873cbb8c6a12e2bc6bf6ab09" # main
with:
path: ""
fixup-command: "go run mage.go lint:extra"
conventional-commits:
name: "Lint Commit Messages"
runs-on: "depot-ubuntu-24.04-small"
if: "github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.action == 'reopened' || github.event.action == 'edited')"
steps:
- name: "Checkout repository"
uses: "actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493" # v4.2.2
with:
fetch-depth: 0
- name: "Set up Python"
uses: "actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065" # v5.6.0
with:
python-version: "3.11"
- name: "Install commitizen"
run: |
python -m pip install --upgrade pip
pip install commitizen
- name: "Get commit range"
id: "commit-range"
run: |
# Get the base and head commit SHAs
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
echo "base-sha=$BASE_SHA" >> $GITHUB_OUTPUT
echo "head-sha=$HEAD_SHA" >> $GITHUB_OUTPUT
echo "Commit range: $BASE_SHA..$HEAD_SHA"
- name: "Validate commit messages"
run: |
BASE_SHA="${{ steps.commit-range.outputs.base-sha }}"
HEAD_SHA="${{ steps.commit-range.outputs.head-sha }}"
echo "::group::Validating commits from $BASE_SHA to $HEAD_SHA"
# Get list of commits in the PR
git log --format="%H %s" "$BASE_SHA..$HEAD_SHA" > commits.txt
if [ ! -s commits.txt ]; then
echo "::notice::No commits found in range"
exit 0
fi
total_commits=$(wc -l < commits.txt)
echo "Found $total_commits commit(s) to validate"
echo "::endgroup::"
# Validate each commit message
failed=0
while read -r commit_sha commit_msg; do
short_sha=$(echo "$commit_sha" | cut -c1-7)
if cz check -m "$commit_msg" >/dev/null 2>&1; then
echo "✅ $short_sha: $commit_msg"
else
echo "❌ $short_sha: $commit_msg"
failed=1
fi
done < commits.txt
if [ $failed -eq 1 ]; then
echo ""
echo "::group::Conventional Commit Format"
echo "<type>[optional scope]: <description>"
echo ""
echo "Examples:"
echo " feat: add authentication system"
echo " fix(api): resolve timeout issue"
echo " docs: update README"
echo ""
echo "Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert"
echo "::endgroup::"
echo "::error::Some commits don't follow conventional format!"
exit 1
else
echo "::notice::All commits follow conventional format ✅"
fi