8000 refactor: determine PR number/sha using GitHub API in report.yml by veprbl · Pull Request #4361 · acts-project/acts · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

refactor: determine PR number/sha using GitHub API in report.yml #4361

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

Merged

Conversation

veprbl
Copy link
Contributor
@veprbl veprbl commented Jun 23, 2025

This refactors Physmon report action to query PR number and head sha from GitHub API. The goal here is to get rid of dependency on physmon artifact, so that we are able to post reports from other workflows without having to wait for this artifact to appear.

--- END COMMIT MESSAGE ---

This is a second attempt at #4328. It looks like, indeed, my original solution had an issue with github hiding information about open pull requests. It appears that running gh pr view is the accepted solution: https://github.com/orgs/community/discussions/25220#discussioncomment-11316244

This was tested to produce a posting for a cross-repo PR: veprbl#6

Summary by CodeRabbit

  • Chores
    • Improved reliability of GitHub Actions workflows by updating how pull request numbers and SHAs are determined and handled.
    • Enhanced error prevention in workflow steps by ensuring necessary directories are created before use.
    • Streamlined workflow conditions to better handle success or failure of PR number retrieval steps.

@github-actions github-actions bot added the Infrastructure Changes to build tools, continous integration, ... label Jun 23, 2025
@github-actions github-actions bot added this to the next milestone Jun 23, 2025
Copy link
coderabbitai bot commented Jun 23, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Workflow steps in builds.yml and report.yml updated have been. The "Save PR number" step removed from linux_physmon job, and directory creation for summaries improved. In report.yml, PR number and SHA retrieval now uses GitHub CLI directly, with conditional logic for step execution refined.

Changes

File(s) Summary of Changes
.github/workflows/builds.yml Removed "Save PR number" step; ensured physmon directory exists before summary posting.
.github/workflows/report.yml Refactored PR number/SHA retrieval to use GitHub CLI; updated dependent step conditions and outputs.

Sequence Diagram(s)

sequenceDiagram
    participant Workflow
    participant GitHub CLI
    participant GitHub API

    Workflow->>GitHub CLI: Query PR number and SHA (gh pr view)
    GitHub CLI->>GitHub API: Request PR info (repo, branch)
    GitHub API-->>GitHub CLI: Respond with PR number and SHA
    GitHub CLI-->>Workflow: Set environment variables (PR_NUMBER, SHA)
    Workflow->>Workflow: Conditionally run steps if PR number found
Loading

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • paulgessinger

Poem

In workflows deep, a change appears,
The PR number step, gone with no tears.
With GitHub CLI, swift as the breeze,
Retrieve we now, PR numbers with ease.
Yoda approves, efficient and neat—
May your Actions forever repeat!


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@veprbl veprbl changed the title report.yml: determine PR number/sha using GitHub API refactor: determine PR number/sha using GitHub API in report.yml Jun 23, 2025
Copy link
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (1)
.github/workflows/report.yml (1)

81-92: Undefined, PR_SHA is – comment empty it will render.

Inside the Render comment step the script expands $PR_SHA, yet this variable never enters the environment. Outputs written to $GITHUB_OUTPUT do not propagate to the shell session. The result: the SHA placeholder disappears, confusing reviewers.

Patch like this, you should:

-      - name: Render comment
-        if: steps.get-pr-number.outcome == 'success'
-        run: |
+      - name: Render comment
+        if: steps.get-pr-number.outcome == 'success'
+        env:
+          PR_SHA: ${{ steps.get-pr-number.outputs.PR_SHA }}
+        run: |

(or reference it via ${{ steps.get-pr-number.outputs.PR_SHA }} directly inside the YAML).

Do likewise for any later steps that rely on the same value.

🧹 Nitpick comments (1)
.github/workflows/report.yml (1)

55-69: CLI query clever, still a guard add you might.

gh pr view fails with non-zero exit when no PR matches; the whole job then dies. If graceful degradation you prefer, wrap the command:

