Skip to content

Bring back pr actions #6894

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
merged 3 commits into from
May 21, 2025
Merged

Bring back pr actions #6894

merged 3 commits into from
May 21, 2025

Conversation

svrnm
Copy link
Member

@svrnm svrnm commented May 15, 2025

Reverts #6663 with an improved workflow to run fix commands via GitHub comment:

  • add hardened runners by StepSecurity
  • split the creation of the changes & the application of them into two separate steps to disable the possibility to inject something malicious into the workflow run

@open-telemetry/docs-approvers @trask PTAL!

@theletterf I remember you had some code that would also check for the handle if the person is allowed to trigger the workflow (e.g. only org members, maintainers, etc.), we could add this as well.

NOTE: As always this github action has not been yet tested in full details, so unfortunately we will need to merge it at some point and then iterate on it until it works as expected.

@theletterf
Copy link
Member

I like it! For user checks, you'd have to add this to all actions, or similar:

    if: |
      github.event.issue.pull_request &&
      startsWith(github.event.comment.body, '/fix:') &&
      (contains(github.event.comment.user.roles, 'admin') || 
       contains(github.event.comment.user.roles, 'write') || 
       github.event.comment.author_association == 'MEMBER' || 
       github.event.comment.author_association == 'OWNER' || 
       github.event.comment.author_association == 'COLLABORATOR')

@svrnm
Copy link
Member Author

svrnm commented May 15, 2025

I like it! For user checks, you'd have to add this to all actions, or similar:

I'll try to incorporate that, thanks!

Copy link
Contributor

@chalin chalin left a comment

Choose a reason for hiding this comment

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

Great! Thanks so much for this @svrnm!

I don't have the time today to review this in detail (I'll be mostly AFK), so I'll let @trask et all work through the details. I'm glad to RSLGTM, get this merged and give it a spin! (I'm also looking forward to study this more closely later.)

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

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

approving with the two permission updates above

@trask
Copy link
Member

trask commented May 15, 2025

@svrnm now that you have a safe way to do this, what do you think of running this (or at least the most common ones?) on every PR build and automatically applying it? (not waiting for someone to add the comment)

@trask
Copy link
Member

trask commented May 15, 2025

@svrnm now that you have a safe way to do this, what do you think of running this (or at least the most common ones?) on every PR build and automatically applying it? (not waiting for someone to add the comment)

just saw your slack comment, which makes sense why you don't want to do this:

[applying] updates without any user intervention, which may be OK in a repo that is 90% contributed by the same folks, but we have way to many drive by contributors which will struggle with pushing and pulling and sometimes even don't know have to do git properly

@theletterf
Copy link
Member

@trask The rerun action one would likely come after this one!

@svrnm
Copy link
Member Author

svrnm commented May 15, 2025

@svrnm now that you have a safe way to do this, what do you think of running this (or at least the most common ones?) on every PR build and automatically applying it? (not waiting for someone to add the comment)

just saw your slack comment, which makes sense why you don't want to do this:

[applying] updates without any user intervention, which may be OK in a repo that is 90% contributed by the same folks, but we have way to many drive by contributors which will struggle with pushing and pulling and sometimes even don't know have to do git properly

Yeah, and thinking about it, there is actually another reason why we don't want to do that: some people update their PRs with lots of small commits, so I am not sure how this would behave, i.e. would we have a flooded action pipeline?

@chalin
Copy link
Contributor

chalin commented May 15, 2025

@svrnm now that you have a safe way to do this, what do you think of running this (or at least the most common ones?) on every PR build and automatically applying it? (not waiting for someone to add the comment)

If we're aiming to streamline the PR process for 80% the cases, I'd be willing to give this a try. Often, drive-by PRs need either fix:format or a refcache update. If we find that it doesn't make it easier for contributors and us maintainers, we can always pull it back.

Anyhow, let's get this merged first and see if the old /fix:... commands are working again. WDYT?


- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: refs/pull/${{ github.event.issue.number }}/head
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

good find! Previously we had a separate step checking out the branch, maybe we need to bring that back

@trask
Copy link
Member

trask commented May 16, 2025

heads up, CodeQL is complaining security flaws in my PR where I'm testing out this approach: open-telemetry/opentelemetry-java-instrumentation#13872

I'm working through them now to understand and hopefully address...

@svrnm
Copy link
Member Author

svrnm commented May 21, 2025

I tested the command in my own repo, it worked for /fix:format, it tripped with /fix:all but that might be related to the drift detection, I also had some issues with npm dependencies&caching, might be related to some things missing in my repo what we have here, so we can revisit that.

@chalin
Copy link
Contributor

chalin commented May 21, 2025

@trask - anything left to do before we can merge and test?

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

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

I think it can be simplified, but have no issue with this being merged as-is

with:
fetch-depth: 999

- run: gh pr checkout $PR_NUM -b "pr-action-${RANDOM}"
Copy link
Member

Choose a reason for hiding this comment

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

I think this simplifies things, because then you can just git push at the end (see below)

Suggested change
- run: gh pr checkout $PR_NUM -b "pr-action-${RANDOM}"
- run: gh pr checkout $PR_NUM

Copy link
Member Author

Choose a reason for hiding this comment

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

If I remember correctly we introduced this back in the day because we had some issues with branch names that were used on the fork and upstream (think: patch-1 or similar), I could dig up the issue for that

Copy link
Member

Choose a reason for hiding this comment

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

Comment on lines +128 to +135
# gh pr checkout sets some git configs that we can use to make sure
# we push to the right repo & to the right branch
remote_repo=$(git config --get branch.${current_branch}.remote)
echo remote_repo=$remote_repo
remote_branch=$(git config --get branch.${current_branch}.merge)
echo remote_branch=$remote_branch
git commit -m "Results from /fix:${PR_ACTION}"
git push ${remote_repo} HEAD:${remote_branch}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# gh pr checkout sets some git configs that we can use to make sure
# we push to the right repo & to the right branch
remote_repo=$(git config --get branch.${current_branch}.remote)
echo remote_repo=$remote_repo
remote_branch=$(git config --get branch.${current_branch}.merge)
echo remote_branch=$remote_branch
git commit -m "Results from /fix:${PR_ACTION}"
git push ${remote_repo} HEAD:${remote_branch}
# gh pr checkout sets some git configs that we can use to make sure
# we push to the right repo & to the right branch
git commit -m "Results from /fix:${PR_ACTION}"
git push

@chalin
Copy link
Contributor

chalin commented May 21, 2025

Merging. @svrnm et al. will follow through with the pending comments via another PR. Thanks all!

@chalin chalin merged commit 5a5462f into open-telemetry:main May 21, 2025
18 checks passed
@chalin chalin added the CI/infra CI & infrastructure label May 21, 2025
@chalin chalin mentioned this pull request May 21, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/infra CI & infrastructure
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants