mongo/buildscripts/bazel_rules_mongo
Trevor Guidry 139bf52e29 SERVER-107417 Fix codeowners on github prs with merge commits (#38392)
GitOrigin-RevId: 8448d3e840f79da1ccce3ac9f3c6191efa59f1f5
2025-07-10 23:55:23 +00:00
..
codeowners SERVER-107417 Fix codeowners on github prs with merge commits (#38392) 2025-07-10 23:55:23 +00:00
engflow_auth SERVER-103495 skip wrapper script for certain commands (#34898) 2025-04-10 22:12:35 +00:00
scripts
tests SERVER-106428 skip TestChangedFiles test on s390x and ppc (#37457) 2025-06-18 00:14:48 +00:00
utils SERVER-107417 Fix codeowners on github prs with merge commits (#38392) 2025-07-10 23:55:23 +00:00
BUILD.bazel
OWNERS.yml SERVER-105622 Fix ownership on some correctness/build files (#36626) 2025-05-28 21:30:57 +00:00
poetry.lock SERVER-104208 Disallow any new unowned files (#35304) 2025-04-30 19:12:06 +00:00
pyproject.toml SERVER-107417 Fix codeowners on github prs with merge commits (#38392) 2025-07-10 23:55:23 +00:00
README.md SERVER-106150 Rewrite private links to public links when we sync source code from 10gen/mongo to mongodb/mongo (#37153) 2025-06-12 18:23:51 +00:00
WORKSPACE.bazel SERVER-104208 Disallow any new unowned files (#35304) 2025-04-30 19:12:06 +00:00

Bazel Rules Mongo

This directory is a bazel rule we use to ship common code between bazel repos

Using in your repo

  1. Look at the latest version in this file

  2. Get the sha of the latest release at https://mdb-build-public.s3.amazonaws.com/bazel_rules_mongo/{version}/bazel_rules_mongo.tar.gz.sha256

  3. Get the link to the latest version at https://mdb-build-public.s3.amazonaws.com/bazel_rules_mongo/{version}/bazel_rules_mongo.tar.gz

  4. Add this as a http archive to your repo and implement the dependencies listed in the WORKSPACE file. It will look something like this

# Poetry rules for managing Python dependencies
http_archive(
    name = "rules_poetry",
    sha256 = "48001b928488e78f03a47bcc712c56432a471fc6cdd90fe57c884efbfcd13696",
    strip_prefix = "rules_poetry-917630033c736c188605cf0f558c34afc1eca540",
    urls = [
        "https://github.com/mongodb-forks/rules_poetry/archive/917630033c736c188605cf0f558c34afc1eca540.tar.gz",
    ],
)

load("@rules_poetry//rules_poetry:poetry.bzl", "poetry")

http_archive(
    name = "bazel_rules_mongo",
    repo_mapping = {"@poetry": "@poetry_bazel_rules_mongo"},
    sha256 = "bb2c2dafc82d905422a12ebef41637b0a1160adffc8a5009dcd1c3d1f81b4056",
    strip_prefix = "bazel_rules_mongo",
    urls = [
        "https://mdb-build-public.s3.amazonaws.com/bazel_rules_mongo/0.1.1/bazel_rules_mongo.tar.gz",
    ],
)

load("@bazel_rules_mongo//codeowners:codeowners_validator.bzl", "codeowners_validator")

codeowners_validator()

load("@bazel_rules_mongo//codeowners:codeowners_binary.bzl", "codeowners_binary")

codeowners_binary()

poetry(
    name = "poetry_bazel_rules_mongo",
    lockfile = "@bazel_rules_mongo//:poetry.lock",
    pyproject = "@bazel_rules_mongo//:pyproject.toml",
)
  1. Use the rule however you see fit! For example to add bazel run codeowners to your repo you can add the following to your root BUILD.bazel file
alias(
    name = "codeowners",
    actual = "@bazel_rules_mongo//codeowners:codeowners",
)

Deploying

When you are ready for a new version to be released, bump the version in the pyproject.toml file. This will be deployed the next time the package_bazel_rules_mongo task runs (nightly). You can schedule this earlier in the waterfall when your pr is merged if you want it quicker.