Skip to content

Commit

Permalink
lint GitHub PR title
Browse files Browse the repository at this point in the history
  • Loading branch information
mrekucci committed Aug 7, 2024
1 parent b0ab7d6 commit 7c2574f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 71 deletions.
37 changes: 0 additions & 37 deletions .commitlintrc.yml

This file was deleted.

41 changes: 7 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,21 @@ concurrency:
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
commitlint:
name: Check Commit Message
pr:
name: Lint PR Title
runs-on: ubuntu-24.04
timeout-minutes: 30
timeout-minutes: 1

steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Required Dependencies
run: |
sudo apt-get update
sudo apt-get install -y git curl
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs
npm install conventional-changelog-conventionalcommits
npm install --save-dev @commitlint/config-conventional
npm install commitlint@latest
- name: Print Versions
run: |
git --version
node --version
npm --version
npx commitlint --version
- name: Validate Current (Last) Commit Message
if: github.event_name == 'push'
run: npx commitlint --last --verbose

- name: Validate PR Commit Messages
if: github.event_name == 'pull_request'
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
uses: ./.github/workflows/pr.yml
secrets: inherit

go-modules:
name: Test and Build Go Modules
runs-on: ubuntu-24.04
timeout-minutes: 60
needs:
-

steps:
- name: Checkout Code
Expand Down Expand Up @@ -245,7 +219,6 @@ jobs:
uses: ./.github/workflows/infrastructure.yml
secrets: inherit
needs:
- commitlint
- go-modules
- foundry
- contracts
37 changes: 37 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: pr

on:
pull_request:
types:
- opened
- edited
- synchronize
branches:
- main

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
lint:
name: Lint
runs-on: ubuntu-24.04
timeout-minutes: 1

steps:
- name: Lint PR Title
run: |
regex="^(fix|feat|refactor|revert|test|perf|style|chore|docs): [a-z][^.\n]{0,70}$"
if [[ "${PR_TITLE}" =~ $regex ]]; then
echo -e "PR title is valid: ${PR_TITLE}"
else
echo -e "Invalid PR title: ${PR_TITLE}"
echo -e "PR title must match the following pattern: ${regex}"
exit 1
fi
env:
PR_TITLE: ${{ github.event.pull_request.title }}

0 comments on commit 7c2574f

Please sign in to comment.