Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(commit-validation): use git to walk commits #9291

Merged
merged 1 commit into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/commit-validation-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: commit-validation-pr
on: [pull_request]

permissions:
contents: read

jobs:
check-commit-msg-length:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check commit message length
run: |
git log ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | (
longlines=0
while IFS='' read -r line; do
if [ "${#line}" -gt 78 ]; then
echo "Overlong line: ${line}" >&2
longlines=$(( longlines + 1 ))
fi
done
[ "${longlines}" -eq 0 ]
)
5 changes: 2 additions & 3 deletions .github/workflows/commit-validation.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: commit-validation
on: [ push, pull_request ]
on: [ push ]

permissions:
contents: read
Expand All @@ -16,8 +16,7 @@ jobs:
result-encoding: json
script: |
var longlines = 0;
const pr = ${{ toJSON(github.event.pull_request) }};
const commits = (pr && pr.commits) || ${{ toJSON(github.event.commits) }};
const commits = ${{ toJSON(github.event.commits) }};
for (const commit of commits) {
for (const line of commit.message.split('\n')) {
if (line.length > 78) {
Expand Down