formal.yml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. author="$(git show -s --format=%aN $commit)"
  33. if echo $author | grep -q '\S\+\s\+\S\+'; then
  34. success "Author name ($author) seems ok"
  35. else
  36. err "Author name ($author) need to be your real name 'firstname lastname'"
  37. RET=1
  38. fi
  39. subject="$(git show -s --format=%s $commit)"
  40. if echo "$subject" | grep -q -e '^[0-9A-Za-z,+/_\.-]\+: ' -e '^Revert '; then
  41. success "Commit subject line seems ok ($subject)"
  42. else
  43. err "Commit subject line MUST start with '<area>: ' ($subject)"
  44. RET=1
  45. fi
  46. body="$(git show -s --format=%b $commit)"
  47. sob="$(git show -s --format='Signed-off-by: %aN <%aE>' $commit)"
  48. if echo "$body" | grep -qF "$sob"; then
  49. success "Signed-off-by match author"
  50. else
  51. err "Signed-off-by is missing or doesn't match author (should be '$sob')"
  52. RET=1
  53. fi
  54. if echo "$body" | grep -v "Signed-off-by:"; then
  55. success "A commit message exists"
  56. else
  57. err "Missing commit message. Please describe your changes"
  58. RET=1
  59. fi
  60. done
  61. exit $RET