Define approach for adding last changed by and last reviewed by to documents #573
Replies: 12 comments 5 replies
-
2025-02-28 Participants@AlexanderLanin Minutes@AlexanderLanin: @mmr1909: Possible approaches to determine review/approver information:1 GitHub API with PyGithubPro:
Con:
2 Store Reviewer information in commit messagesPro:
Con:
3 Combined approachGet all modified files with review-header directive from Sphinx
Con:
Untested query: https://chatgpt.com/share/67c86c41-b0c8-800a-b263-c7f700099969 |
Beta Was this translation helpful? Give feedback.
-
Analysis results:Github bot/appIdea: bot/app modifies the merge commit message
Github action
Disadvantage: Only works for merged PRs |
Beta Was this translation helpful? Give feedback.
-
I've looked into that pull_request.closed event. It is triggered after main has been modified. So it's already too late for our use case. |
Beta Was this translation helpful? Give feedback.
-
I wanna try a new summary. Let's see if that helps or not. Basically the approach is always the same: we use GitHub API and query the reviewer etc. When to query the API:
Cache can be:
This makes roughly 4*6=24 possible approaches. Before mergeOption 1) GitHub webhook -> no proper hook available, see above ❌ Therefore before merge is off the table Right after merge + Daily via CITrivially implementable with GitHub Actions. The more interesting question is where to cache the data. CachingIf we cache the data somewhere in git:
Open Points
|
Beta Was this translation helpful? Give feedback.
-
2025-03-07 Participants@AlexanderLanin Minutes
|
Beta Was this translation helpful? Give feedback.
-
The following query has a total cost of 1.
|
Beta Was this translation helpful? Give feedback.
-
Accessing team information is blocked. The following request
returns this error message:
Checking whether an approver is part of an approver group is therefore not possible via GraphQL API. |
Beta Was this translation helpful? Give feedback.
-
GitHub Triggers. Setup:
Workflows are triggered by:
=> PR closed is way after merge has completed. |
Beta Was this translation helpful? Give feedback.
-
I've asked ChatGPT to construct a query to find the reviewers of all our rst files. It came up with this script based on the one by @mmr1909 above. import subprocess
# GitHub repository details
ORG = "eclipse-score"
REPO = "score"
# Get the last commit for each .rst file
files = (
subprocess.run(
"git ls-files '*.rst' | while read file; do echo \"$(git log -1 --format='%H' -- $file) $file\"; done",
shell=True,
capture_output=True,
text=True,
)
.stdout.strip()
.split("\n")
)
# Generate GraphQL query
query = f"""query {{
rateLimit {{
limit
remaining
used
resetAt
cost
}}
repository(owner: "{ORG}", name: "{REPO}") {{
"""
for i, line in enumerate(files):
commit_hash, file_path = line.split(" ", 1)
query += f' commit{i}: object(expression: "{commit_hash}") {{\n'
query += """ ... on Commit {
associatedPullRequests(first:10) {
nodes {
author {
login
}
approver: reviews(first:100, states: APPROVED) {
nodes {
state
author {
login
}
}
}
reviewer: reviews(first:100, states: [COMMENTED, CHANGES_REQUESTED, DISMISSED]) {
nodes {
state
author {
login
}
}
}
}
}
}
}\n"""
query += " }\n}"
print(query) This generates the following .graphql query: query {
rateLimit {
limit
remaining
used
resetAt
cost
}
repository(owner: "eclipse-score", name: "score") {
commit0: object(expression: "a7634dbccd021c3a059b6238391528d18a1b4272") {
... on Commit {
associatedPullRequests(first: 10) {
nodes {
author {
login
}
approver: reviews(first: 100, states: APPROVED) {
nodes {
state
author {
login
}
}
}
reviewer: reviews(
first: 100
states: [COMMENTED, CHANGES_REQUESTED, DISMISSED]
) {
nodes {
state
author {
login
}
}
}
}
}
}
}
commit1: object(expression: "a7634dbccd021c3a059b6238391528d18a1b4272") {
... on Commit {
associatedPullRequests(first: 10) {
nodes {
author {
login
}
approver: reviews(first: 100, states: APPROVED) {
nodes {
state
author {
login
}
}
}
reviewer: reviews(
first: 100
states: [COMMENTED, CHANGES_REQUESTED, DISMISSED]
) {
nodes {
state
author {
login
}
}
}
}
}
}
}
# ... (shortened for brevity)
commit132: object(expression: "f03a8528be21e47eeff1e3d8590c4642215cec83") {
... on Commit {
associatedPullRequests(first: 10) {
nodes {
author {
login
}
approver: reviews(first: 100, states: APPROVED) {
nodes {
state
author {
login
}
}
}
reviewer: reviews(
first: 100
states: [COMMENTED, CHANGES_REQUESTED, DISMISSED]
) {
nodes {
state
author {
login
}
}
}
}
}
}
}
}
} That runs in ~4 seconds and the cost is reported as 28. |
Beta Was this translation helpful? Give feedback.
-
There is one more point we need to figure out, before putting this away as a low prio feature: Can and should we run that from Some ideas:
@ltekieli we started that discussion in ~December. It's back! Would you comment on this? Or should we have a call instead? Note: even if we abandon the idea of querying the info on demand. Instead query after merge (on push to main), and store the information somewhere. That would help reproducibility in case github is offline. But we still need to run |
Beta Was this translation helpful? Give feedback.
-
We could also use the GraphQL to determine the latest commit:
|
Beta Was this translation helpful? Give feedback.
-
2025-03-12 Participants@AlexanderLanin Minutes@AlexanderLanin: Next steps: @mmr1909 will update the header-service to use GraphQL. Implementation for git log extraction will be removed. |
Beta Was this translation helpful? Give feedback.
-
This discussion contains possible approaches how to add approver/reviewer information to documents.
See issue: #205
Beta Was this translation helpful? Give feedback.
All reactions