sourcegraph/.bazelrc

54 lines
2.3 KiB
Plaintext
Raw Permalink Normal View History

# Import Aspect bazelrc presets
import %workspace%/.aspect/bazelrc/bazel7.bazelrc
import %workspace%/.aspect/bazelrc/convenience.bazelrc
import %workspace%/.aspect/bazelrc/correctness.bazelrc
import %workspace%/.aspect/bazelrc/debug.bazelrc
import %workspace%/.aspect/bazelrc/javascript.bazelrc
import %workspace%/.aspect/bazelrc/performance.bazelrc
import %workspace%/.aspect/bazelrc/rules_ts.bazelrc
Build images end-to-end using Bazel v2 (#61845) * wip * gitserver (mostly) wolfi 4 bazel * the big heck of all things * Add rules_apko lock translation rules to WORKSPACE * Call apko_repositories() more * fix rules_apko to handle our shorter repo urls * fix workspace from rebase, and missing locks * visibility on wolfi_base_image * hand-fix a lock coz apko lock is :b:roken * remove chainguard repo+keyring from base * update locks * add chainguard repo+keychain to single server manifest * unrelated fixes, server+grafana still h*cked * fix postgres-exporter * the big fix * aws lib got bumped? * downgrade sso-oidc? idk * ignore wolfi locks from prettier * dynamically do the locks with a reporule * document and make nice :nails: * bazel run @rules_apko//apko patch * Fix .typo.typo * Update tooling for end-to-end Bazel images (#61106) * Update sg wolfi image to build using Bazel * bazel run @rules_apko//apko patch * Fix .typo.typo * Add update-images and implement apko YAML change monitoring * Use bazel apko and add support for additional repos * Refactor sg wolfi * Rework wolfi base image auto-update pipeline * sg bazel configure * [rough] Add --check flag to sg wolfi lock * Refactor sg wolfi lock --check * Simplify check and update apko lock hash operations * Fix resolveImagePath when running in bazel * Fixup logic error in CheckApkoLockHashes * Tweak DoBaseImageBuild output * Remove debug output * Fix sg wolfi lock --check behaviour for all images * Replace base image build step with apko lock --check * Remove debug line * Minor fixups for CI step * Wrap with AnnotatedCmd * Fixup annotation * Update apko lockfiles * Allow additional repos to be passed * Update build-base-image.sh with bazel + add back to pipeline * Ensure that modified base images are rebuilt * Solve bazelception * Remove timestamp for bit-level reproducibility * Skip local keygen when running on buildkite * Add workaround for lack of local repo support in rules_apko * Run apkoOps first as it's quick and might fail * Remove blocking allBaseImagesBuilt step * Remove unused promethus-gcp image * Add special cases to resolveImagePath * Cleanly handle case where no bazel build path exists This could happen in cases where a base image is only used outside of sourcegraph/sourcegraph, or if you've added a new base image config but haven't added the associated Bazel scaffolding * Add debugging around failing docker builds * More debugging * Normalise apko_lockfile to match repo.bzl * Fixup apko docker call * Try passing imageconfigdir differently to docker * Run ls in different container * Soft-fail when using legacy build in Buildkite * Add missing include * Workaround for building sourcegraph and sourcegraph-dev * Add postgresql-client package to server This contains createdb, which was recently moved from postgresql * Inflate postgres-12-codeinsights image to avoid rules_apko errors * Remove update line from yaml files * Fix issue caused by moving base sourcegraph image * Remove apk-tools from server * Update lockfiles * Address review feedback * Remove debug lines * fix unbound var --------- Co-authored-by: Noah Santschi-Cooney <noah@santschi-cooney.ch> * go mod tidy + gazelle-update-repos after merging main * Use aspect bazel cache * Use Aspect bazel caching when calling bazel in bash and sg * Append annotation * Run apko lock on aspect agent * Remove base image builds Discussion in https://sourcegraph.slack.com/archives/C05EVRLQEUR/p1712307465660509 * Remove unused functionality * Update BaseImageConfig comments * Rewrite wolfi-images/README.md * Add .apko/range.sh to .gitattributes * Remove "wolfi" from :base_image and :base_tarball targets * remove allowlist extras from debugging * Tweak user instructions around package testing * Add agent healthcheck to buildkite scripts * prettier * sg bazel configure * bazel run //:gazelle-update-repos --------- Co-authored-by: Noah Santschi-Cooney <noah@santschi-cooney.ch> Co-authored-by: Noah S-C <noah@sourcegraph.com>
2024-04-12 15:18:43 +00:00
try-import %workspace%/.apko/.bazelrc
### YOUR PROJECT SPECIFIC SETTINGS GO HERE ###
# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`.
# This file should appear in `.gitignore` so that settings are not shared with team members. This
# should be last statement in this config so the user configuration is able to overwrite flags from
# this file. See https://bazel.build/configure/best-practices#bazelrc-file.
try-import %workspace%/.aspect/bazelrc/user.bazelrc
# Enable bazel hack for autogold; apply to both build & test to avoid busting analysis cache
build --test_env=ENABLE_BAZEL_PACKAGES_LOAD_HACK=true
# Except in CI run E2E tests in headless mode
try-import %workspace%/user.bazelrc
# Some special sauce for the special NixOS users in your life :) set by dev-shell shell-hook
try-import %workspace%/.bazelrc-nix
Switch to OCI/Wolfi based image (#52693) This PR ships our freshly rewritten container images built with rules_oci and Wolfi, which for now will only be used on S2. *What is this about* This work is the conjunction of [hardening container images](https://github.com/orgs/sourcegraph/projects/302?pane=issue&itemId=25019223) and fully building our container images with Bazel. * All base images are now distroless, based on Wolfi, meaning we fully control every little package version and we won't be subject anymore to Alpine maintainers dropping a postgres version for example. * Container images are now built with `rules_oci`, meaning we don't have Dockerfile anymore, but instead created through [Bazel rules](https://sourcegraph.sourcegraph.com/github.com/sourcegraph/sourcegraph@bzl/oci_wolfi/-/blob/enterprise/cmd/gitserver/BUILD.bazel). Don't be scared, while this will look a bit strange to you at first, it's much saner and simpler to do than our Dockerfiles and their muddy shell scripts calling themselves in cascade. :spiral_note_pad: *Plan*: *1/ (NOW) We merge our branch on `main` today, here is what it does change for you :point_down::skin-tone-3::* * On `main`: * It will introduce a new job on `main` _Bazel Push_, which will push those new images on our registries with all tags prefixed by `bazel-`. * These new images will be picked up by S2 and S2 only. * The existing jobs building docker images and pushing them will stay in place until we have QA'ed them enough and are confident to roll them out on Dotcom. * Because we'll be building both images, there will be more jobs running on `main`, but this should not affect the wall clock time. * On all branches (so your PRs and `main`) * The _Bazel Test_ job will now run: Backend Integration Tests, E2E Tests and CodeIntel QA * This will increase the duration of your test jobs in PRs, but as we haven't removed yet the `sg lint` step, it should not affect too much the wall clock time of your PRs. * But it will also increase your confidence toward your changes, as the coverage will vastly increased compared to before. * If you have ongoing branches which are affecting the docker images (like adding a new binary, like the recent `scip-tags`, reach us out on #job-fair-bazel so we can help you to port your changes. It's much much simpler than before, but it's going to be unfamiliar to you). * If something goes awfully wrong, we'll rollback and update this thread. *2/ (EOW / Early next week) Once we're confident enough with what we saw on S2, we'll roll the new images on Dotcom.* * After the first successful deploy and a few sanity checks, we will drop the old images building jobs. * At this point, we'll reach out to all TLs asking for their help to exercise all features of our product to ensure we catch any potential breakage. ## Test plan <!-- All pull requests REQUIRE a test plan: https://docs.sourcegraph.com/dev/background-information/testing_principles --> * We tested our new images on `scale-testing` and it worked. * The new container building rules comes with _container tests_ which ensures that produced images are containing and configured with what should be in there: [example](https://sourcegraph.sourcegraph.com/github.com/sourcegraph/sourcegraph@bzl/oci_wolfi/-/blob/enterprise/cmd/gitserver/image_test.yaml) . --------- Co-authored-by: Dave Try <davetry@gmail.com> Co-authored-by: Will Dollman <will.dollman@sourcegraph.com>
2023-06-02 10:12:52 +00:00
# Used to locally cross compile, when targeting docker images
bazel: use transitions to apply cross-compile platform automatically to oci_image (#60569) Removes the need to pass `--config=docker-darwin` through the following mechanisms: 1. `--enable_platform_specific_config` to enable certain flags on macos only e.g. `--extra_toolchains @zig_sdk//toolchain:linux_amd64_gnu.2.34` and `--sandbox_add_mount_pair=/tmp` (see [.bazelrc change](https://github.com/sourcegraph/sourcegraph/pull/60569/files?file-filters%5B%5D=dotfile&show-viewed-files=true)) 2. Apply a transition (using https://github.com/fmeum/with_cfg.bzl, please view [the following great video on it](https://www.youtube.com/watch?v=U5bdQRQY-io)) on `oci_image` targets when on the `@platforms//os:macos` platform to transition to the `@zig_sdk//platform:linux_amd64` platform. - This will start at `oci_image` targets and propagate down to e.g. `go_{binary,library}` etc targets with the "transitioned" platform configuration, resulting in them being built with the transitioned-to platform 3. Remove `darwin_docker_e2e_go` config_setting and `darwin-docker` bool_flag. - These aren't necessary anymore, as the places where these were used were not in the transitive closure rooted at an `oci_image` target, meaning they wouldn't be transitioned. To review, view [the following (filtered) files](https://github.com/sourcegraph/sourcegraph/pull/60569/files?file-filters%5B%5D=.bzl&file-filters%5B%5D=.sh&file-filters%5B%5D=.yaml&file-filters%5B%5D=No+extension&file-filters%5B%5D=dotfile&show-viewed-files=true) along with [the root BUILD.bazel](https://github.com/sourcegraph/sourcegraph/pull/60569/files#diff-7fc57714ef13c3325ce2a1130202edced92fcccc0c6db34a72f7b57f60d552a3). All the other files are just changing the `load` statements from `@rules_oci` to `//dev:oci_defs.bzl` ## Test plan CI, checked image locally and `sg test bazel-backend-integration` & `sg test bazel-e2e`
2024-02-20 13:57:56 +00:00
common --enable_platform_specific_config
common:macos --extra_toolchains @zig_sdk//toolchain:linux_amd64_gnu.2.34
common:macos --sandbox_add_mount_pair=/tmp
common:macos --experimental_inprocess_symlink_creation
# Helper to run only fast go unit tests
test:go-short --test_tag_filters=go --test_timeout_filters=short
# Helper to run go tests verbosely, useful for debugging test timeouts
test:go-verbose-test --test_env=GO_TEST_WRAP_TESTV=1
# .aspect/bazelrc/correctness.bazelrc sets this, but this breaks with a lot of Go external deps, so
# we instead disable it.
common --noincompatible_disallow_empty_glob
2024-05-02 12:56:45 +00:00
# Ensure clippy and rustfmt run for Rust targets
build --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect
build --output_groups=+clippy_checks
2024-05-02 12:56:45 +00:00
build --aspects=@rules_rust//rust:defs.bzl%rustfmt_aspect
build --output_groups=+rustfmt_checks
build --@rules_rust//:rustfmt.toml=//docker-images/syntax-highlighter:rustfmt.toml
common --noenable_bzlmod