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