sourcegraph/dev/bkstats
Bolaji Olajide 20b858f6c3
fix(build-tracker): Failed back-compat doesn't count towards branch-locking quota (#63911)
Closes
[DINF-51](https://linear.app/sourcegraph/issue/DINF-51/failed-back-compat-doesnt-count-towards-branch-locking-quota)

## Context

If a back-compat step on main fails, the build is marked as having
failed. However, we don't treat that as a failure in build-tracker,
resulting in no #buildkite-main post and not counting towards failed
build quota for locking main.

The reason why this was happening is that the Backcompat build wasn't
linked to the main Sourcegraph build in anyway. However, when a
backcompat fails the main build reflects the status of this failure, but
we do not use this field when determining the status of a build, so it
doesn't work for our use case.

![CleanShot 2024-07-18 at 15 04
15@2x](https://github.com/user-attachments/assets/9553330a-ad98-45cc-b4ce-03a22ca1b99d)

We [instead do a walkthrough of all the jobs associated with a build to
figure
out](https://sourcegraph.sourcegraph.com/github.com/sourcegraph/sourcegraph/-/blob/dev/build-tracker/main.go?L349-372)
if the build has failed, fixed or is passing.

With this logic, it means we have to link the steps from child builds
that a particular build triggers to it's parent.

## Test plan

* Create a build that'll have backcompat failing
* The build tracker event associated with the main build will be
reported with a state of failed to buildkite.

![CleanShot 2024-07-18 at 15 10
45@2x](https://github.com/user-attachments/assets/1bf503ab-0020-47bf-9512-b3a9ee5d4e36)


## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-25 06:45:09 -05:00
..
BUILD.bazel bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
main.go fix(build-tracker): Failed back-compat doesn't count towards branch-locking quota (#63911) 2024-07-25 06:45:09 -05:00
OWNERS chore: links/ownership devx->dev-infra (#58999) 2023-12-14 15:07:20 +00:00
README.md chore: links/ownership devx->dev-infra (#58999) 2023-12-14 15:07:20 +00:00
run.sh Fix bkstats handling of empty details, clarify CLI parameters (#29357) 2021-12-29 11:25:52 +01:00

Bkstats

A crude script to compute simple "red time" statistics from our Buildkite pipelines and post them to Slack. Owned by the DevInfra team.

"Red time" is defined to be the duration from the end of a failed build to the end of the first subsequent green build.

For more detailed analyses over longer periods of time, check out buildchecker history.

Usage

$ go run main.go -buildkite.token $BUILDKITE_API_TOKEN -date 2021-10-22 -buildkite.pipeline sourcegraph
# ...
On 2021-10-22, the pipeline was red for 1h8m32.856s

Buildkite API token

  1. Go over your personal settings
  2. Create a new token with the following permissions:
  • Check sourcegraph organization
  • read_builds
  • read_pipelines