-
Notifications
You must be signed in to change notification settings - Fork 7
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
Feature/close draft pr #93
Conversation
raise a PR when the --pullrequest=true or if set in the wiby.json file.
add a body and title to the PR
remove the PR during the result scan
add tests for PR closing
change the status and the conclussion to values defined in [checkrun definitio](https://docs.github.com/en/[email protected]/graphql/reference/objects#checkrun)
lib/result.js
Outdated
@@ -37,6 +37,7 @@ module.exports = async function ({ dependents }) { | |||
const parentBranchName = await context.getParentBranchName() | |||
const branch = await context.getTestingBranchName(parentBranchName) | |||
let resp = await github.getChecks(dependentPkgInfo.owner, dependentPkgInfo.name, branch) | |||
await updatePRStatus(dependentPkgInfo.owner, dependentPkgInfo.name, branch, resp.data.check_runs) |
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.
🤔
So we do have a wiby clean
command, which deletes the branches. So maybe that's a better fit for this?
I'm kind of torn on whether the full wiby clean
should happen automatically after the results are successful (it seems it now does it regardless of the result?) - I think if, as an implementer of a feature, I run wiby result
, and there's a failure - I definitely want to keep things as is, so that I can go explore and debug. But if everything passed - I might still want to keep things around, if I'm building a feature that spans multiple repos?
Quite possibly this is a full-on separate feature and/or needs to be behind a global config flag (--auto-clean
/ autoClean
in wiby.json
or smth).
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.
agreed.
Let me address the other issues in this draft PR. Then we can discuss further and maybe move it behind a different command.
👏 Thanks. sorry for not responding and not clarifying things earlier... I see there's some other discussions on the issue - will check those out now 👍 |
change updatePRStatus to closePR
change pullrequest to pull-request change pullRequest (json) to pullRequest
change the pullRequest to be per dependent object
lib/result.js
Outdated
} | ||
const prsToClose = checkRuns.reduce((acc, check) => { | ||
if (check.status === 'completed' && | ||
check.conclusion === 'success' && |
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.
I forgot... do we not already have a helper function to verify if check has passed?
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.
not sure I see this else where?
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.
Yeah, OK, the one we have is in a different context 👍
lib/test.js
Outdated
` | ||
const head = context.getTestingBranchName(parentBranchName) | ||
const draft = true | ||
const result = await github.createPR(dependentOwner, dependentRepo, title, head, parentBranchName, draft, body) |
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.
Do we need to set the base
to parentBranchName
here? I do have a note in the issues, that if the branch exists in the dependent repo as well as in parent repo, we should try to use that, but that's not implemented yet, so at this point parentBranchName
likely does not even exist - we should probably keep it undefined
(if the API allows it - otherwise we need to fetch the default branch name...)?
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.
I was not sure on this comment, but its late afternoon so I'm taking it easy.
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.
@dominykas ok, I came back to look at this comment and confess to not understanding at first you are referring to this I think issue 95. If so I think I understand.
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.
It's kind of related to that issue, but that's not exactly it.
When opening a PR, we want to merge head
into base
. So most of the time base
should be main
/ master
(i.e. default branch), not parentBranchName
?
- Suppose you're working on
my-feature
- You
wiby test
- A
wiby-my-feature
branch is created in the dependent repo - You should be opening a PR on the dependent repo to merge
wiby-my-feature
intomain
i.e. my-feature
(parentBranchName
) will not even exist in the dependent, most of the time. When it does - we do have the "existing branches" case, which needs to be thought through - most likely we'll want to create a wiby-my-feature
in the dependent, but we will not start it at main
/ master
, but at my-feature
instead. In that case, there could be some DX wins if the PR on the dependent tried to merge wiby-my-feature
into my-feature
, but at the same time - if it tries to merge wiby-my-feature
into main
, it's probably no big deal either?
This is hard 😅
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.
To simplify this - I think initially the base
param should always be empty (if GH will accept that), and the rest should be addressed as we tackle the existing branches case.
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.
Not quite done yet, I'm going for the merging into the default branch main or whatever the default is set to. ( the better DX experience needs another change which I'm going to try for tomorrow.
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.
@dominykas , I altered the code to raise the PR against the default branch and added changes to the tests to cover this most simple scenario. I too want to get this PR merged and maybe covering the other edge cases should be handled in another follow up PR?
I'm redoing this with the suggestions that it be a different feature flag.
I am going to merge the changes I have made back into this PR now. We may need to re-review it. |
add new feature flag... for PR removal
add small amount of text output for success case with the intent of adding proper processing next.
lint fixes
updates to names and suggestions from feedback
add a TODO to remind me to create a processOutput for the close-pr command
🤔 I see you added That said, I think we probably still need to add it into |
@@ -32,6 +32,9 @@ module.exports = async function ({ dependents }) { | |||
|
|||
const patchedPackageJSON = applyPatch(parentDependencyLink, parentPkgJSON.name, dependentPkgJson, parentPkgJSON.name) | |||
await pushPatch(patchedPackageJSON, dependentRepositoryInfo.owner, dependentRepositoryInfo.name, parentPkgJSON.name, parentBranchName) | |||
if (pullRequest) { |
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.
Updated #95 (comment) - if we think that's the right approach, then we should check if the PR is already open here (we need to open a new one if it's closed).
I can't recall if the GH API returns the PR list as part of the "get branch" API call, or if there's a separate API call for that...
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. I agree that clean needs it to. I'll merge the latest changes back into my branch and carry on.
One other thing occurred to me. We may want to be using the Promise.allSettled() module as if we checking upon multiple checks. But that can be for 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.
Promise.allSettled()
Yeah, that probably makes sense.
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 looking at the needs of the clean command. I do not think we need to do anything. If the branch is deleted during a clean then the PR that was raised against that branch to trigger an action is also deleted.
If you agree with my opinion I'll look at issue 95 with respect to the close-pr command.
add TODO noting that the run checks could be > 1 for a branch and that some could pass and some could fail and we need to handle that case
# Conflicts: # test/cli/test.js
Co-authored-by: Dominykas Blyžė <[email protected]>
many thanks for the reviews |
I'm keen to merge this, but #93 (comment) is not yet resolved? (the |
I'll look at this with respect to #93 tomorrow. Today I need to prep or the talk for OpenJSWorld. |
PR should be raised against the default branch this could be main. Next handle the case that the feature branch is already there.
…ture/close-draft-pr
test that the parent branch exists or not in the dependent. If the dependency parent branch exists in the dependent use that branch and raise a PR of wiby-feature-x into feature-x rather than into the default branch.
rationalize repeated nock code block into a beforeEach clause.
@dominykas I had some extra time so I have addressed the case where the dependency feature branch name could be pre-existing in the dependent repo, and altered the PR raised to be wiby-feature-x into feature-x in that case. |
wiby test |
(don't really expect ☝️ to work, but still hoping that maybe GH fixed the issue I was having...) |
🎉 This PR is included in version 0.8.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Changes for issue 53
Both opens the draft PR on test and closes it on result
using --pullrequest, open to use of other names
goes in ontop of pull 91 tap update