dev/ci: add IfReadyForReview for Chromatic, sg ci for PR builds
Created by: bobheadxi
Closes https://github.com/sourcegraph/sourcegraph/pull/30339
This PR adds a new SteptOpt
, IfReadyForReview()
, that only enables a step if a commit is attached to a pull request and that pull request is ready for review, and adds sg ci status
support for indicating this information.
The Chromatic step now uses IfReadyForReview()
if the step is not configured to autoAcceptChanges
(which implies the main
branch at the moment). Semantically I believe this makes sense too - can't auto accept changes if you don't generate them in the first place, so we ensure they do get generated
I've updated the Buildkite settings based on the notes in https://github.com/sourcegraph/sourcegraph/pull/30339 - after testing this out, it seems that new builds created will aggressively cancel previous builds. We also won't get duplicate builds building branch commits and PRs.
- on pull request creation, a PR build is created. From henceforth, only PR builds are created for pushes to a branch.
- on pull request conversion into "ready for review", a new PR build is created, cancelling all previous builds
Examples
- draft PR build excludes the chromatic step, and gets cancelled by subsequent PR-ready build: https://buildkite.com/sourcegraph/sourcegraph/builds/127865
❯ go run ./dev/sg ci status --build 127865 | grep 'PR\|skipped'
PR: https://github.com/sourcegraph/sourcegraph/pull/30375
- [skipped] :chromatic: Upload Storybook to Chromatic
- review ready PR includes the chromatic step: https://buildkite.com/sourcegraph/sourcegraph/builds/127866