Skip to content

Comments

No-Deploy-Friday-Nudge #56#95

Merged
OpsBotPrime merged 15 commits intomasterfrom
no-deploy-friday
Dec 17, 2021
Merged

No-Deploy-Friday-Nudge #56#95
OpsBotPrime merged 15 commits intomasterfrom
no-deploy-friday

Conversation

@xrvdg
Copy link

@xrvdg xrvdg commented Dec 13, 2021

This pull request adds (non-configurable) No-Deploy-Friday-Nudge functionality (#56) to Hoff.

Copy link

@ReinierMaas ReinierMaas left a comment

Choose a reason for hiding this comment

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

The overall design looks good to me. I just have style pointers but nothing really major. Using the free monad to encapsulate getting the timestamps nicely abstracts it for the testing! And the additional tests also look extensive.

src/Logic.hs Outdated
Comment on lines 422 to 433
isApproved <-
if isJust approvalType
then isReviewer author
else pure False
day <- dayOfWeek . utctDay <$> getDateTime
if isApproved
then -- The PR has now been approved by the author of the comment.

case fromJust approvalType of
approval | isMergeOnFriday approval || day /= Friday -> handleCommentAdded' projectConfig prId author state pr approval
other -> do
() <- leaveComment prId ("Merging is not allowed on Fridays. To override this behaviour use the command `" `Text.append` Pr.displayApproval other `Text.append` " on Friday`.")

Choose a reason for hiding this comment

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

Text can be appended with <>. I also see that the lines are quite long we normally restrict this to 100 chars width.


We can combine these multiple if and case statements. When a pull request is approved you know that the fromJust won't fail.

case isApproved of
  True | your filter here -> handleCommentAdded
  True -> leave comment
  False -> pure state

Choose a reason for hiding this comment

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

Should we allow merge on Friday on other days?

Copy link
Member

@fatho fatho left a comment

Choose a reason for hiding this comment

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

Your first PR 🎉 Besides Reinier's remarks, I think the design can also still be simplified/future-proofed (see below).

src/Logic.hs Outdated
-- reversed all "merge and xxx" commands would be detected as a Merge
-- command.
cases =
[ (" merge and deploy on friday", MergeAndDeployOnFriday),
Copy link
Member

Choose a reason for hiding this comment

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

A minor thing: I wonder if "on" is a good choice of words here, as it could be mistaken for a scheduled merge (which we don't support). Maybe "even on"? Not really sure, would otherwise also be fine.

if isJust approvalType
then isReviewer author
else pure False
day <- dayOfWeek . utctDay <$> getDateTime
Copy link

Choose a reason for hiding this comment

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

This gets the date in the UTC time zone. It will be Friday two hours later in Europe/Amsterdam than in UTC when DST is in effect. Is that intentional? (And also, does it make sense to pick midnight as the boundary? Is Saturday 04:00 an okay time to merge things?)

Choose a reason for hiding this comment

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

Thanks for the feedback. What would be your proposal for updating the nudge? Should we detect whether it is Friday Anywhere on Earth? (Start at UTC+14 / End at UTC-12)
Using AoE as the dedicated time range would already disallow the merge to proceed on Thursday afternoon in Europe/Amsterdam when DST is in effect. Which might be a valid moment for the stop merging nudge.

Copy link
Member

Choose a reason for hiding this comment

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

Good point about the timezone! I think just detecting Friday at our location is good enough (maybe the timezone could be made configurable, but that's about it).

Is Saturday 04:00 an okay time to merge things

It is not. But the feature is intended as a guardrail against accidents, not a foolproof method of preventing all untimely merges, and I'd just assume that there won't be accidental merges on Saturday at 04:00.

We might want to just cover the whole weekend, but I think nighttime can be ignored for the moment.

Copy link

Choose a reason for hiding this comment

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

What would be your proposal for updating the nudge?

If it’s just a nudge on Fridays for people working in Europe/Amsterdam, I would just ignore the issue and keep it like this.

At the expense of scope creep, maybe a nicer solution that also covers the weekend is to provide a time range in the configuration file. It could include a start day of week + time of day and an end day of week + time of day, and a time zone in which to interpret them.

@xrvdg xrvdg requested review from ReinierMaas and fatho December 16, 2021 10:51
@channable channable deleted a comment from ReinierMaas Dec 16, 2021
Copy link
Member

@fatho fatho left a comment

Choose a reason for hiding this comment

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

Just some small things from my side:

src/Logic.hs Outdated
pure state
(other, OnFriday) -> do
() <- leaveComment prId ("Your merge request has been denied because \
\it not Friday. Run " <>
Copy link
Member

Choose a reason for hiding this comment

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

s/it not/it is not/

(other, OnFriday) -> do
() <- leaveComment prId ("Your merge request has been denied because \
\it not Friday. Run " <>
Pr.displayApproval other <> " instead")
Copy link
Member

Choose a reason for hiding this comment

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

Good idea rejecting this as well so that people don't get conditioned to just always using the more powerful command 👍

src/Logic.hs Outdated
Comment on lines 426 to 427
-- For now Friday at UTC+0 is good enough.
-- See https://github.com/channable/hoff/pull/95 for caveats and improvement ideas.
Copy link
Member

Choose a reason for hiding this comment

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

Can you open a new hoff issue about potentially making this more configurable (e.g. the timezone and the range)?
Then we'll also immediately have a good first issue for the next person joining :-)

Copy link

@ReinierMaas ReinierMaas left a comment

Choose a reason for hiding this comment

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

LGTM! After resolving Fabians comments and one nit. Thanks for implementing this!

src/Logic.hs Outdated
-- If the pull request is not in the state, ignore the comment.
Nothing -> pure state

handleMergeRequested :: ProjectConfiguration -> PullRequestId -> Username -> ProjectState -> PullRequest -> ApprovedFor -> Action ProjectState

Choose a reason for hiding this comment

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

Nit: this line is very long.

@xrvdg
Copy link
Author

xrvdg commented Dec 17, 2021

@OpsBotPrime merge

@OpsBotPrime
Copy link

Pull request approved for merge by @xrvdg, rebasing now.

Approved-by: xrvdg
Auto-deploy: false
@OpsBotPrime
Copy link

Rebased as 991e117, waiting for CI …

@OpsBotPrime OpsBotPrime merged commit 991e117 into master Dec 17, 2021
@OpsBotPrime OpsBotPrime deleted the no-deploy-friday branch December 17, 2021 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants