Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: MiM PR report #15355

Open
wants to merge 166 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
73a6ac9
add find_labels
adomani Jul 31, 2024
713a1b7
excl
adomani Jul 31, 2024
9d491b6
token?
adomani Jul 31, 2024
557f339
format message
adomani Jul 31, 2024
12eedba
move env
adomani Jul 31, 2024
f1c4c5a
move env
adomani Jul 31, 2024
c9af61b
checkout master
adomani Jul 31, 2024
3d7de17
origin
adomani Jul 31, 2024
f5dd7fe
closed, rather than merged
adomani Jul 31, 2024
a8e65ae
switch
adomani Jul 31, 2024
39e0a44
print date
adomani Jul 31, 2024
8139287
fetch all
adomani Jul 31, 2024
d6d231c
checkout later
adomani Jul 31, 2024
ad54316
no origin
adomani Jul 31, 2024
23795f9
do not filter much
adomani Jul 31, 2024
70b9390
print more
adomani Jul 31, 2024
65d04a3
no pages
adomani Jul 31, 2024
c6b67fa
closed
adomani Jul 31, 2024
70857d0
used commit numbers as limit
adomani Jul 31, 2024
fb27aa9
print title
adomani Jul 31, 2024
ff57b09
print title really
adomani Jul 31, 2024
09aa949
add number of commits
adomani Jul 31, 2024
2310592
rename CI step
adomani Jul 31, 2024
6f191db
starts with `Merged by Bors`
adomani Jul 31, 2024
d59268a
double the number of commits searched
adomani Jul 31, 2024
7fde707
one fewer day
adomani Jul 31, 2024
3bffc81
two different dates
adomani Jul 31, 2024
97a76bd
print all prs
adomani Jul 31, 2024
2006ef2
do not print prs
adomani Jul 31, 2024
5d29134
15 days
adomani Jul 31, 2024
75f13fc
number of commits
adomani Jul 31, 2024
8bb1097
commits in range
adomani Jul 31, 2024
5c6aee8
prune
adomani Jul 31, 2024
3cc12d2
print closed
adomani Jul 31, 2024
da61d9e
closedAt
adomani Jul 31, 2024
3dc7d93
restore closed
adomani Jul 31, 2024
3a5dc18
range dates
adomani Jul 31, 2024
f33dcdd
closedAt
adomani Jul 31, 2024
5dd222c
use search
adomani Jul 31, 2024
09c6474
search closed
adomani Jul 31, 2024
d7abc43
embed time in date
adomani Jul 31, 2024
d3eb548
remove printing of closed
adomani Jul 31, 2024
bd13254
print repository name
adomani Jul 31, 2024
1c6f6d4
use github API name for repo
adomani Jul 31, 2024
88882ae
Capitalize Repository
adomani Jul 31, 2024
0bbb60b
base on master
adomani Jul 31, 2024
f010c98
report missed PRs
adomani Jul 31, 2024
5b022b3
fix
adomani Jul 31, 2024
941964b
dates in git
adomani Jul 31, 2024
2d09ba4
engulph
adomani Jul 31, 2024
eaa5398
both
adomani Jul 31, 2024
b3358bc
better reporting
adomani Jul 31, 2024
53da2c4
formatting
adomani Jul 31, 2024
f6fca31
separation
adomani Jul 31, 2024
bf8180e
switch back to original branch
adomani Jul 31, 2024
e9e4bf5
switch back to original branch
adomani Jul 31, 2024
8bd675a
checkout
adomani Jul 31, 2024
5424675
print branch name
adomani Jul 31, 2024
bee9d55
use BRANCH_NAME as env variable
adomani Jul 31, 2024
9cfdaf1
create and remove temp files
adomani Jul 31, 2024
d4c6b83
print PRs
adomani Jul 31, 2024
2cb4eda
refactor
adomani Jul 31, 2024
53557ea
start extracting dates and docs
adomani Jul 31, 2024
60d2eab
extract reports
adomani Jul 31, 2024
1b5ccb9
checkout outside of the function
adomani Jul 31, 2024
42cc216
run twice to cover a whole month
adomani Jul 31, 2024
360d2f8
sort
adomani Jul 31, 2024
3c18faa
commit in range once
adomani Jul 31, 2024
93f0a06
print commits in range
adomani Jul 31, 2024
923b3ec
remove ticks
adomani Jul 31, 2024
3a56678
abstract year month
adomani Jul 31, 2024
a2e68b4
recycle variable
adomani Jul 31, 2024
5031911
local vars
adomani Jul 31, 2024
33af814
use current year and month
adomani Jul 31, 2024
9491ab2
Merge remote-tracking branch 'origin/master' into adomani/yd_find_label
adomani Jul 31, 2024
3126e27
split differently
adomani Jul 31, 2024
84da4d9
Merge remote-tracking branch 'origin/master' into adomani/yd_find_label
adomani Aug 1, 2024
48384c5
print prs
adomani Aug 1, 2024
ea56e86
filter better
adomani Aug 1, 2024
136093f
line breaks around reports
adomani Aug 1, 2024
0716baa
omit unnecessary escaped double quote
adomani Aug 1, 2024
088dda3
clean up, add closed PR numbers
adomani Aug 1, 2024
20ca0da
formatting
adomani Aug 1, 2024
453aa58
fix line break
adomani Aug 1, 2024
59711cf
print date ranges once
adomani Aug 1, 2024
50a23e7
formatting
adomani Aug 1, 2024
da0203e
stars
adomani Aug 1, 2024
9ed2e09
months
adomani Aug 1, 2024
be8a01f
next month
adomani Aug 1, 2024
6f0e59b
pad exceptions, remove parens
adomani Aug 1, 2024
7e51b99
Add question marks
adomani Aug 1, 2024
a2f1a2f
dates go up
adomani Aug 1, 2024
93cf6c6
14 15 16
adomani Aug 1, 2024
f2143bd
recycle
adomani Aug 1, 2024
63f9835
add authors
adomani Aug 1, 2024
6ec7878
new workflow
adomani Aug 1, 2024
a8a3b72
add author
adomani Aug 1, 2024
3c49769
ls
adomani Aug 1, 2024
edf76eb
checkout the right file
adomani Aug 1, 2024
e122bc7
checkout origin
adomani Aug 1, 2024
9702a0d
clean up after new action
adomani Aug 1, 2024
7f7c1ac
print with authors
adomani Aug 1, 2024
eb5ea7f
really print
adomani Aug 1, 2024
e96c649
single line
adomani Aug 1, 2024
30d5331
start/end _date
adomani Aug 1, 2024
f6a6e0c
add author name
adomani Aug 1, 2024
de359dc
do not print the json
adomani Aug 1, 2024
74bdcad
remove "or null"
adomani Aug 1, 2024
5b37820
PR number before author
adomani Aug 1, 2024
d931fef
rename job
adomani Aug 1, 2024
4da1164
reformat
adomani Aug 1, 2024
9cf2cb1
print seen
adomani Aug 1, 2024
0888ad4
initialize seen, use seen[order[i]]
adomani Aug 1, 2024
23744bd
header
adomani Aug 1, 2024
923dc2d
maintain a comment
adomani Aug 1, 2024
4ded3a4
embed title in message
adomani Aug 1, 2024
7e39374
printf
adomani Aug 1, 2024
c097f4d
use secrets
adomani Aug 1, 2024
8cc618d
some formatting
adomani Aug 1, 2024
0ae1677
quotes
adomani Aug 1, 2024
8fedb6e
end
adomani Aug 1, 2024
da8605f
remove filename
adomani Aug 1, 2024
ed4c190
ticks
adomani Aug 1, 2024
2eb5998
line break
adomani Aug 1, 2024
0a9b684
close details
adomani Aug 1, 2024
f3d0a09
remove initial PR
adomani Aug 1, 2024
d4974a6
plural to singular
adomani Aug 1, 2024
96d44cb
spaces
adomani Aug 1, 2024
00bfe68
Update .github/workflows/monthly_pr_report.yaml
adomani Aug 1, 2024
12f5456
Update .github/workflows/monthly_pr_report.yaml
adomani Aug 1, 2024
44864ff
Remove PR title
adomani Aug 1, 2024
2561ea3
remove unneeded line breaks
adomani Aug 2, 2024
96d685b
plural in all reports, format, remove initial </details>
adomani Aug 2, 2024
c66244f
shorten name
adomani Aug 2, 2024
79be0eb
reports collapse
adomani Aug 2, 2024
6fdfb6e
details at end
adomani Aug 2, 2024
d8ef988
close details
adomani Aug 2, 2024
a12987a
space out final details
adomani Aug 2, 2024
ed02c7c
one more line break
adomani Aug 2, 2024
a62b5b4
extract date
adomani Aug 2, 2024
903b0b5
<Month> in mathlib
adomani Aug 2, 2024
dd75942
show date
adomani Aug 2, 2024
f6e8a4c
Do not continue on error
adomani Aug 2, 2024
fcd366e
pass the date
adomani Aug 2, 2024
6999c07
do not print the date
adomani Aug 2, 2024
f2e8804
start with comment
adomani Aug 2, 2024
ac291ce
environment variable
adomani Aug 2, 2024
f6847e5
quotes
adomani Aug 2, 2024
26bea5d
print more
adomani Aug 2, 2024
353bec4
one line
adomani Aug 2, 2024
eeb1318
another one line
adomani Aug 2, 2024
a7d5a0f
add permissions
adomani Aug 2, 2024
a8825b5
also pull request
adomani Aug 2, 2024
e9a69c5
colon
adomani Aug 2, 2024
ca6cf86
comment better
adomani Aug 2, 2024
a6eca90
hide pull request
adomani Aug 2, 2024
09db8a7
only if
adomani Aug 2, 2024
b35c31e
no name
adomani Aug 2, 2024
4176673
remove permissions
adomani Aug 2, 2024
47b6d65
run on any comment
adomani Aug 2, 2024
90dc246
also deleted comments
adomani Aug 2, 2024
a761751
cleanup comment
adomani Aug 2, 2024
31112d7
two workflows: PR and comment
adomani Aug 2, 2024
c7967a9
add explicit repository
adomani Aug 2, 2024
4261540
remove comment action
adomani Aug 2, 2024
acaf9f3
use leanprover
adomani Aug 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/monthly_pr_report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
on:
pull_request

