-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcirrus-flake-catchup
executable file
·44 lines (37 loc) · 1.74 KB
/
cirrus-flake-catchup
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
#!/bin/bash
#
# cirrus-flake-catchup - bring local database up-to-date
#
# FIXME: we need a better way, because some PRs won't be in db
#
# FIXME: AUGH! This lists by ID, not merge time! So 7845, which is an old
# number that merged 10 minutes ago, does not show up in 7940..7871
#
if [[ -z $GITHUB_TOKEN ]]; then
echo "You need to set \$GITHUB_TOKEN" >&2
exit 1
fi
for PROJECT in podman buildah skopeo netavark; do
echo -e "\e[34m" $PROJECT "\e[m"
DB="$HOME/.local/share/cirrus-flake-summarize/$PROJECT/db.sqlite"
curl -s -S -H "Authorization: bearer $GITHUB_TOKEN" -X POST --data '{ "query": "{ repository(owner:\"containers\", name: \"'$PROJECT'\") { pullRequests(states:[MERGED], first:30, orderBy: {field:UPDATED_AT,direction:DESC}) { nodes { number title } } } }" }' https://api.github.com/graphql \
| jq -r '.data.repository.pullRequests.nodes[] | "\(.number) \(.title)"' \
| while read pr rest; do
found=$(echo "SELECT COUNT(*) FROM flakes WHERE pr=$pr;" | sqlite3 $DB)
if ((found == 0)); then
merged=$(echo "SELECT COUNT(*) FROM merged WHERE pr=$pr;" | sqlite3 $DB)
if ((merged == 0)); then
echo
echo -e "\e[35m" $pr - $rest "\e[0m"
# FIXME: fail on error? Offer option to continue?
# "Could not get task ID" is okay for v3.2
cirrus-flake-summarize --project=$PROJECT $pr
# Mark as merged, so we don't do it again
echo "INSERT INTO merged VALUES ($pr);" | sqlite3 $DB
fi
fi
done
rm -f ~/public_html/cirrus-flake-xref/*tmp*
cirrus-flake-xref --project=$PROJECT
done
rsync -avP ~/public_html/cirrus-flake-xref/. irc:public_html/cirrus-flake-xref/.