-
Notifications
You must be signed in to change notification settings - Fork 15.3k
ci: Fix pr-code-format permissions for private forks
#120838
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
Conversation
The action requires the ability to change the contents of a pull request (by adding the formatting-related comment) which is only possible through the `write` permission, but if this permission is missing, potential private forks with Actions enabled will break, and because the action triggers on `pull_request_target` even a PR initially fixing this issue downstream will not exhibit the fix until merged.
|
@llvm/pr-subscribers-github-workflow Author: None (whisperity) ChangesThe action requires the ability to change the contents of a pull request (by adding the formatting-related comment) which is only possible through the Full diff: https://github.com/llvm/llvm-project/pull/120838.diff 1 Files Affected:
diff --git a/.github/workflows/pr-code-format.yml b/.github/workflows/pr-code-format.yml
index f2bb37316d3a8b..fda5b6d96e78c2 100644
--- a/.github/workflows/pr-code-format.yml
+++ b/.github/workflows/pr-code-format.yml
@@ -2,6 +2,8 @@ name: "Check code formatting"
permissions:
contents: read
+ issues: write
+ pull-requests: write
on:
pull_request:
|
|
This workflow should not be adding comments to the pull requests directly. The comments are added by this workflow instead: https://github.com/llvm/llvm-project/blob/main/.github/workflows/issue-write.yml So, I don't think it needs these permissions. Can you show me what failures you are seeing? |
|
I think you may have been looking at an old version of this action, because it uses |
We were getting two issues. First, the inability to download the contents of the (otherwise private) repository when This is not a problem for this repository because it is public, so the query can run.
Both the latest tagged release and the default branch contains the following code where the PR is commented directly by the formatting workflow: llvm-project/llvm/utils/git/code-format-helper.py Lines 133 to 136 in e21dc4b
|
In the llvm/llvm-project main branch, this code never gets called, because we pass the --write-comment-to-file option. |
|
Also, running the LLVM workflows in forks is not really a well-supported use case currently. People hacking on the actions typically make sure they work in the monorepo at head and leave it at that. If people want to maintain this and the changes are simple enough and don't impact how they operate in the monorepo, I'm probably fine with them going upstream. This patch significantly increases the permissions scope for this workflow and thus does impact how things operate in the monorepo, which I'm not a big fan of. |
In that case, should I create a patch that restricts the running of the action
It is very unlikely that anything would be changed by such a change. @tstellar Can you (or someone who has the rights) check how LLVM organisation is set up? Likely the write permission isn't needed in
either, because the org is set to allow write rights implicitly? |
Probably. It is worth checking the git history though as I remember some discussion about someone else removing it in a fork. I believe the consensus was that they should remove the check downstream, but I forget what ended up happening. |
|
I'll come back to this once we update our fork to the latest LLVM snapshot and see if there are still issues with it. So far I've realised I am a bit lost in the full diff between what we have (what existed in LLVM 18.1) and what exists in the upstream right now. I would apologise for the noise, and will make sure to check the larger picture in the diffs next time it happens — I made the wrong assumption that the CI scripts would not be so constantly evolving. 😇 |


The action requires the ability to change the contents of a pull request (by adding the formatting-related comment) which is only possible through the
writepermission, but if this permission is missing, potential private forks with Actions enabled will break, and because the action triggers onpull_request_targeteven a PR initially fixing this issue downstream will not exhibit the fix until merged.