Skip to content
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

Report URLs of pending status checks #138

Merged
merged 1 commit into from
Jul 22, 2022
Merged

Conversation

alex-mckenna
Copy link

This PR allows hoff to report the target_url of pending builds, giving users an indication of which job hoff is waiting for. This is shown both as a comment on the PR, and an additional link in the headline for pull requests where a CI URL is available (i.e. pending and failed jobs, since we don't currently keep the URL of succeeded jobs).

Screenshots:
Screenshot from 2022-07-21 15-15-17

Screenshot from 2022-07-21 15-15-07

I'm slightly unsure if this will actually go off in practice. This info is given when the build status changes to pending with a non-null target_url, but I have no concrete intuition for when this would occur in practice. I'm hoping when the status check starts it will change the state from BuildPending Nothing to BuildPending (Just url).

Closes #26
Closes #109

Copy link

@rudymatela rudymatela left a comment

Choose a reason for hiding this comment

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

Nice. Other than the typo and minor indenting issues I found, looks good to me. 👍

src/Logic.hs Outdated
Comment on lines 549 to 550
-- Sometimes we want to leave an informative comment on the PR. This isn't for things
-- that require uesr feedback like build failures.

Choose a reason for hiding this comment

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

itym user:

Suggested change
-- Sometimes we want to leave an informative comment on the PR. This isn't for things
-- that require uesr feedback like build failures.
-- Sometimes we want to leave an informative comment on the PR. This isn't for things
-- that require user feedback like build failures.

Comment on lines +239 to +248
case integrationStatus pullRequest of
Integrated _ (BuildPending (Just ciUrl)) -> do
span " | "
a ! href (toValue ciUrl) $ "View in CI"

Integrated _ (BuildFailed (Just ciUrl)) -> do
span " | "
a ! href (toValue ciUrl) $ "View in CI"

_ -> pure ()

Choose a reason for hiding this comment

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

Awesome... and pretty handy!

Copy link

Choose a reason for hiding this comment

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

While reading the original issues I found something to improve.

Instead of just "View in CI", maybe it would be better to have: "🟡 build pending" and "❌ build failed " as the link labels for each case. So one can see the status without clicking the links.

NVM, the PRs are already separated by category.

Comment on lines 124 to 127
event=
commit="$1"
state="$2"
target="$3"

Choose a reason for hiding this comment

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

Code is misaligned here due to a mix of tabs and spaces. Changing the 8 spaces before target to a tab fixes it:

Suggested change
event=
commit="$1"
state="$2"
target="$3"
event=
commit="$1"
state="$2"
target="$3"

Comment on lines 130 to 139
[ -n "$state" ] || state=success

# If this is a URL make sure it has quote marks, if null make sure it doesn't.
if [ -z "$target" ]; then
target="null"
else
target="\"$target\""
fi

event="status"

Choose a reason for hiding this comment

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

Code is misaligned here as well due to spaces instead of tabs:

Suggested change
[ -n "$state" ] || state=success
# If this is a URL make sure it has quote marks, if null make sure it doesn't.
if [ -z "$target" ]; then
target="null"
else
target="\"$target\""
fi
event="status"
[ -n "$state" ] || state=success
# If this is a URL make sure it has quote marks, if null make sure it doesn't.
if [ -z "$target" ]; then
target="null"
else
target="\"$target\""
fi
event="status"

Comment on lines -1634 to +1652
event `shouldBe` (BuildStatusChanged (Sha "b26354") Project.BuildPending)
event `shouldBe` (BuildStatusChanged (Sha "b26354") (Project.BuildPending (Just "https://travis-ci.org/rachael/owl/builds/1982")))

Choose a reason for hiding this comment

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

Nice. The test fixture was already there. :-)

@rudymatela rudymatela requested review from rudymatela and removed request for rudymatela July 21, 2022 14:51
Comment on lines +239 to +248
case integrationStatus pullRequest of
Integrated _ (BuildPending (Just ciUrl)) -> do
span " | "
a ! href (toValue ciUrl) $ "View in CI"

Integrated _ (BuildFailed (Just ciUrl)) -> do
span " | "
a ! href (toValue ciUrl) $ "View in CI"

_ -> pure ()
Copy link

Choose a reason for hiding this comment

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

While reading the original issues I found something to improve.

Instead of just "View in CI", maybe it would be better to have: "🟡 build pending" and "❌ build failed " as the link labels for each case. So one can see the status without clicking the links.

NVM, the PRs are already separated by category.

@rudymatela
Copy link

I'm slightly unsure if this will actually go off in practice. This info is given when the build status changes to pending with a non-null target_url, but I have no concrete intuition for when this would occur in practice. I'm hoping when the status check starts it will change the state from BuildPending Nothing to BuildPending (Just url).

For this, I think GitHub sends a BuildPending hook again with the build URL when it gets one. But I think you've already figured this out because I saw your changes on send-webhook which deal with this.

@rudymatela rudymatela self-requested a review July 21, 2022 15:01
Copy link

@rudymatela rudymatela left a comment

Choose a reason for hiding this comment

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

LGTM! (modulo minor fixes)

@rudymatela
Copy link

Btw, I reverted the broken merge of yesterday. So feel free to rebase and merge this into master now if you like.

I saw this created a few conflicts with your files (as your change was already based on top of mine). I'm sorry about that 😔. I reviewed the conflicts though, and they seem to be not major. :-)

@alex-mckenna
Copy link
Author

Okay, the rebase was mostly mechanical apart from the handleBuildStatusChanged which was a little different after the revert for some reason. I changed the PR to be in the style of the reverted version so give it a once over in case anything dumb crept in

Copy link

@rudymatela rudymatela left a comment

Choose a reason for hiding this comment

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

LGTM.

src/Logic.hs Outdated
Comment on lines 540 to 541
-- Sometimes we want to leave an informative comment on the PR. This isn't for things
-- that require uesr feedback like build failures.

Choose a reason for hiding this comment

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

s/uesr/user/

Suggested change
-- Sometimes we want to leave an informative comment on the PR. This isn't for things
-- that require uesr feedback like build failures.
-- Sometimes we want to leave an informative comment on the PR. This isn't for things
-- that require user feedback like build failures.

Copy link
Author

Choose a reason for hiding this comment

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

in case anything dumb crept in

Hey look, something dumb

Choose a reason for hiding this comment

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

😂 😅

@rudymatela rudymatela added the enhancement New feature or request label Jul 22, 2022
@alex-mckenna
Copy link
Author

@OpsBotPrime merge on friday

@OpsBotPrime
Copy link

Pull request approved for merge by @alex-mckenna, rebasing now.

@OpsBotPrime
Copy link

Rebased as b4994ca, waiting for CI …

@OpsBotPrime OpsBotPrime merged commit b4994ca into master Jul 22, 2022
@OpsBotPrime OpsBotPrime deleted the report-ci-run-link branch July 22, 2022 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants