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

Improve reliability of wait-for-build #5393

Merged
merged 6 commits into from
Feb 13, 2022
Merged

Conversation

cheap-glitch
Copy link
Member

Fixes #5336
Hopefully fixes #5023

Test URLs

The feature should NOT run here:

Videos

Successful CI
successful.mp4
Failing CI
failing.mp4

Copy link
Member Author

@cheap-glitch cheap-glitch left a comment

Choose a reason for hiding this comment

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

This PR doesn't fundamentally changes how wait-for-build works, but it makes its internals rely on the DOM as little as possible:

  1. The checkbox will appear if there's at least one commit with a CI icon, and the icon of the latest commit is either missing or yellow.

  2. When the user clicks the merge button, the API will be queried every 5 to 10 seconds (using p-retry).

  3. The DOM is watched to cancel the operation, but only in the case of a new commit being pushed.

Also it adds more checks in the feature setup to exclude draft/merged PRs, repo with no workflows and repo with Actions disabled.

source/features/wait-for-build.tsx Outdated Show resolved Hide resolved
Comment on lines 127 to 129
// Cancel submission if a new commit was pushed
disableForm(false);
showCheckboxIfNecessary();
Copy link
Member Author

Choose a reason for hiding this comment

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

The current mechanism goes like this:

  • the DOM observer is (hopefully) triggered when a new commit is pushed
  • it enables the merge form again
  • up to 10 seconds later, the "API watcher" sees the form has been enabled and stops

This feels needlessly roundabout. Having sindresorhus/p-retry#53 would be a much cleaner solution, so I think I'll work on that next.

Copy link
Member Author

Choose a reason for hiding this comment

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

This feels needlessly roundabout. Having https://togithub.com/sindresorhus/p-retry/issues/53 would be a much cleaner solution, so I think I'll work on that next.

Opened sindresorhus/p-retry#59

source/github-helpers/pr-ci-status.ts Show resolved Hide resolved
source/github-helpers/pr-ci-status.ts Show resolved Hide resolved
Copy link
Member Author

@cheap-glitch cheap-glitch left a comment

Choose a reason for hiding this comment

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

While we're at it, how about renaming the feature wait-for-checks or wait-for-ci? "Build" is too specific imo

source/features/wait-for-build.tsx Outdated Show resolved Hide resolved
source/features/wait-for-build.tsx Outdated Show resolved Hide resolved
Copy link
Member

@fregante fregante left a comment

Choose a reason for hiding this comment

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

YOLO

@cheap-glitch cheap-glitch merged commit f45048d into main Feb 13, 2022
@cheap-glitch cheap-glitch deleted the improve-wait-for-build branch February 13, 2022 10:08
@cheap-glitch
Copy link
Member Author

Follow-up:

@kidonng
Copy link
Member

kidonng commented Feb 13, 2022

I'm not that good at (and into) reviewing but this is simply immeasurable hard work. @cheap-glitch you are a legend

Now if you accept one-time sponsorship...

@cheap-glitch
Copy link
Member Author

Thank you! Now let's hope this doesn't crash and burn 🤞

I'm not that good at (and into) reviewing

Just a quick read-through is still useful, especially on big PRs like this one, as it can help catching slip-ups like this:

console.log('Watching new commits');

(Yes I use console to debug 😳)

Now if you accept one-time sponsorship...
I've enabled it 😉

@kidonng
Copy link
Member

kidonng commented Feb 14, 2022

Just a quick read-through is still useful, especially on big PRs like this one, as it can help catching slip-ups like this:

LOL but it's fine. Consider it an easter egg and hava fun linting later 😄

(Yes I use console to debug 😳)

I do that too. Browser extension breakpoints are a pain to setup for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

wait-for-build does not result in a usable checkbox wait-for-build merges without all checks completed
3 participants