We are currently in the process of setting up a monorepo with Bazel with the intent of it eventually hosting all of our applications. I’m doing some explorations around CI, release, and deployment strategies the repository. There is some solid prior art of setting up a CI system for Bazel monorepo (buildci.py/ci.sh) and a derivative script running on Google Cloud Build has yielded positive results.
For deployments, we have a number of different deployment targets in our applications - Docker pushes, Kubernetes deployments, serverless functions, uploading binaries to a cloud bucket, Ansible scripts, etc. - and over time would like to bring them all into the main repository. I’ve started prototyping with the idea that deployments are defined as a Bazel target:
deploy_bundle(
deps = [
:all_build_labels,
:all_test_labels.
],
run = [
:first_run_target,
:second_run_target
],
)
For applications that are deployed on merge to master, each “dirty” deployment bundle from the CI run would be scheduled as its own Cloud Build job in a different project (in order to have separate permissions for the service account) i.e.:
for label in bazel query 'kind("deployment_bundle", rdeps(//..., set(dirty files))’
gcloud gcloud builds submit ... --substitutions DEPLOY_BUNDLE=${label} --config deploy.yaml
We would also provide a release script as some apps will want specific release branches and/or manual deploys. Infrastructure changes have their own Terraform based workflow, so I'm excluding those from the scope here for now.
I haven’t seen anything in open source that accomplishes similar goal. After playing around with this a bit, I did find the chapter in the SRE book on Rapid which seems to have a similar workflow. Any thoughts, references, or in flight initiatives that would be helpful here? Thanks.