You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.9 KiB

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