sourcegraph/dev
Noah S-C 14123fcc42
chore(bazel): rework push_all to improve concurrency by avoiding bazel server lock (#64044)
This PR is a second attempt at improving push_all.sh, continuing on from
(and inspired by) https://github.com/sourcegraph/sourcegraph/pull/63391.
As a recap, that PR uses
[--script_path](https://bazel.build/reference/command-line-reference#flag--script_path)
to emit a short bash script for every `oci_push` target, which
essentially does minor setup + invokes the executable as if running
`bazel run`.

While the idea in https://github.com/sourcegraph/sourcegraph/pull/63391
was good, it trades concurrent server locking with an equal amount of
overhead in sequentially building the scripts. By observing the
scripts<b>[1]</b> that it would emit, we can notice a few things:
- The path
`/home/noah/.cache/bazel/_bazel_noah/8fd1d20666a46767e7f29541678514a0/execroot/__main__/bazel-out/k8-fastbuild/bin/`
shows up twice, which is the same path that `./bazel-bin` points at
- The script only `cd`'s to a path, unsets some environment variables,
and then executes the underlying script of the target.

The path can be observed to be a combination of bazel-bin, the target's
package (`//cmd/batcheshelper` in this case), as well as the target with
some extra static strings (`candidate_push` with `push_` prefix and
`.sh{,.runfiles}` suffixes for the script & its runfiles respectively).
Knowing this, and assuming that this is reliably so, we can opt to
recreate this manually instead, saving on the hefty overhead of `bazel
run --script_path`.

The current average times for `Push candidate images` and `Push final
images` are ~7m50s and ~8m30s respectively. While the example
main-dry-run build
[here](https://buildkite.com/sourcegraph/sourcegraph/builds/284041#0190e54a-9aaa-471a-81bf-623fce6ffa45)
isnt fully representative of how much rebuilding is required, it sets a
pretty solid 3m20s baseline.

Note this may break with rules_oci changes, but imo thats a small and
very infrequent cost to pay for cleaner log output + shaving a good
piece of time off.

<details><summary><b>[1]</b> A <code>--script_path</code>
example</summary>

```
#!/nix/store/mqc7dqwp046lh41dhs7r7q7192zbliwd-bash/bin/bash
cd /home/noah/.cache/bazel/_bazel_noah/8fd1d20666a46767e7f29541678514a0/execroot/__main__/bazel-out/k8-fastbuild/bin/cmd/batcheshelper/push_candidate_push.sh.runfiles/__main__ && \
  exec env \
    -u JAVA_RUNFILES \
    -u RUNFILES_DIR \
    -u RUNFILES_MANIFEST_FILE \
    -u RUNFILES_MANIFEST_ONLY \
    -u TEST_SRCDIR \
    BUILD_WORKING_DIRECTORY=/home/noah/Sourcegraph/sourcegraph \
    BUILD_WORKSPACE_DIRECTORY=/home/noah/Sourcegraph/sourcegraph \
  /home/noah/.cache/bazel/_bazel_noah/8fd1d20666a46767e7f29541678514a0/execroot/__main__/bazel-out/k8-fastbuild/bin/cmd/batcheshelper/push_candidate_push.sh "$@"
```

</details> 

## Test plan

Observe a `sg ci build main-dry-run`
[here](https://buildkite.com/sourcegraph/sourcegraph/builds/284041#0190e54a-9aaa-471a-81bf-623fce6ffa45).

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-24 16:55:09 +01:00
..
auth-provider remove more ENTERPRISE=1 remnants (#57232) 2023-10-02 10:43:11 -07:00
authtest chore: Remove client construction from SignUp/In funcs (#62789) 2024-05-21 15:18:58 +02:00
backcompat chore(ci): bump backcompat target to 5.4.0 (#62623) 2024-05-13 11:37:11 +02:00
bkstats bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
build-tracker msp/runtime: split contract into JobContract and ServiceContract (#63494) 2024-06-26 19:46:10 +00:00
buildchecker chore(ci): remove buildchecker sunday summary posts (#63289) 2024-06-17 13:05:39 +00:00
check searcher: remove unused dependency on dbconn pkg (#61463) 2024-03-28 17:11:41 +02:00
ci chore(bazel): rework push_all to improve concurrency by avoiding bazel server lock (#64044) 2024-07-24 16:55:09 +01:00
clustering Dev tool: python script for text clustering based on local embeddings (#58691) 2023-12-04 09:27:14 -05:00
codehost_testing bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
codeintel-qa chore: Remove client construction from SignUp/In funcs (#62789) 2024-05-21 15:18:58 +02:00
db scripts: dont run subshell in for loop (#60611) 2024-02-19 14:48:33 +00:00
depgraph depgraph: Fix spurious error when no subcommand name is passed (#61871) 2024-04-15 16:10:44 +02:00
deployment-lag-notifier bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
deployment-notifier fix: update links for dev docs (#62758) 2024-05-17 13:47:34 +02:00
gitserverintegration gitserver: Framework to support integration testing against gitserver (#62801) 2024-06-07 17:01:12 +02:00
go-mockgen-gazelle bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
go-mockgen-transformer bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
gqltest Search: add regex support to repo:has.meta() (#63891) 2024-07-19 11:53:24 -06:00
grafana chore: remove unused dev/sg/internal/loki (#61923) 2024-04-16 12:19:32 +00:00
insight-data-gen bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
internal/cmd bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
linearhooks chore/linearhooks: use MSP rollouts (#63556) 2024-07-01 18:24:40 +01:00
linters chore: Make location fetching queries more uniform (#64026) 2024-07-24 11:14:22 +02:00
managedservicesplatform sg/msp: enable alerting by default for production projects (#63912) 2024-07-18 20:57:38 +01:00
nix fix(nix/p4-fusion): update p4-fusion helix-api hashes (#63805) 2024-07-15 10:20:33 +02:00
perforce bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
phabricator add shellcheck & shfmt to pre-commit's pre-push hook (#59485) 2024-01-11 14:16:22 +00:00
pr-auditor Removed pr-auditor and left redirect notice (#59497) 2024-01-10 15:15:24 -08:00
prometheus telemetry-gateway: migrate to MSP runtime (#58814) 2023-12-08 12:14:34 -08:00
scaletesting bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
sg fix(ci): check command out for error when git fails (#63993) 2024-07-23 09:56:33 -05:00
src-expose chore: Change errors.HasType to respect multi-errors (#63024) 2024-06-06 13:02:14 +00:00
team bazel: native go-mockgen in Bazel (#60386) 2024-02-16 13:26:48 +00:00
tilt
tools chore(ci): instrument push_all.sh commands in honeycomb (#63350) 2024-06-19 18:16:21 +01:00
update-embeddings-list reapply "switch from jest to vitest for faster, simpler tests (#57886)" (#58145) 2023-11-07 12:00:18 +02:00
zoekt gomod: update zoekt to fix several CVEs in dependencies (#60093) 2024-02-02 15:36:04 +00:00
.gitignore
add_https_domain_to_hosts.sh
bazel_buildkite_stamp_vars.sh bazel: test volatile variables with Percy (#51693) 2023-05-11 09:20:42 +00:00
bazel_stamp_vars.sh Reapply "bazel: migrate dind dockerfile to rules_oci" (#61790) (#61824) 2024-04-12 15:52:44 +00:00
BUILD.bazel chore(codeintel): Rename uploads/../Store -> codegraph/../DataStore (#64001) 2024-07-24 08:24:20 +01:00
caddy.sh fix(sg): start Caddy admin server before caddy trust (#58928) 2023-12-20 10:03:45 +02:00
Caddyfile Add an option for disabling HTTP/2 when communicating with Cody Gateway (#59668) 2024-01-17 15:36:40 +01:00
check-test-ownership.sh feat(ci): add GHA to report when Bazel test ownership drops below 70% threshold (#62985) 2024-05-31 14:46:01 +01:00
check-tokens.sh chore(local): add FORBIDCOMMIT pragma to prevent accidental commits (#63581) 2024-07-01 18:27:26 +00:00
CLA.txt
codeinsights-db.sh
comby-install-or-upgrade.sh add shellcheck & shfmt to pre-commit's pre-push hook (#59485) 2024-01-11 14:16:22 +00:00
defs.bzl Removed unused bazel macro arg (#60996) 2024-03-11 06:36:15 -07:00
dev-sourcegraph-server.sh
docsite.sh [docsite]: bump version (#56013) 2023-08-18 12:40:44 -06:00
drop-entire-local-database-and-redis.sh
esbuild.bzl chore(bazel): enable rules_esbuild sandbox with object-inspect workaround (#61969) 2024-06-05 15:34:29 +01:00
eslint-report-test.sh Revert "revert "bazel: improve ESLint rule" (#52853)" (#52878) 2023-06-04 19:06:39 -07:00
eslint.bzl chore(bazel): fixup custom eslint test rule after bump to rules_js 2 (#63143) 2024-06-06 23:32:34 +01:00
forbidcommit.sh chore(local): add FORBIDCOMMIT pragma to prevent accidental commits (#63581) 2024-07-01 18:27:26 +00:00
foreach-non-web-client-project.sh release: drop legacy release tooling (#61220) 2024-04-09 14:29:35 -05:00
git-stats
global-settings.json Chore: remove search console (#63322) 2024-06-19 11:05:03 -06:00
go_defs.bzl build: add buildifier check to Aspect Workflows (#58566) 2023-11-27 14:58:01 +02:00
go_mockgen_rule.bzl bump to Go 1.22.1 (#60902) 2024-03-06 17:38:43 -07:00
go_mockgen.bzl bazel: native go-mockgen in Bazel (#60386) 2024-02-16 13:26:48 +00:00
go_stringer.bzl build: upgrade to Bazel 7 pre-release (#57970) 2023-10-31 15:29:14 +02:00
go-mod-update.sh
licenses.sh fix: update links for dev docs (#62758) 2024-05-17 13:47:34 +02:00
migrations.bzl bazel: add utility macro for wrapping single-file tools (#62930) 2024-05-27 16:53:51 +00:00
mocha.bzl chore(ci): remove Percy visual tests (#63515) 2024-06-27 16:20:06 +02:00
msp_delivery.bzl msp_delivery: infer pipeline id from service_id and region (#61395) 2024-03-26 15:30:27 +00:00
oci_defs.bzl bazel: transition oci_image to opt/release mode for Rust (#61740) 2024-04-15 17:19:17 +00:00
oci_deps.bzl chore(security): Updated dind image to 27-0-3 (#63725) 2024-07-09 12:59:18 -04:00
p4-fusion-dev bazel: provide p4-fusion via bazel (#58893) 2023-12-11 16:06:06 +00:00
proto.bzl fix: gazelle and proto generation (continuation of #49547) (#49713) 2023-04-11 11:36:45 +02:00
prune-pick.sh
redis-postgres.yml fix: update links for dev docs (#62758) 2024-05-17 13:47:34 +02:00
redis.conf
remote_cache_local_env.sh chore(sg): sg bazel uses remote cache by default (unless in CI) (#62245) 2024-04-29 18:56:18 +02:00
run-server-image.sh Remove HTTP for inter-service RPC (#59093) 2024-01-11 19:46:32 +01:00
sass.bzl
schema_migrations.bzl chore(rel): bump minor for stitch graph + add support invalidating migrations repo rule (#62511) 2024-05-07 22:04:59 +00:00
scip-ctags-dev local: fix scip-ctags install script (#57252) 2023-10-02 14:58:14 +00:00
scip-ctags-install.sh syntax-highlighter: initial ctags work (w/ musl scip-ctags) (#52643) 2023-05-30 17:19:39 -04:00
scip-syntax-dev highlighter: Rename scip-treesitter-cli -> scip-syntax (#60077) 2024-02-05 13:15:09 +01:00
scip-syntax-install.sh Syntactic indexing: add database schema and dbworker (#60055) 2024-02-08 18:00:21 +00:00
site-config.json Remove broken federation feature (#55161) 2023-07-20 17:30:32 +00:00
src-prof-services.json Add embeddings to server behind env var (#50288) 2023-04-04 16:45:50 +02:00
src-search-meta.sh
tool_deps.bzl chore(security) : upgrade src-cli version to address CVE (#63750) 2024-07-10 09:57:16 -04:00
tools.go dev/linearhooks: add POC (#62367) 2024-05-07 00:14:05 -07:00
universal-ctags-dev bzl: do not show full commmand line for ctags in dev (#58261) 2023-11-10 10:05:25 -05:00
write_generated_to_source_files.bzl bazel: native go-mockgen in Bazel (#60386) 2024-02-16 13:26:48 +00:00