This PR is a result/followup of the improvements we've made in the [SAMS repo](https://github.com/sourcegraph/sourcegraph-accounts/pull/199) that allows call sites to pass down a context (primarily to indicate deadline, and of course, cancellation if desired) and collects the error returned from `background.Routine`s `Stop` method. Note that I did not adopt returning error from `Stop` method because I realize in monorepo, the more common (and arguably the desired) pattern is to hang on the call of `Start` method until `Stop` is called, so it is meaningless to collect errors from `Start` methods as return values anyway, and doing that would also complicate the design and semantics more than necessary. All usages of the the `background.Routine` and `background.CombinedRoutines` are updated, I DID NOT try to interpret the code logic and make anything better other than fixing compile and test errors. The only file that contains the core change is the [`lib/background/background.go`](https://github.com/sourcegraph/sourcegraph/pull/62136/files#diff-65c3228388620e91f8c22d91c18faac3f985fc67d64b08612df18fa7c04fafcd). |
||
|---|---|---|
| .. | ||
| build | ||
| config | ||
| notify | ||
| .gitignore | ||
| background.go | ||
| bigquery.go | ||
| BUILD.bazel | ||
| image_test.yaml | ||
| integration_test.go | ||
| main_test.go | ||
| main.go | ||
| mocks_test.go | ||
| README.md | ||
| server_test.go | ||
BUILD TRACKER
Build Tracker is a server that listens for build events from Buildkite and stores them in memory and sends notifications about builds if they've failed.
The server currently listens for two events:
build.finishedjob.finished
For each job.finished event that is received, the corresponding build is updated with the job that has finished. On receipt of a build.finished event, the server will determine if the build has failed by going through all the contained jobs of the build. If one or more jobs have indeed failed, a notification will be sent over slack.
Deployment infrastructure
Build Tracker is deployed in the Buildkite kubernetes cluster of the Sourcegraph CI project on GCP. For more information on the deployment see infrastructure
Build
Execute the build.sh script which will build the docker container and push it to correct GCP registry. Once the image has been pushed the pod needs to be restarted so that it can pick up the new image!
Test
To run the tests execute go test .
Notification testing
To test the notifications that get sent over slack you can pass the flag -RunSlackIntegrationTest as part of your test invocation, with some required configuration:
export SLACK_TOKEN='my valid token'
export BUILDKITE_WEBHOOK_TOKEN='optional'
export GITHUB_TOKEN='optional'
go test . -RunSlackIntegrationTest
You can enable Slack client debugging by exporting the following environment variable BUILD_TRACKER_SLACK_DEBUG=1