if ! gh pr view … ; then
  echo "No matching PR found – skipping comment"; exit 0
fi

Small, this is, yet spares red crosses when the workflow fires on non-PR runs or closed PRs.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d3d89d and a7b96a8.

📒 Files selected for processing (2)
  • .github/workflows/builds.yml (1 hunks)
  • .github/workflows/report.yml (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (24)
  • GitHub Check: merge-sentinel
  • GitHub Check: CI Bridge / lcg_107: [alma9, clang19]
  • GitHub Check: CI Bridge / lcg_107: [alma9, gcc14]
  • GitHub Check: CI Bridge / build_gnn_tensorrt
  • GitHub Check: CI Bridge / build_linux_ubuntu
  • GitHub Check: CI Bridge / linux_ubuntu_2404_clang19
  • GitHub Check: CI Bridge / lcg_106a: [alma9, gcc14]
  • GitHub Check: CI Bridge / lcg_106a: [alma9, clang16]
  • GitHub Check: CI Bridge / build_exatrkx_cpu
  • GitHub Check: CI Bridge / lcg_107: [alma9, gcc13]
  • GitHub Check: CI Bridge / build_exatrkx
  • GitHub Check: CI Bridge / lcg_107: [alma9, gcc13]
  • GitHub Check: CI Bridge / lcg_106a: [alma9, gcc13]
  • GitHub Check: CI Bridge / linux_ubuntu_2204
  • GitHub Check: CI Bridge / clang_tidy
  • GitHub Check: CI Bridge / clang_tidy
  • GitHub Check: build_debug
  • GitHub Check: linux_ubuntu_extra (ubuntu2204, 20, g++)
  • GitHub Check: macos
  • GitHub Check: linux_ubuntu
  • GitHub Check: linux_ubuntu_extra (ubuntu2404_clang19, 20, clang++-19)
  • GitHub Check: docs
  • GitHub Check: missing_includes
  • GitHub Check: unused_files
🔇 Additional comments (1)
.github/workflows/builds.yml (1)

211-216: Directory ensured, failure avoided, good this change is.
mkdir -p physmon before the cat command you add – the “file not found” error, it shall prevent.

@veprbl veprbl force-pushed the pr/pr-number-sha-from-GH-api branch from a7b96a8 to 16180f1 Compare June 23, 2025 20:44
@paulgessinger
Copy link
Member

@veprbl This now uses the gh cli client. This looks like it might work. Does the branch name contain the source repo? Otherwise could there be problems if there are PRs from different forks with the same name?

@veprbl
Copy link
Contributor Author
veprbl commented Jun 24, 2025

@veprbl This now uses the gh cli client. This looks like it might work. Does the branch name contain the source repo? Otherwise could there be problems if there are PRs from different forks with the same name?

You can't make multiple forks (or forks of forks) in the same owner namespace, so "owner:branch" should uniquely identify a PR.

@veprbl
Copy link
Contributor Author
veprbl commented Jun 25, 2025

So, turns out it is possible to create multiple forks, but only if owner is an organization.
I've tried to setup such a collision (same branch name) in veprbl#7 and veprbl#8. What I found was that referencing veprbl-dummy-org:temp/test still works in the current setup, but only updates commend of the later PR. And it looks like it is not possible to disambiguate using a full_name:

Run gh pr view --repo "${PR_TARGET_REPO}" "${PR_BRANCH}" \
no pull requests found for branch "veprbl-dummy-org/acts1:temp/test"

https://github.com/veprbl/acts/actions/runs/15863838553/job/44726751681#step:5:13

@paulgessinger
Copy link
Member

This is probably fine @veprbl. Let's merge this and try it out

@paulgessinger paulgessinger merged commit 7510659 into acts-project:main Jun 30, 2025
39 of 41 checks passed
@paulgessinger paulgessinger modified the milestones: next, v42.0.0 Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Changes to build tools, continous integration, ...
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0