-
Notifications
You must be signed in to change notification settings - Fork 3
564 lines (525 loc) · 18.6 KB
/
publish_requests_all.yml
File metadata and controls
564 lines (525 loc) · 18.6 KB
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
name: Update with requested PRs (all)
on:
workflow_dispatch:
jobs:
pr-requests:
runs-on: ubuntu-latest
if: github.repository == 'AliceO2Group/dpg-documentation'
steps:
- name: Checkout documentation
uses: actions/checkout@v4
with:
repository: AliceO2Group/dpg-documentation
path: dpg-documentation
persist-credentials: false
# To push the updated branch, we need a non-shallow clone.
fetch-depth: 0
- name: Create PR branch in docs
working-directory: dpg-documentation
run: |
git config --global user.email 'alibuild@cern.ch'
git config --global user.name 'ALICE Action Bot'
# Overwrite branch, creating a new one based on HEAD
git checkout -B auto-update-requests
- name: Get PRs
id: get_prs
uses: octokit/graphql-action@v2.x
env:
GITHUB_TOKEN: ${{ github.token }}
with:
query: |
query {
doc: repository(owner: "AliceO2Group", name: "dpg-documentation") {
id
}
AliceO2_1: repository(owner: "AliceO2Group", name: "AliceO2") {
pullRequests(first: 100, states: [MERGED, OPEN], labels: ["async-2023-pbpb-apass3"], orderBy: { field: UPDATED_AT, direction: DESC }) {
nodes {
title
createdAt
updatedAt
mergedAt
number
labels(first:12) {
edges{
node {
name
}
}
}
state
url
author {
login
}
mergeCommit {
oid
}
commits(first: 10) {
nodes {
commit {
oid
}
}
}
}
}
}
AliceO2_2: repository(owner: "AliceO2Group", name: "AliceO2") {
pullRequests(first: 100, states: [MERGED, OPEN], labels: ["async-2023-pbpb-apass4"], orderBy: { field: UPDATED_AT, direction: DESC }) {
nodes {
title
createdAt
updatedAt
mergedAt
number
labels(first:12) {
edges{
node {
name
}
}
}
state
url
author {
login
}
mergeCommit {
oid
}
commits(first: 10) {
nodes {
commit {
oid
}
}
}
}
}
}
AliceO2_3: repository(owner: "AliceO2Group", name: "AliceO2") {
pullRequests(first: 100, states: [MERGED, OPEN], labels: ["async-2022-pp-apass6-2023-PbPb-apass2"], orderBy: { field: UPDATED_AT, direction: DESC }) {
nodes {
title
createdAt
updatedAt
mergedAt
number
labels(first:12) {
edges{
node {
name
}
}
}
state
url
author {
login
}
mergeCommit {
oid
}
commits(first: 10) {
nodes {
commit {
oid
}
}
}
}
}
}
AliceO2_4: repository(owner: "AliceO2Group", name: "AliceO2") {
pullRequests(first: 100, states: [MERGED, OPEN], labels: ["async-2022-pp-apass4"], orderBy: { field: UPDATED_AT, direction: DESC }) {
nodes {
title
createdAt
updatedAt
mergedAt
number
labels(first:12) {
edges{
node {
name
}
}
}
state
url
author {
login
}
mergeCommit {
oid
}
commits(first: 10) {
nodes {
commit {
oid
}
}
}
}
}
}
AliceO2_5: repository(owner: "AliceO2Group", name: "AliceO2") {
pullRequests(first: 100, states: [MERGED, OPEN], orderBy: { field: UPDATED_AT, direction: DESC }) {
nodes {
title
createdAt
updatedAt
mergedAt
number
labels(first:12) {
edges{
node {
name
}
}
}
state
url
author {
login
}
mergeCommit {
oid
}
commits(first: 10) {
nodes {
commit {
oid
}
}
}
}
}
}
O2DPG_1: repository(owner: "AliceO2Group", name: "O2DPG") {
pullRequests(first: 100, states: [MERGED, OPEN], labels: ["async-2023-pbpb-apass3"], orderBy: { field: UPDATED_AT, direction: DESC }) {
nodes {
title
createdAt
updatedAt
mergedAt
number
labels(first:12) {
edges{
node {
name
}
}
}
state
url
author {
login
}
mergeCommit {
oid
}
commits(first: 10) {
nodes {
commit {
oid
}
}
}
}
}
}
O2DPG_2: repository(owner: "AliceO2Group", name: "O2DPG") {
pullRequests(first: 100, states: [MERGED, OPEN], labels: ["async-2023-pbpb-apass4"], orderBy: { field: UPDATED_AT, direction: DESC }) {
nodes {
title
createdAt
updatedAt
mergedAt
number
labels(first:12) {
edges{
node {
name
}
}
}
state
url
author {
login
}
mergeCommit {
oid
}
commits(first: 10) {
nodes {
commit {
oid
}
}
}
}
}
}
O2DPG_3: repository(owner: "AliceO2Group", name: "O2DPG") {
pullRequests(first: 100, states: [MERGED, OPEN], labels: ["async-2022-pp-apass6-2023-PbPb-apass2"], orderBy: { field: UPDATED_AT, direction: DESC }) {
nodes {
title
createdAt
updatedAt
mergedAt
number
labels(first:12) {
edges{
node {
name
}
}
}
state
url
author {
login
}
mergeCommit {
oid
}
commits(first: 10) {
nodes {
commit {
oid
}
}
}
}
}
}
O2DPG_4: repository(owner: "AliceO2Group", name: "O2DPG") {
pullRequests(first: 100, states: [MERGED, OPEN], labels: ["async-2022-pp-apass4"], orderBy: { field: UPDATED_AT, direction: DESC }) {
nodes {
title
createdAt
updatedAt
mergedAt
number
labels(first:12) {
edges{
node {
name
}
}
}
state
url
author {
login
}
mergeCommit {
oid
}
commits(first: 10) {
nodes {
commit {
oid
}
}
}
}
}
}
O2DPG_5: repository(owner: "AliceO2Group", name: "O2DPG") {
pullRequests(first: 100, states: [MERGED, OPEN], orderBy: { field: UPDATED_AT, direction: DESC }) {
nodes {
title
createdAt
updatedAt
mergedAt
number
labels(first:12) {
edges{
node {
name
}
}
}
state
url
author {
login
}
mergeCommit {
oid
}
commits(first: 10) {
nodes {
commit {
oid
}
}
}
}
}
}
QualityControl_1: repository(owner: "AliceO2Group", name: "QualityControl") {
pullRequests(first: 100, states: [MERGED, OPEN], orderBy: { field: UPDATED_AT, direction: DESC }) {
nodes {
title
createdAt
updatedAt
mergedAt
number
labels(first:12) {
edges{
node {
name
}
}
}
state
url
author {
login
}
mergeCommit {
oid
}
commits(first: 10) {
nodes {
commit {
oid
}
}
}
}
}
}
}
- name: Store PRs
run: |
cat <<\EOF > prs.json
${{ steps.get_prs.outputs.data }}
EOF
cat prs.json
- name: Make the request pages
shell: python
run: |
import json
# sort before further processing (by state, and merge/update timestamp)
def sort_prs(prs):
# Need to sort by
# - MERGED or OPEN
# - async-labels
# - mergedAt or updatedAt
prs_dict = {}
repo_pr_numbers = []
for pr in prs:
repo_name = pr['repo_name']
repo_name_number = (repo_name, pr['number'])
if repo_name_number in repo_pr_numbers:
continue
repo_pr_numbers.append(repo_name_number)
flag = pr['state']
if flag not in prs_dict:
prs_dict[flag] = {}
label_edges = pr.get('labels', {}).get('edges', None)
if not label_edges:
continue
label_names = []
for edge in label_edges:
label_name = edge.get('node', {}).get('name', None)
if not label_name:
continue
if not label_name.startswith('async-'):
continue
label_names.append(label_name)
for label_name in label_names:
if label_name not in prs_dict[flag]:
prs_dict[flag][label_name] = {}
if repo_name not in prs_dict[flag][label_name]:
prs_dict[flag][label_name][repo_name] = []
prs_dict[flag][label_name][repo_name].append(pr)
return prs_dict
def make_report(flag, prs_per_label, outfile):
with open(outfile, 'w') as f:
f.write(f'# List PRs in state {flag} (from oldest to recent)\n')
for label_name, prs_per_repo in prs_per_label.items():
f.write(f'\n\n### For label {label_name}\n\n')
if flag == 'MERGED':
sort_by_field = 'mergedAt'
common_header = '| Author | Package | PR | PR title | Merged at | #original commits | Merge commit |\n| --- | --- | --- | --- | --- | --- | --- |\n'
else:
sort_by_field = 'updatedAt'
common_header = '| Author | Package | PR | PR title | Updated at | #original commits | Merge commit |\n| --- | --- | --- | --- | --- | --- | --- |\n'
f.write(common_header)
for repo_name, prs in prs_per_repo.items():
sort_by = [pr[sort_by_field] for pr in prs]
for s, pr in sorted(zip(sort_by, prs)):
f.write(f'| {pr["author"]["login"]} | {repo_name} | [PR]({pr["url"]}) | {pr["title"]} | {s} | {len(pr["commits"]["nodes"])} | {pr["mergeCommit"]["oid"] if pr["mergeCommit"] else "-"} |\n')
def make_markdowns(prs_json):
# a list of all PRs
prs = []
with open(prs_json, 'r') as f:
prs_github = json.load(f)
for repo_name, prs_repo in prs_github.items():
if 'AliceO2' not in repo_name and 'O2DPG' not in repo_name and 'QualityControl' not in repo_name:
continue
# get the repo name without suffix
repo_name = repo_name.split('_')[0]
for pr in prs_repo.get('pullRequests', {}).get('nodes', []):
# add the repo name manually, otherwise we would also need to query it in addition from GitHub; but we know what we are asking for in the initial query
pr['repo_name'] = repo_name
prs.append(pr)
# sort before further processing (by state, label and merge/update timestamp)
prs = sort_prs(prs)
for flag, prs_per_label in prs.items():
make_report(flag, prs_per_label, f'dpg_pr_report_{flag}.md')
make_markdowns('prs.json')
- name: Add and push changes, get repo ID
id: add_push_repo_id
env:
GITHUB_TOKEN: ${{ secrets.ALIBUILD_GITHUB_TOKEN }}
working-directory: dpg-documentation/
run: |
cp ../*.md docs/software/requests_automatic
echo "NEED_PR=true" >> $GITHUB_OUTPUT
if git diff --quiet; then
echo "No changes, nothing to push."
echo "NEED_PR=false" >> $GITHUB_OUTPUT
exit 0 # Nothing has changed, so no need to send a PR.
fi
# Add the markdown files here
git add *.md
git commit -m 'Automatic update of PR requests'
git remote set-url origin "https://alibuild:$GITHUB_TOKEN@github.com/AliceO2Group/dpg-documentation"
git push -f origin auto-update-requests
repo_id=$(jq -r '.doc.id' ../prs.json)
echo "REPO_ID=${repo_id}" >> $GITHUB_OUTPUT
- name: Open PR
id: open_pr
if: ${{ steps.add_push_repo_id.outputs.NEED_PR == 'true' }}
uses: octokit/graphql-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.ALIBUILD_GITHUB_TOKEN }}
repo_id: ${{ github.repository_id }}
with:
query: |
mutation CreatePullRequest($repoId: ID!) {
createPullRequest(input: {
repositoryId: $repoId,
baseRefName: "main",
headRefName: "auto-update-requests",
title: "Update requests",
body: ""
}) {
pullRequest {
number
url
}
}
}
variables: |
{
"repoId": "${{ steps.add_push_repo_id.outputs.REPO_ID }}"
}