name: Blog report

jobs:

Monthly_PRs:
if: github.repository == 'leanprover-community/mathlib4' && github.event.pull_request.draft == false
name: Blog draft
runs-on: ubuntu-latest

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_NAME: ${{ github.head_ref }}

steps:
- name: cleanup
run: |
find . -name . -o -prune -exec rm -rf -- {} +

- uses: actions/checkout@v4
with:
repository: leanprover-community/mathlib4
fetch-depth: 0
ref: master

- name: blog report
run: |
yrMth=2024-07
mth="$(date -d "${yrMth}-01" '+%B')"
PR="${{ github.event.pull_request.number }}"
title="### ${mth} in Mathlib summary"

printf $'Repository: %s\nBranch: %s\n' "${{ github.repository }}" "${BRANCH_NAME}"
git checkout origin/adomani/yd_find_label scripts/find_labels.sh
message="$(printf '%s\n\n%s\n' "${title}" "$(./scripts/find_labels.sh "${{ github.repository }}" "${yrMth}")")"
echo "${message}"
message="$(echo "${message}" |
sed '
/ [0-9]* PRs$/{
s=^=</details><details><summary>\n=
s=$=\n</summary>\n=
}
s=^PR \(#[0-9]* [^:]*\): .*=* \1 =' |
sed -z '
s=</details><details><summary>=<details><summary>=
s=\n---\nReports\n\n=\n</details>\n\n---\n\n<details><summary>Reports</summary>\n\n=
s=\n---[\n]*$=\n\n</details>\n&=
')"
./scripts/update_PR_comment.sh "${message}" "${title}" "${PR}"
102 changes: 102 additions & 0 deletions scripts/find_labels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/bin/bash

# Check if required arguments are provided
if [ "$#" -ne 2 ]; then
printf $'Usage: %s <repo_owner/repo_name> <YYYY-MM>\n\nFor instance `%s leanprover-community/mathlib4`\n\n' "${0}" "${0}"
exit 1
fi

rm -rf found_by_gh.txt found_by_git.txt

findInRange () {

repository="${1}"

# Get the start and end dates
startDate="${2}"
endDate="${3}"

# find how many commits to master there have been in the last month
commits_in_range="$(git log --since="${startDate}" --until="${endDate}" --pretty=oneline | wc -l)"

# Retrieve merged PRs from the given range
prs=$(gh pr list --repo "$repository" --state closed --base master --search "closed:${startDate}..${endDate}" --json number,labels,title,author --limit "$((commits_in_range * 2))")

## Print PR numbers, their labels and their title
#echo "$prs" | jq -r '.[] | select(.title | startswith("[Merged by Bors]")) | "PR #\(.number) - Labels: \((.labels | map(.name) | join(", ")) // "No labels") - Title: \(.title)"'

# Store to file `found_by_gh.txt` the PR numbers, as found by `gh`
echo "$prs" | jq -r '.[] | select(.title | startswith("[Merged by Bors]")) | "(#\(.number))"' | sort >> found_by_gh.txt

# Store to file `found_by_git.txt` the PR numbers, as found by looking at the commits to `master`
git log --pretty=oneline --since="${startDate}" --until="${endDate}" |
sed -n 's=.*\((#[0-9]*)\)$=\1=p' | sort >> found_by_git.txt

echo "$prs"
}

# the current year and month
yr_mth="${2}" #"$(date +%Y-%m)"
yr_mth_day=${yr_mth}-01

start_date="${yr_mth_day}T00:00:00"
end_date="$(date -d "${yr_mth_day} + 1 month - 1 day" +%Y-%m-%d)T23:59:59"

mth="$(date -d "${yr_mth_day}" '+%B')"
prev_mth="$(date -d "${yr_mth_day} - 1 day" '+%B')"
next_mth="$(date -d "${yr_mth_day} + 1 month" '+%B')"

commits_in_range="$(git log --since="${start_date}" --until="${end_date}" --pretty=oneline | wc -l)"

printf $'\n\nBetween %s and %s there were\n' "${yr_mth_day}" "${end_date/%T*}"

printf $'* %s commits to `master` and\n' "${commits_in_range}"

(
findInRange "${1}" "${start_date}" "${yr_mth}-15T23:59:59" | sed -z 's=]\n*$=,\n='
findInRange "${1}" "${yr_mth}-16T00:00:00" "${end_date}" | sed -z 's=^\[=='
) | jq -S -r '.[] |
select(.title | startswith("[Merged by Bors]")) |
"\(.labels | map(.name | select(startswith("t-"))) ) PR #\(.number) \(if .author.name == "" then .author.login else .author.name end): \(.title)"' |
sort |
awk 'BEGIN{ labels=""; con=0; total=0 }
{ total++
if(!($1 in seen)) { con++; order[con]=$1; seen[$1]=0 }
seen[$1]++
gsub(/\[Merged by Bors\] - /, "")
rest=$2; for(i=3; i<=NF; i++){rest=rest" "$i};acc[$1]=acc[$1]"\n"rest }
END {
printf("* %s closed PRs\n", total)
for(i=1; i<=con; i++) {
tag=order[i]
gsub(/\[\]/, "Miscellaneous", tag)
gsub(/["\][]/, "", tag)
gsub(/,/, " ", tag)
noPR=seen[order[i]]
printf("\n%s, %s PR%s%s\n", tag, noPR, noPR == "1" ? "" : "s", acc[order[i]])
}
}
'

only_gh="$( comm -23 <(sort found_by_gh.txt) <(sort found_by_git.txt) | sed 's=^= =' | tr -d '()')"
only_git="$(comm -13 <(sort found_by_gh.txt) <(sort found_by_git.txt) | sed 's=^= =' | tr -d '()')"

printf $'\n---\nReports\n\n'

if [ -z "${only_gh}" ]
then
printf $'* All PRs are accounted for!\n'
else
printf $'* PRs not corresponding to a commit (merged in %s, closed in %s?)\n%s\n' "${prev_mth}" "${mth}" "${only_gh}"
fi

if [ -z "${only_git}" ]
then
printf $'\n* All commits are accounted for!\n'
else
printf $'\n* PRs not found by `gh` (merged in %s, closed in %s?)\n%s\n' "${mth}" "${next_mth}" "${only_git}"
fi

printf -- $'---\n'

rm -rf found_by_gh.txt found_by_git.txt
Loading