formal.yml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. name: Test Formalities
  2. on:
  3. pull_request:
  4. permissions:
  5. contents: read
  6. jobs:
  7. build:
  8. name: Test Formalities
  9. runs-on: ubuntu-latest
  10. strategy:
  11. fail-fast: false
  12. steps:
  13. - uses: actions/checkout@v3
  14. with:
  15. ref: ${{ github.event.pull_request.head.sha }}
  16. fetch-depth: 0
  17. - name: Determine branch name
  18. run: |
  19. BRANCH="${GITHUB_BASE_REF#refs/heads/}"
  20. echo "Building for $BRANCH"
  21. echo "BRANCH=$BRANCH" >> $GITHUB_ENV
  22. - name: Test formalities
  23. run: |
  24. source .github/workflows/scripts/ci_helpers.sh
  25. RET=0
  26. for commit in $(git rev-list HEAD ^origin/$BRANCH); do
  27. info "=== Checking commit '$commit'"
  28. if git show --format='%P' -s $commit | grep -qF ' '; then
  29. err "Pull request should not include merge commits"
  30. RET=1
  31. fi
  32. subject="$(git show -s --format=%s $commit)"
  33. if echo "$subject" | grep -q -e '^[0-9A-Za-z,+/_\.-]\+: ' -e '^Revert '; then
  34. success "Commit subject line seems ok ($subject)"
  35. else
  36. err "Commit subject line MUST start with '<area>: ' ($subject)"
  37. RET=1
  38. fi
  39. body="$(git show -s --format=%b $commit)"
  40. sob="$(git show -s --format='Signed-off-by: %aN <%aE>' $commit)"
  41. if echo "$body" | grep -qF "$sob"; then
  42. success "Signed-off-by match author"
  43. else
  44. err "Signed-off-by is missing or doesn't match author (should be '$sob')"
  45. RET=1
  46. fi
  47. if echo "$body" | grep -v "Signed-off-by:"; then
  48. success "A commit message exists"
  49. else
  50. err "Missing commit message. Please describe your changes"
  51. RET=1
  52. fi
  53. done
  54. exit $RET