forked from markmc/openstack-gitdm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
do-it.sh
executable file
·266 lines (226 loc) · 10.7 KB
/
do-it.sh
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#!/bin/bash
# provide debugging output when desired
function DEBUG() {
[ "$_DEBUG" == "on" ] && echo "DEBUG: $1"
}
# enable/disable debugging output
_DEBUG="on"
GITBASE=~/git/openstack
RELEASE=grizzly
BASEDIR=$(pwd)
CONFIGDIR=$(pwd)/openstack-config
TEMPDIR=${TEMPDIR:-$(mktemp -d $(pwd)/dmtmp-XXXXXX)}
GITLOGARGS="--no-merges --numstat -M --find-copies-harder"
UPDATE_GIT=${UPDATE_GIT:-y}
GIT_STATS=${GIT_STATS:-y}
LP_STATS=${LP_STATS:-y}
QUERY_LP=${QUERY_LP:-y}
GERRIT_STATS=${GERRIT_STATS:-y}
REMOVE_TEMPDIR=${REMOVE_TEMPDIR:-y}
if [ ! -d .venv ]; then
echo "Creating a virtualenv"
./tools/install_venv.sh
fi
# current list of CI / infrastructure projects - everything else will be considered "core"
# see https://wiki.openstack.org/wiki/Projects for an authoritative list
CI_PROJECTS='config|zuul|jenkins|jeepyb|devstack|git|gerrit|meetbot|openstack|nose|tempest'
# generate a list of the CORE projects...
CORE_PROJECTS=`grep -v '^#' ${CONFIGDIR}/${RELEASE} | grep -Ev "^(${CI_PROJECTS})" |
while read project x; do
echo ${project}
done`
DEBUG "Got CORE_PROJECTS = '${CORE_PROJECTS}'"
# generate a list of the INFRASTRUCTURE projects...
INFRA_PROJECTS=`grep -v '^#' ${CONFIGDIR}/${RELEASE} | grep -E "^(${CI_PROJECTS})" |
while read project x; do
echo ${project}
done`
DEBUG "Got INFRA_PROJECTS = '${INFRA_PROJECTS}'"
if [ "$UPDATE_GIT" = "y" ]; then
echo "Updating projects from git"
grep -v '^#' ${CONFIGDIR}/${RELEASE} |
while read project x; do
DEBUG "Updating ${project}"
cd ${GITBASE}/${project}
echo -n "${project}: "
# gerrit is currently using upstream version 2.4.2, so only look at that branch
if [ "$project" = "gerrit" ] ; then
git checkout openstack/2.4.2
else
git fetch origin 2>/dev/null
fi
done
fi
if [ "$GIT_STATS" = "y" ] ; then
echo "Generating git commit logs"
grep -v '^#' ${CONFIGDIR}/${RELEASE} |
while read project revisions excludes x; do
DEBUG "Generating git commit log for ${project}"
cd ${GITBASE}/${project}
git log ${GITLOGARGS} ${revisions} > "${TEMPDIR}/${project}-commits.log"
# kludge to exclude large sets of commits:
# If a file called ${project}.exclude exists in the config dir, then treat
# its contents as a list of commits to exclude from the statistics.
# This is done for projects whose commit logs include a lot of automated commits
# (such as all of the Jenkins commits to nova) that need to be excluded, and which
# otherwise would overwhelm the 'awk' command
if [ -r ${CONFIGDIR}/${project}.exclude ]; then
DEBUG "Excluding large set of commits for ${project}..."
for A in `cat ${CONFIGDIR}/${project}.exclude`; do
DEBUG "Excluding $A"
awk "/^commit /{ok=1} /^commit ${A}/{ok=0} {if(ok) {print}}" \
< "${TEMPDIR}/${project}-commits.log" > "${TEMPDIR}/${project}-commits.log.$A"
mv "${TEMPDIR}/${project}-commits.log.$A" "${TEMPDIR}/${project}-commits.log"
done
elif [ -n "$excludes" ]; then
# otherwise if there is a small list of excludes in the config file
# then process with awk (this was the original exclude mechanism)
awk "/^commit /{ok=1} /^commit ${excludes}/{ok=0} {if(ok) {print}}" \
< "${TEMPDIR}/${project}-commits.log" > "${TEMPDIR}/${project}-commits.log.new"
mv "${TEMPDIR}/${project}-commits.log.new" "${TEMPDIR}/${project}-commits.log"
fi
done
echo "Generating git statistics"
DEBUG "Generating git statistics for each sub-project"
cd ${BASEDIR}
grep -v '^#' ${CONFIGDIR}/${RELEASE} |
while read project x; do
DEBUG "Generating git stats for ${project}"
python gitdm -l 20 -n < "${TEMPDIR}/${project}-commits.log" > "${TEMPDIR}/${project}-git-stats.txt"
done
DEBUG "Generating aggregate git stats for CORE projects"
for project in ${CORE_PROJECTS}; do
cat "${TEMPDIR}/${project}-commits.log" >> "${TEMPDIR}/core-git-commits.log"
done
python gitdm -l 20 -n < "${TEMPDIR}/core-git-commits.log" > "${TEMPDIR}/core-git-stats.txt"
DEBUG "Generating aggregate git stats for INFRASTRUCTURE projects"
for project in ${INFRA_PROJECTS}; do
cat "${TEMPDIR}/${project}-commits.log" >> "${TEMPDIR}/infra-git-commits.log"
done
python gitdm -l 20 -n < "${TEMPDIR}/infra-git-commits.log" > "${TEMPDIR}/infra-git-stats.txt"
DEBUG "Generating aggregate git stats for ALL of openstack"
grep -v '^#' ${CONFIGDIR}/${RELEASE} |
while read project x; do
cat "${TEMPDIR}/${project}-commits.log" >> "${TEMPDIR}/git-commits.log"
done
python gitdm -l 20 -n < "${TEMPDIR}/git-commits.log" > "${TEMPDIR}/git-stats.txt"
fi
if [ "$LP_STATS" = "y" ] ; then
echo "Generating a list of bugs"
cd ${BASEDIR}
# get a list of all the launchpad projects we want to examine.
# Exclude comments and all of the infrastructure/ci projects
LP_PROJECTS=`grep -v '^#' ${CONFIGDIR}/${RELEASE} | grep -Ev "^(${CI_PROJECTS})" |
while read project x; do
echo ${project}
done`
DEBUG "Got LP_PROJECTS = '${LP_PROJECTS}'"
for project in ${LP_PROJECTS}; do
DEBUG "Retrieving bug list for project ${project}"
./tools/with_venv.sh python launchpad/buglist.py ${project} ${RELEASE} > "${TEMPDIR}/${project}-bugs.log"
while read id person date x; do
emails=$(awk "/^$person / {print \$2}" ${CONFIGDIR}/launchpad-ids.txt)
echo $id $person $date $emails
done < "${TEMPDIR}/${project}-bugs.log" > "${TEMPDIR}/${project}-bugs.log.new"
mv "${TEMPDIR}/${project}-bugs.log.new" "${TEMPDIR}/${project}-bugs.log"
done
# handle the special case of openstack-ci which includes all of the openstack
# infrastructure / ci bugs, because openstack-ci uses different Launchpad
# attributes to organize its bugs
project=openstack-ci
DEBUG "Retriving bug list for project ${project}"
./tools/with_venv.sh python launchpad/openstack-ci-buglist.py ${RELEASE} > "${TEMPDIR}/${project}-bugs.log"
while read id person date x; do
emails=$(awk "/^$person / {print \$2}" ${CONFIGDIR}/launchpad-ids.txt)
echo $id $person $date $emails
done < "${TEMPDIR}/${project}-bugs.log" > "${TEMPDIR}/${project}-bugs.log.new"
mv "${TEMPDIR}/${project}-bugs.log.new" "${TEMPDIR}/${project}-bugs.log"
echo "Generating launchpad statistics"
cd ${BASEDIR}
for project in $LP_PROJECTS; do
grep -v '<unknown>' "${TEMPDIR}/${project}-bugs.log" |
python lpdm -l 20 > "${TEMPDIR}/${project}-lp-stats.txt"
done
DEBUG "Generating aggregate launchpad stats for CORE projects"
for project in ${CORE_PROJECTS}; do
grep -v '<unknown>' "${TEMPDIR}/${project}-bugs.log" >> "${TEMPDIR}/core-lp-bugs.log"
done
grep -v '<unknown>' "${TEMPDIR}/core-lp-bugs.log" |
python lpdm -l 20 < "${TEMPDIR}/core-lp-bugs.log" > "${TEMPDIR}/core-lp-stats.txt"
DEBUG "Generating aggregate launchpad stats for ALL of openstack"
for project in $LP_PROJECTS; do
grep -v '<unknown>' "${TEMPDIR}/${project}-bugs.log" >> "${TEMPDIR}/lp-bugs.log"
done
grep -v '<unknown>' "${TEMPDIR}/lp-bugs.log" |
python lpdm -l 20 > "${TEMPDIR}/lp-stats.txt"
fi
if [ "$GERRIT_STATS" = "y" ] ; then
echo "Generating a list of Change-Ids"
grep -v '^#' ${CONFIGDIR}/${RELEASE} |
while read project revisions x; do
cd "${GITBASE}/${project}"
git log ${revisions} |
awk '/^ Change-Id: / { print $2 }' |
split -l 100 -d - "${TEMPDIR}/${project}-${RELEASE}-change-ids-"
done
cd ${TEMPDIR}
grep -v '^#' ${CONFIGDIR}/${RELEASE} |
while read project x; do
> ${project}-${RELEASE}-reviews.json
for f in ${project}-${RELEASE}-change-ids-??; do
echo "Querying gerrit: ${f}"
ssh -p 29418 review.openstack.org \
gerrit query --all-approvals --format=json \
$(awk -v ORS=' OR ' '{print}' $f | sed 's/ OR $//') \
< /dev/null >> "${project}-${RELEASE}-reviews.json"
done
done
echo "Generating a list of commit IDs"
grep -v '^#' ${CONFIGDIR}/${RELEASE} |
while read project revisions x; do
cd "${GITBASE}/${project}"
git log --pretty=format:%H $revisions > \
"${TEMPDIR}/${project}-${RELEASE}-commit-ids.txt"
done
echo "Parsing the gerrit queries"
cd ${BASEDIR}
grep -v '^#' ${CONFIGDIR}/${RELEASE} |
while read project x; do
python gerrit/parse-reviews.py \
"${TEMPDIR}/${project}-${RELEASE}-commit-ids.txt" \
"${CONFIGDIR}/launchpad-ids.txt" \
< "${TEMPDIR}/${project}-${RELEASE}-reviews.json" \
> "${TEMPDIR}/${project}-${RELEASE}-reviewers.txt"
done
echo "Generating gerrit statistics"
cd ${BASEDIR}
grep -v '^#' ${CONFIGDIR}/${RELEASE} |
while read project x; do
python gerritdm -l 20 \
< "${TEMPDIR}/${project}-${RELEASE}-reviewers.txt" \
> "${TEMPDIR}/${project}-gerrit-stats.txt"
done
DEBUG "Generating aggregate gerrit stats for CORE projects"
> "${TEMPDIR}/core-gerrit-reviewers.txt"
for project in ${CORE_PROJECTS}; do
cat "${TEMPDIR}/${project}-${RELEASE}-reviewers.txt" >> "${TEMPDIR}/core-gerrit-reviewers.txt"
done
python gerritdm -l 20 < "${TEMPDIR}/core-gerrit-reviewers.txt" > "${TEMPDIR}/core-gerrit-stats.txt"
DEBUG "Generating aggregate gerrit stats for INFRASTRUCTURE projects"
> "${TEMPDIR}/infra-gerrit-reviewers.txt"
for project in ${INFRA_PROJECTS}; do
cat "${TEMPDIR}/${project}-${RELEASE}-reviewers.txt" >> "${TEMPDIR}/infra-gerrit-reviewers.txt"
done
python gerritdm -l 20 < "${TEMPDIR}/infra-gerrit-reviewers.txt" > "${TEMPDIR}/infra-gerrit-stats.txt"
DEBUG "Generating aggregate gerrit stats for ALL of openstack"
> "${TEMPDIR}/gerrit-reviewers.txt"
grep -v '^#' ${CONFIGDIR}/${RELEASE} |
while read project x; do
cat "${TEMPDIR}/${project}-${RELEASE}-reviewers.txt" >> "${TEMPDIR}/gerrit-reviewers.txt"
done
python gerritdm -l 20 < "${TEMPDIR}/gerrit-reviewers.txt" > "${TEMPDIR}/gerrit-stats.txt"
fi
cd ${BASEDIR}
rm -rf ${RELEASE} && mkdir ${RELEASE}
mv ${TEMPDIR}/*stats.txt ${RELEASE}
[ "$REMOVE_TEMPDIR" = "y" ] && rm -rf ${TEMPDIR} || echo "Not removing ${TEMPDIR}"