Skip to content

Commit

Permalink
ci(commitlint): check for the presence of concrete PR number
Browse files Browse the repository at this point in the history
Enrich commitlint checker in order to check the precise PR number in the
commit log headline.
  • Loading branch information
tiborsimko committed Jan 26, 2024
1 parent 48302cf commit 62ddc94
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Check commit message compliance of the pull request
if: github.event_name == 'pull_request'
run: |
./run-tests.sh --check-commitlint ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} ${{ github.event.pull_request.head.sha }}
./run-tests.sh --check-commitlint ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} ${{ github.event.pull_request.head.sha }} ${{ github.event.pull_request.number }}
lint-shellcheck:
runs-on: ubuntu-20.04
Expand Down
5 changes: 3 additions & 2 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ set -o nounset
check_commitlint () {
from=${2:-master}
to=${3:-HEAD}
pr=${4:-[0-9]+}
npx commitlint --from="$from" --to="$to"
found=0
while IFS= read -r line; do
if echo "$line" | grep -qP "\(\#[0-9]+\)$"; then
if echo "$line" | grep -qP "\(\#$pr\)$"; then
true
else
echo "PR number missing in $line"
echo "Headline does not end by '(#$pr)' PR number: $line"
found=1
fi
done < <(git log "$from..$to" --format="%s")
Expand Down

0 comments on commit 62ddc94

Please sign in to comment.