-
-
Notifications
You must be signed in to change notification settings - Fork 3
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] check status of commits #30
Conversation
The purpose of #20 is so that a commit that's pushed up, but is not part of a PR at all, can be checked. If a commit is part of a PR, then I suppose the status checks on the commit could be used instead of those on the PR, because there are some cases where that's different. I think it maybe makes sense for
|
|
0d0f4e7
to
7366241
Compare
@MeghalBisht heads up that i've rebased this; you may want to check out the branch fresh :-) |
@ljharb This looks ready to land, can you give it a final look please? |
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.
Getting close! I've rebased this for you; you'll want to delete your local branch and check it out again, or git reset --hard origin/commit-status
after fetching.
hmm, i just tried this on a commit, and it found no checks. This was the content of {
repository: { branchProtectionRules: { nodes: [] }, commit: null },
rateLimit: { cost: 1, remaining: 4994 }
} |
Hmm can you share the command you ran? I tested out a few commit SHAs, it seems to be working fine |
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.
This looks great! I'll give it a try today and report any feedback.
bin/can-merge
Outdated
@@ -98,13 +105,26 @@ runQuery(args.pr, String(args.repo), args.sha, token).then((response) => { | |||
console.log(JSON.stringify(response, null, 2)); | |||
} | |||
const prs = parsePullRequest(response.repository); | |||
if (prs.length === 0) { | |||
if (args.checkCommitStatus && args.sha && !args.pr) { |
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 might be a good idea to check the commit status even if a PR is provided, but let's look into that after this PR lands.
bin/can-merge
Outdated
let status = null; | ||
if (pr.commits.nodes.length > 1) { | ||
throw chalk.red('Failed to evaluate the status of the commit'); | ||
} | ||
status = evaluateCommitStatus(pr.commits.nodes[0].commit); |
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.
let status = null; | |
if (pr.commits.nodes.length > 1) { | |
throw chalk.red('Failed to evaluate the status of the commit'); | |
} | |
status = evaluateCommitStatus(pr.commits.nodes[0].commit); | |
if (pr.commits.nodes.length > 1) { | |
throw chalk.red('Failed to evaluate the status of the commit'); | |
} | |
const status = evaluateCommitStatus(pr.commits.nodes[0].commit); |
hmm - I ran this on sha d004c6b064 in https://github.com/nvm-sh/nvm, which i'd just force pushed to a PR, and I got: ⚠ This remote repository does not contain any pull requests matching sha: d004c6b064
{"branchProtectionRules":{"nodes":[{"requiresStatusChecks":true,"requiredApprovingReviewCount":1,"requiredStatusCheckContexts":["Automatic Rebase","Travis CI - Pull Request","Require “Allow Edits”","dockerfile_lint","doctoc","eclint","nvm install-latest-npm","release","shellcheck","test_naming","nvm_windows"]}]},"commit":{"statusCheckRollup":{"state":"PENDING","contexts":{"totalCount":79,"pageInfo":{"endCursor":"Nzk","hasNextPage":false},"nodes":[{"__typename":"CheckRun","status":"IN_PROGRESS","name":"eclint","conclusion":null},{"__typename":"CheckRun","status":"COMPLETED","name":"Automatic Rebase","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"Require “Allow Edits”","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"MSYS fail prefix nvm install","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"matrix","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"release","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"shellcheck_matrix (bash, nvm.sh)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"shellcheck_matrix (sh, nvm.sh)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"shellcheck_matrix (dash, nvm.sh)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"shellcheck_matrix (ksh, nvm.sh)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"shellcheck_matrix (bash, install.sh)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"shellcheck_matrix (bash, bash_completion)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"shellcheck_matrix (bash, nvm-exec)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (17)","conclusion":null},{"__typename":"CheckRun","status":"QUEUED","name":"shellcheck","conclusion":null},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"dockerfile_lint","conclusion":null},{"__typename":"CheckRun","status":"COMPLETED","name":"MSYS nvm install (--lts)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (16)","conclusion":null},{"__typename":"CheckRun","status":"COMPLETED","name":"MSYS nvm install (--default 12)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (15)","conclusion":null},{"__typename":"CheckRun","status":"COMPLETED","name":"MSYS nvm install (--no-progress 10)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (14)","conclusion":null},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"nvm install-latest-npm (13)","conclusion":null},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"nvm install-latest-npm (12)","conclusion":null},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"nvm install-latest-npm (11)","conclusion":null},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"nvm install-latest-npm (10)","conclusion":null},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (9)","conclusion":null},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (8)","conclusion":null},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (7)","conclusion":null},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (6)","conclusion":null},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (5)","conclusion":null},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (4)","conclusion":null},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (3)","conclusion":null},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (2)","conclusion":null},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"nvm install-latest-npm (1)","conclusion":null},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (9.2)","conclusion":null},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (9.1)","conclusion":null},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (9.0)","conclusion":null},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (6.1)","conclusion":null},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (5.9)","conclusion":null},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (4.6)","conclusion":null},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (4.5)","conclusion":null},{"__typename":"CheckRun","status":"QUEUED","name":"nvm install-latest-npm (4.4)","conclusion":null},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"nvm install-latest-npm (0.12)","conclusion":null},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"nvm install-latest-npm (0.10)","conclusion":null},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"doctoc","conclusion":null},{"__typename":"CheckRun","status":"COMPLETED","name":"Cygwin nvm install","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Debian, --lts)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"test_naming","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Debian, --lts, script)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Debian, 14)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Debian, 14, script)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Debian, 12)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Debian, 12, script)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Debian, 11)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Debian, 11, script)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Debian, 10)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Debian, 10, script)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Alpine, --lts)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Alpine, --lts, script)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Alpine, 14)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Alpine, 14, script)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Alpine, 12)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Alpine, 12, script)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Alpine, 11)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Alpine, 11, script)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Alpine, 10)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"COMPLETED","name":"WSL nvm install (Alpine, 10, script)","conclusion":"SUCCESS"},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"WSL nvm install (Ubuntu-18.04, --lts)","conclusion":null},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"WSL nvm install (Ubuntu-18.04, --lts, script)","conclusion":null},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"WSL nvm install (Ubuntu-18.04, 14)","conclusion":null},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"WSL nvm install (Ubuntu-18.04, 14, script)","conclusion":null},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"WSL nvm install (Ubuntu-18.04, 12)","conclusion":null},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"WSL nvm install (Ubuntu-18.04, 12, script)","conclusion":null},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"WSL nvm install (Ubuntu-18.04, 11)","conclusion":null},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"WSL nvm install (Ubuntu-18.04, 11, script)","conclusion":null},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"WSL nvm install (Ubuntu-18.04, 10)","conclusion":null},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"WSL nvm install (Ubuntu-18.04, 10, script)","conclusion":null},{"__typename":"CheckRun","status":"IN_PROGRESS","name":"Travis CI - Pull Request","conclusion":null}]}},"associatedPullRequests":{"edges":[]}}} How is it unable to infer the PR? |
When I ran it with |
e49b6fe
to
325b948
Compare
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've rebased this, and will try it out soon, and either provide feedback or land it :-)
325b948
to
c23c65e
Compare
(I think #37 needs to be addressed before I can properly test this) |
Unfortunately landing #40 seems to have made this PR a bit tricky to rebase. @Green-Ranger11 or @MeghalBisht, want to take a crack at it? |
Changes will have to be made to |
@Green-Ranger11 any update on rebasing this? I often need the |
c23c65e
to
5ac4982
Compare
I've given it a shot and had to make some changes to the query. I've also added a flag |
So if you add the |
5ac4982
to
848a8db
Compare
848a8db
to
988a6c1
Compare
One other thing is the |
The intention is that with the commit flag, both are checked. |
I'll add that in to check both pr checks and commit checks |
85a9c34
to
615b7d0
Compare
utils/evaluatePending.js
Outdated
|
||
return pending.length; | ||
return pullRequestPending.length === 0 ? false : true || commitRequestPending; |
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.
this reads a bit confusingly; can it be restated to avoid the false/true and/or the ternary+or?
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 I'll refactor it into a way that is readable in the next commit.
utils/watch.js
Outdated
@@ -7,7 +7,7 @@ module.exports = async function watch(retryDelay, getResponse) { | |||
|
|||
const pendingChecks = evaluatePending(response); | |||
|
|||
if (pendingChecks === 0) { | |||
if (!pendingChecks) { |
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 prefer the comparison to zero; it’s more obvious what value pendingChecks contains
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.
Because we now also have commit checks I can't equate it to zero. What if I rename it to isPendingChecks
? Or I could just return both values from evaluatePending()
Thoughts?
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.
Ah, if it’s a boolean then an “is” prefix works fine.
615b7d0
to
9e65a6a
Compare
Closes #20
When
--commit
flag is specified, status of commits are checked forsuccess
,failure
orpending
.Need some discussion around the point mentioned in the issue
--commit
flag would show the status of commits but the PR mergeable logic stays the same.(
--commit
can be considered as a flag to see the status of commits as well maybe? But not change the logic of mergeable PRs)