np icon indicating copy to clipboard operation
np copied to clipboard

Ensure CI has passed

Open jamestalmage opened this issue 8 years ago • 13 comments

If .travis.yml exists, use the Travis API to verify the build for the latest commit has passed (this should come after ensuring the latest commit has been pulled down).

Same thing if appveyor.yml exits, use the AppVeyor API.

Both API's provide the commit sha, so it should be fairly easy.

If the CI build is pending, it would be really cool if we just awaited the build result (instead of failing). That way you could merge a commit into master and execute np immediately, knowing it will wait for CI to finish before actually publishing.

jamestalmage avatar Jul 07 '16 22:07 jamestalmage

Cool idea! I've seen something similar done by having Travis publish on success, but this sounds much simpler and better. I don't think it should be default behavior, but rather an opt-in flag.

sindresorhus avatar Jul 07 '16 22:07 sindresorhus

You wouldn't want to check status by default? Or do you mean just the await completion part?

jamestalmage avatar Jul 07 '16 22:07 jamestalmage

The await completion part.

sindresorhus avatar Jul 07 '16 22:07 sindresorhus

Would be a cool feature. Although waiting for AppVeyor to complete? Do we really want to wait 1 hour before the module is actually being published?

SamVerschueren avatar Jul 08 '16 06:07 SamVerschueren

Do we really want to wait 1 hour before the module is actually being published?

Yep. It's a requirement for publishing AVA. That's a big part of why I want this feature. I want to hit publish and go to bed / lunch instead of hanging around that extra hour waiting on CI just so I can take the next step. (Paid Appveyor is much better BTW)

jamestalmage avatar Jul 08 '16 06:07 jamestalmage

After I typed my comment I actually realized that might be a good thing actually. So yeah, let's do it :)!

SamVerschueren avatar Jul 08 '16 06:07 SamVerschueren

I think it should await completion by default, but provide a key sequence / prompt you can use to avoid waiting (and a --skip-ci flag).

If we don't await by default what do we do if a build is pending? Fail / Pass? Awaiting it with an option to skip or exit seems to make the most sense

jamestalmage avatar Jul 08 '16 06:07 jamestalmage

Exit and show a message that it can be skipped via (something like) --skip-ci?

SamVerschueren avatar Jul 08 '16 07:07 SamVerschueren

Never mind, that doesn't make sense. I think we should await by default and add --skip-ci.

If we await for the CI, shouldn't we bypass the local cleanup/installation/testing? Seems moot then.

SamVerschueren avatar Jul 08 '16 07:07 SamVerschueren

Nah. You are doing an OSX sanity check before publishing. Also, you might be publishing days after the last CI run, and dependencies might have updated.

If you are actually awaiting CI, then chances are you've got time to run the tests locally before CI finishes

jamestalmage avatar Jul 08 '16 13:07 jamestalmage

What do you think about using the GitHub API, something like https://api.github.com/repos/sindresorhus/np/statuses/master and checking that everything is successful?

tusbar avatar Apr 09 '18 15:04 tusbar

@tusbar I think that's a better solution, yes, since it will work with any service.

sindresorhus avatar Apr 25 '18 06:04 sindresorhus

If anyone wants to work on this, please first make yourself familiar with the discussion in https://github.com/sindresorhus/np/pull/289 and use that as a starting point. There are several unanswered questions in that thread, so it would be best to discuss a solution here before starting to work on it.

sindresorhus avatar Jun 03 '21 19:06 sindresorhus