forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 1
147 lines (129 loc) · 4.29 KB
/
checkpatch.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: "CheckPatch"
on:
push:
branches-ignore:
- 'archived/**' # previous branches
- 't/**' # TopGit tree
- 'net' # part of the TopGit tree
- 'net-next' # part of the TopGit tree
- 'for-review' # part of the TopGit tree
- 'for-review-net' # part of the TopGit tree
tags:
- 'patchew/**' # patchew is using tags
env:
CURL_OPT: "--no-progress-meter --connect-timeout 30 --retry 20 --retry-delay 10"
PW: "https://patchwork.kernel.org/api/1.2"
RESULTS: "./checkpatch-results.txt"
DETAILS: "./checkpatch-details.txt"
permissions: {}
jobs:
checkpatch:
name: "Checkpatch"
# for others or for the official repo but only commits from patchew
if: github.repository_owner != 'multipath-tcp' || startswith(github.ref, 'refs/tags/patchew/')
runs-on: ubuntu-latest
permissions:
contents: read # to fetch code (actions/checkout)
steps:
- name: "Checkout"
uses: actions/checkout@v3
with:
fetch-depth: 0 ## to make sure a mentioned commit exists
- name: "Checkpatch"
uses: multipath-tcp/mptcp-upstream-validate-export-action@main
with:
each_commit: true
checkpatch: true
debug: ${{ secrets.BUILD_ACTION_DEBUG }}
- name: "Artifacts"
uses: actions/upload-artifact@v3
with:
name: results
path: ${{ env.RESULTS }}
- name: "Artifacts"
uses: actions/upload-artifact@v3
with:
name: details
path: ${{ env.DETAILS }}
notif:
name: "Notifications"
needs: checkpatch
# only for the official repo (patchew)
if: github.repository_owner == 'multipath-tcp' && startswith(github.ref, 'refs/tags/patchew/')
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: results
- name: "Patchwork"
run: |
# $1: mid, $2: status, $3: desc
_send() { local check_url
check_url="$(curl "${URL_PW}${1}" | jq -r 'last(.[].checks)')"
if [ -z "${check_url}" ] || [ "${check_url}" = "null" ]; then
echo "URL not found: '${check_url}' '${URL_PW}${1}'"
return 1
fi
curl ${CURL_OPT} \
-X POST \
-H "Authorization: Token ${{ secrets.PW_TOKEN }}" \
-F "state=${2}" \
-F "target_url=${URL_GH}" \
-F "context=checkpatch" \
-F "description=${3}" \
"${check_url}" | jq '.'
}
FIRST=1
send() { local i
# patches can take a bit of time to appear: retry the first time
if [ "${FIRST}" = "1" ]; then
FIRST=0
for i in $(seq 45); do
if _send "${@}"; then
echo "Successful sent after ${i} attempts"
return 0
fi
sleep 1m
done
curl "${URL_PW}${1}"
return 1
else
_send "${@}"
fi
}
if [ ! -s "${RESULTS}" ]; then
echo "Strange, no results, please check why"
exit 1
fi
while read -r mid status desc; do
echo "Sending: '${mid}' '${status}' '${desc}'"
send "${mid}" "${status}" "${desc}"
done < "${RESULTS}"
env:
URL_GH: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
URL_PW: "${{ env.PW }}/patches/?project=mptcp&msgid="
status:
name: "Status"
needs: checkpatch
# for others, to report an error if patches were not OK
if: github.repository_owner != 'multipath-tcp'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: results
- name: "Set exit status"
run: |
if [ ! -s "${RESULTS}" ]; then
echo "Strange, no results, please check why"
exit 1
fi
if awk '{ if ($2 != "success") exit 1 }' "${RESULTS}"; then
echo "Everything OK with Checkpatch, good job!"
exit 0
fi
echo "Checkpatch detected some issues:"
echo
cat "${RESULTS}"
echo
exit 1