From 55f247f03f45d660333d044463e7d18a86b0fb8a Mon Sep 17 00:00:00 2001 From: Dragos Carp Date: Fri, 30 Oct 2026 23:01:02 +0100 Subject: [PATCH 1/8] ci: automate releases and BCR publishing --- .bcr/metadata.template.json | 14 ++++ .bcr/presubmit.yml | 12 ++++ .bcr/source.template.json | 7 ++ .github/workflows/ci.yaml | 36 ++++++++-- .github/workflows/publish.yaml | 36 ++++++++++ .github/workflows/release.yaml | 113 ++++++++++++++++++++++++++++++ .github/workflows/release_prep.sh | 43 ++++++++++++ 7 files changed, 255 insertions(+), 6 deletions(-) create mode 100644 .bcr/metadata.template.json create mode 100644 .bcr/presubmit.yml create mode 100644 .bcr/source.template.json create mode 100644 .github/workflows/publish.yaml create mode 100644 .github/workflows/release.yaml create mode 100755 .github/workflows/release_prep.sh diff --git a/.bcr/metadata.template.json b/.bcr/metadata.template.json new file mode 100644 index 0000000..5b3a2e8 --- /dev/null +++ b/.bcr/metadata.template.json @@ -0,0 +1,14 @@ +{ + "homepage": "https://github.com/modular/rules_mojo", + "maintainers": [ + { + "email": "atrotta@modular.com", + "github": "Ahajha", + "name": "Alex Trotta", + "github_user_id": 44127594 + } + ], + "repository": ["github:modular/rules_mojo"], + "versions": [], + "yanked_versions": {} +} diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml new file mode 100644 index 0000000..334665b --- /dev/null +++ b/.bcr/presubmit.yml @@ -0,0 +1,12 @@ +bcr_test_module: + module_path: '.' + matrix: + bazel: ['8.x', '9.x', '10.*'] + platform: ['macos_arm64', 'ubuntu2204', 'ubuntu2404_arm64'] + tasks: + run_tests: + name: 'Run test module' + bazel: ${{ bazel }} + platform: ${{ platform }} + test_targets: + - '//...' diff --git a/.bcr/source.template.json b/.bcr/source.template.json new file mode 100644 index 0000000..966f818 --- /dev/null +++ b/.bcr/source.template.json @@ -0,0 +1,7 @@ +{ + "integrity": "", + "strip_prefix": "rules_mojo-{VERSION}", + "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/rules_mojo-{VERSION}.tar.gz", + "patch_strip": 1, + "patches": {} +} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3a17ab6..2f81169 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,14 +7,15 @@ on: branches: [main] workflow_dispatch: +permissions: + contents: read + jobs: test: name: >- ${{ matrix.mojo == 'default' && format('test ({0}, {1})', matrix.os, matrix.bazel) || format('test ({0}, {1}, {2})', matrix.os, matrix.bazel, matrix.mojo) }} - permissions: - contents: read strategy: matrix: os: @@ -24,9 +25,8 @@ jobs: bazel: - 8.x - 9.x - - latest - - last_rc - - last_green + # Unlike 10.x, 10.* includes release candidates. + - '10.*' mojo: - default include: @@ -62,7 +62,14 @@ jobs: env: USE_BAZEL_VERSION: ${{ matrix.bazel }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: bazel-contrib/setup-bazel@104e3eea9447cdaa4b00d0fb46191a3985d26ab3 # 0.19.1 + with: + bazelisk-cache: true + repository-cache: true + disk-cache: true + cache-version: ci-v1-${{ runner.os }}-${{ runner.arch }}-${{ matrix.bazel }} + cache-save: ${{ github.event_name == 'push' && github.repository == 'modular/rules_mojo' && github.ref == 'refs/heads/main' }} - name: Select Mojo version if: matrix.mojo != 'default' env: @@ -90,3 +97,20 @@ jobs: bazel test --experimental_output_paths=strip //... - name: Check fixit exports run: bazel build --experimental_output_paths=strip --//:experimental_export_fixits --output_groups=+mojo_fixits //tests:hello_world + + # These six names are required by the existing main CI ruleset. Each reports + # the result of the entire test matrix; the legacy Bazel labels are aliases. + required-checks: + name: test (${{ matrix.os }}, ${{ matrix.bazel }}) + needs: test + if: ${{ always() }} + strategy: + matrix: + os: [macos-15, ubuntu-latest] + bazel: [latest, last_rc, last_green] + runs-on: ubuntu-latest + steps: + - name: Require all test jobs to succeed + env: + TEST_RESULT: ${{ needs.test.result }} + run: test "$TEST_RESULT" = success diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..b3a9e6d --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,36 @@ +# Called by release.yaml after the release and its artifacts are ready. +name: Publish to BCR + +on: + workflow_call: + inputs: + tag_name: + description: Validated unprefixed release tag + required: true + type: string + secrets: + publish_token: + description: Token for pushing to the BCR fork and opening its pull request + required: true + +permissions: + contents: read + +jobs: + publish: + permissions: + actions: read + contents: write + id-token: write + attestations: write + uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v1.6.0 # 3b1b972e41764b9a7498cf9128ed4ed2258a3687 + with: + tag_name: ${{ inputs.tag_name }} + tag_prefix: '' + registry_fork: modular/bazel-central-registry + attest: true + draft: false + download_default_release_artifacts: true + release_artifacts_run_id: ${{ github.run_id }} + secrets: + publish_token: ${{ secrets.publish_token }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..a6e2667 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,113 @@ +name: Release + +on: + workflow_call: + inputs: + tag_name: + description: Existing unprefixed release tag (for example, 0.9.0) + required: true + type: string + secrets: + publish_token: + description: Token for pushing to the BCR fork and opening its pull request + required: true + BCR_PUBLISH_TOKEN: + description: Repository secret used as the fallback for manual dispatch + required: false + workflow_dispatch: + inputs: + tag_name: + description: Existing unprefixed release tag (for example, 0.9.0) + required: true + type: string + +permissions: + contents: read + +# Serialize manual and callable release runs to prevent competing preparations. +concurrency: + group: release + cancel-in-progress: false + +jobs: + validate: + if: github.repository == 'modular/rules_mojo' && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + outputs: + tag_name: ${{ steps.validate.outputs.tag_name }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + - name: Validate release tag + id: validate + env: + GH_TOKEN: ${{ github.token }} + RELEASE_TAG: ${{ inputs.tag_name }} + shell: bash + run: | + set -euo pipefail + NUMBER='(0|[1-9][0-9]*)' + IDENTIFIER="($NUMBER|[0-9]*[A-Za-z-][0-9A-Za-z-]*)" + if [[ ! "$RELEASE_TAG" =~ ^$NUMBER\.$NUMBER\.$NUMBER(-$IDENTIFIER(\.$IDENTIFIER)*)?$ ]]; then + echo 'Expected an unprefixed version such as 0.9.0 or 0.9.0-rc.1' >&2 + exit 1 + fi + + # Require an existing upstream tag whose commit belongs to main. + git fetch --no-tags https://github.com/modular/rules_mojo.git \ + +refs/heads/main:refs/remotes/upstream/main \ + "+refs/tags/$RELEASE_TAG:refs/tags/$RELEASE_TAG" + COMMIT=$(git rev-parse --verify "refs/tags/$RELEASE_TAG^{commit}") + git merge-base --is-ancestor "$COMMIT" refs/remotes/upstream/main + for path in .github/workflows/{release.yaml,publish.yaml,release_prep.sh} \ + .bcr/{metadata.template.json,source.template.json,presubmit.yml}; do + git cat-file -e "$COMMIT:$path" + done + + # Include all pages and allow retries of drafts, preserving published releases. + PUBLISHED=$(gh api 'repos/modular/rules_mojo/releases?per_page=100' --paginate --slurp \ + | jq --arg tag "$RELEASE_TAG" 'any(.[][]; .tag_name == $tag and .draft == false)') + if [[ "$PUBLISHED" == true ]]; then + echo "GitHub release $RELEASE_TAG is already published" >&2 + exit 1 + fi + PUBLISHED=$(gh api repos/bazelbuild/bazel-central-registry/contents/modules/rules_mojo/metadata.json \ + -H 'Accept: application/vnd.github.raw+json' \ + | jq --arg tag "$RELEASE_TAG" '.versions | index($tag) != null') + if [[ "$PUBLISHED" == true ]]; then + echo "rules_mojo@$RELEASE_TAG is already in the BCR" >&2 + exit 1 + fi + + echo "tag_name=$RELEASE_TAG" >> "$GITHUB_OUTPUT" + echo "Validated $RELEASE_TAG at upstream main commit $COMMIT" + + release: + needs: validate + permissions: + contents: write + id-token: write + attestations: write + uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v7.7.0 # 1d798ff015ed0696433e01e2c3ccbb2abefadad7 + with: + tag_name: ${{ needs.validate.outputs.tag_name }} + prerelease: false + draft: false + # Cache writes are reserved for upstream main push CI runs. + mount_bazel_caches: false + release_files: rules_mojo-*.tar.gz + + publish-to-bcr: + needs: [validate, release] + permissions: + actions: read + contents: write + id-token: write + attestations: write + uses: ./.github/workflows/publish.yaml + with: + tag_name: ${{ needs.validate.outputs.tag_name }} + secrets: + publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }} diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh new file mode 100755 index 0000000..46e1fdc --- /dev/null +++ b/.github/workflows/release_prep.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [[ $# -ne 1 ]]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +TAG=$1 +NUMBER='(0|[1-9][0-9]*)' +IDENTIFIER="($NUMBER|[0-9]*[A-Za-z-][0-9A-Za-z-]*)" +if [[ ! "$TAG" =~ ^$NUMBER\.$NUMBER\.$NUMBER(-$IDENTIFIER(\.$IDENTIFIER)*)?$ ]]; then + echo "Expected an unprefixed version such as 0.9.0 or 0.9.0-rc.1" >&2 + exit 1 +fi + +PREFIX="rules_mojo-$TAG" +ARCHIVE="$PREFIX.tar.gz" +git rev-parse --verify "${TAG}^{commit}" > /dev/null +# Keep committed sources intact; the BCR publisher stamps its MODULE.bazel. +# Refuse to overwrite an existing artifact, and omit gzip timestamps. +set -o noclobber +git -C "$(git rev-parse --show-toplevel)" archive --format=tar --prefix="${PREFIX}/" "$TAG" | gzip -n > "$ARCHIVE" +SHA=$(shasum -a 256 "$ARCHIVE" | awk '{print $1}') + +cat << EOF +## rules_mojo $TAG + +Add the following to your \`MODULE.bazel\`: + +\`\`\`bzl +bazel_dep(name = "rules_mojo", version = "$TAG") +\`\`\` + +Requires Bazel 8 or later. Omit the version from \`mojo.toolchain()\` to use the +default Mojo toolchain, or select one with \`mojo.toolchain(version = "...")\`. + +Archive: \`$ARCHIVE\` (strip prefix: \`$PREFIX\`) + +SHA-256: \`$SHA\` + +Archive and BCR metadata attestations are attached by the release workflow. +EOF From ca9386bd383c21e51ac4641d7c615ff62fe5d136 Mon Sep 17 00:00:00 2001 From: Dragos Carp Date: Fri, 30 Oct 2026 23:07:07 +0100 Subject: [PATCH 2/8] feat: generate API documentation for releases --- .bcr/source.template.json | 1 + .github/workflows/release_prep.sh | 12 +++++ MODULE.bazel | 3 +- mojo/BUILD.bazel | 84 +++++++++++++++++++++++++++++++ mojo/private/BUILD.bazel | 42 ++++++++++++++++ mojo/private/link_hack.bzl | 2 +- 6 files changed, 142 insertions(+), 2 deletions(-) diff --git a/.bcr/source.template.json b/.bcr/source.template.json index 966f818..bb52b38 100644 --- a/.bcr/source.template.json +++ b/.bcr/source.template.json @@ -2,6 +2,7 @@ "integrity": "", "strip_prefix": "rules_mojo-{VERSION}", "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/rules_mojo-{VERSION}.tar.gz", + "docs_url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/rules_mojo-{VERSION}.docs.tar.gz", "patch_strip": 1, "patches": {} } diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh index 46e1fdc..cc14935 100755 --- a/.github/workflows/release_prep.sh +++ b/.github/workflows/release_prep.sh @@ -23,6 +23,18 @@ set -o noclobber git -C "$(git rev-parse --show-toplevel)" archive --format=tar --prefix="${PREFIX}/" "$TAG" | gzip -n > "$ARCHIVE" SHA=$(shasum -a 256 "$ARCHIVE" | awk '{print $1}') +# Build API documentation in a separate output base so the archive contains +# documentation outputs only. +DOCS=$(mktemp -d) +TARGETS=$(mktemp) +trap 'bazel --output_base="$DOCS" shutdown; rm -rf "$DOCS"; rm -f "$TARGETS"' EXIT +bazel --output_base="$DOCS" query --output=label --output_file="$TARGETS" 'kind("starlark_doc_extract rule", //...)' +test -s "$TARGETS" +bazel --output_base="$DOCS" build --target_pattern_file="$TARGETS" --remote_download_regex='.*doc_extract\.binaryproto' +tar --create --auto-compress \ + --directory "$(bazel --output_base="$DOCS" info bazel-bin)" \ + --file "$PWD/${ARCHIVE%.tar.gz}.docs.tar.gz" . + cat << EOF ## rules_mojo $TAG diff --git a/MODULE.bazel b/MODULE.bazel index b716e5c..399cd34 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -5,7 +5,8 @@ module( ) bazel_dep(name = "bazel_features", version = "1.46.0") -bazel_dep(name = "bazel_skylib", version = "1.7.1") +bazel_dep(name = "bazel_lib", version = "3.0.0") +bazel_dep(name = "bazel_skylib", version = "1.8.1") bazel_dep(name = "platforms", version = "0.0.11") bazel_dep(name = "rules_cc", version = "0.2.18") bazel_dep(name = "rules_python", version = "1.0.0") diff --git a/mojo/BUILD.bazel b/mojo/BUILD.bazel index e69de29..8577cb7 100644 --- a/mojo/BUILD.bazel +++ b/mojo/BUILD.bazel @@ -0,0 +1,84 @@ +load("@bazel_lib//:bzl_library.bzl", "bzl_library") + +bzl_library( + name = "build_settings", + srcs = ["build_settings.bzl"], + visibility = ["//visibility:public"], + deps = ["@bazel_skylib//rules:common_settings"], +) + +bzl_library( + name = "extensions", + srcs = ["extensions.bzl"], + visibility = ["//visibility:public"], + deps = [ + ":mojo_host_platform", + "//mojo/private:mojo_gpu_toolchains_repository", + ], +) + +bzl_library( + name = "mojo_binary", + srcs = ["mojo_binary.bzl"], + visibility = ["//visibility:public"], + deps = ["//mojo/private:mojo_binary_test"], +) + +bzl_library( + name = "mojo_host_platform", + srcs = ["mojo_host_platform.bzl"], + visibility = ["//visibility:public"], +) + +bzl_library( + name = "mojo_import", + srcs = ["mojo_import.bzl"], + visibility = ["//visibility:public"], + deps = [ + ":providers", + "//mojo/private:utils", + ], +) + +bzl_library( + name = "mojo_library", + srcs = ["mojo_library.bzl"], + visibility = ["//visibility:public"], + deps = [ + ":providers", + "//mojo/private:utils", + "@bazel_skylib//rules:common_settings", + "@rules_cc//cc/common", + ], +) + +bzl_library( + name = "mojo_shared_library", + srcs = ["mojo_shared_library.bzl"], + visibility = ["//visibility:public"], + deps = ["//mojo/private:mojo_binary_test"], +) + +bzl_library( + name = "mojo_test", + srcs = ["mojo_test.bzl"], + visibility = ["//visibility:public"], + deps = ["//mojo/private:mojo_binary_test"], +) + +bzl_library( + name = "providers", + srcs = ["providers.bzl"], + visibility = ["//visibility:public"], +) + +bzl_library( + name = "toolchain", + srcs = ["toolchain.bzl"], + visibility = ["//visibility:public"], + deps = [ + ":providers", + "//mojo/private:utils", + "@rules_cc//cc/common", + ], +) diff --git a/mojo/private/BUILD.bazel b/mojo/private/BUILD.bazel index 70b2e96..c71e9f0 100644 --- a/mojo/private/BUILD.bazel +++ b/mojo/private/BUILD.bazel @@ -1,4 +1,46 @@ +load("@bazel_lib//:bzl_library.bzl", "bzl_library") + +package(default_visibility = ["//mojo:__subpackages__"]) + exports_files( ["env_shim.sh"], visibility = ["//visibility:public"], ) + +bzl_library( + name = "mojo_binary_test", + srcs = ["mojo_binary_test.bzl"], + deps = [ + ":transitions", + ":utils", + "//mojo:providers", + "@bazel_skylib//lib:paths", + "@bazel_skylib//rules:common_settings", + "@bazel_tools//tools/cpp:toolchain_utils.bzl", + "@build_bazel_rules_android//:link_hack.bzl", + "@rules_cc//cc:find_cc_toolchain_bzl", + "@rules_cc//cc/common", + "@rules_python//python:py_info_bzl", + ], +) + +bzl_library( + name = "mojo_gpu_toolchains_repository", + srcs = ["mojo_gpu_toolchains_repository.bzl"], +) + +bzl_library( + name = "transitions", + srcs = ["transitions.bzl"], +) + +bzl_library( + name = "utils", + srcs = ["utils.bzl"], + deps = [ + "//mojo:providers", + "@bazel_features//:features", + "@bazel_skylib//lib:paths", + "@rules_cc//cc/common", + ], +) diff --git a/mojo/private/link_hack.bzl b/mojo/private/link_hack.bzl index 0c57ada..7200775 100644 --- a/mojo/private/link_hack.bzl +++ b/mojo/private/link_hack.bzl @@ -4,7 +4,7 @@ https://github.com/bazelbuild/bazel/pull/23838 """ def _link_hack_impl(rctx): - rctx.file("BUILD.bazel", "") + rctx.file("BUILD.bazel", 'exports_files(["link_hack.bzl"])') rctx.file("link_hack.bzl", """\ load("@rules_cc//cc/common:cc_common.bzl", "cc_common") From 63fbfeb01fabf558a8a30015573134f13481d8db Mon Sep 17 00:00:00 2001 From: Dragos Carp Date: Fri, 30 Oct 2026 23:17:39 +0100 Subject: [PATCH 3/8] ci: require pre-commit checks --- .bcr/metadata.template.json | 26 ++++++++++++++------------ .bcr/source.template.json | 12 ++++++------ .github/workflows/ci.yaml | 17 +++++++++++++---- mojo/mojo_host_platform.bzl | 2 +- 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/.bcr/metadata.template.json b/.bcr/metadata.template.json index 5b3a2e8..50a5324 100644 --- a/.bcr/metadata.template.json +++ b/.bcr/metadata.template.json @@ -1,14 +1,16 @@ { - "homepage": "https://github.com/modular/rules_mojo", - "maintainers": [ - { - "email": "atrotta@modular.com", - "github": "Ahajha", - "name": "Alex Trotta", - "github_user_id": 44127594 - } - ], - "repository": ["github:modular/rules_mojo"], - "versions": [], - "yanked_versions": {} + "homepage": "https://github.com/modular/rules_mojo", + "maintainers": [ + { + "email": "atrotta@modular.com", + "github": "Ahajha", + "name": "Alex Trotta", + "github_user_id": 44127594 + } + ], + "repository": [ + "github:modular/rules_mojo" + ], + "versions": [], + "yanked_versions": {} } diff --git a/.bcr/source.template.json b/.bcr/source.template.json index bb52b38..5c409ac 100644 --- a/.bcr/source.template.json +++ b/.bcr/source.template.json @@ -1,8 +1,8 @@ { - "integrity": "", - "strip_prefix": "rules_mojo-{VERSION}", - "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/rules_mojo-{VERSION}.tar.gz", - "docs_url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/rules_mojo-{VERSION}.docs.tar.gz", - "patch_strip": 1, - "patches": {} + "integrity": "", + "strip_prefix": "rules_mojo-{VERSION}", + "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/rules_mojo-{VERSION}.tar.gz", + "docs_url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/rules_mojo-{VERSION}.docs.tar.gz", + "patch_strip": 1, + "patches": {} } diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2f81169..e4d42ea 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -98,11 +98,17 @@ jobs: - name: Check fixit exports run: bazel build --experimental_output_paths=strip --//:experimental_export_fixits --output_groups=+mojo_fixits //tests:hello_world + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: j178/prek-action@44924fe9ef4a6f88253c4b6b1bf11c689d3ce53d # v3.1.0 + # These six names are required by the existing main CI ruleset. Each reports - # the result of the entire test matrix; the legacy Bazel labels are aliases. + # the test matrix and pre-commit results; the legacy Bazel labels are aliases. required-checks: name: test (${{ matrix.os }}, ${{ matrix.bazel }}) - needs: test + needs: [test, pre-commit] if: ${{ always() }} strategy: matrix: @@ -110,7 +116,10 @@ jobs: bazel: [latest, last_rc, last_green] runs-on: ubuntu-latest steps: - - name: Require all test jobs to succeed + - name: Require tests and pre-commit to succeed env: TEST_RESULT: ${{ needs.test.result }} - run: test "$TEST_RESULT" = success + PRE_COMMIT_RESULT: ${{ needs.pre-commit.result }} + run: | + test "$TEST_RESULT" = success + test "$PRE_COMMIT_RESULT" = success diff --git a/mojo/mojo_host_platform.bzl b/mojo/mojo_host_platform.bzl index 34862a0..7cc6eef 100644 --- a/mojo/mojo_host_platform.bzl +++ b/mojo/mojo_host_platform.bzl @@ -85,7 +85,7 @@ def _get_amd_constraints_with_rocm_smi(rctx, rocm_smi, gpu_mapping): _log_result(rctx, rocm_smi, result) constraints = [] - if result.return_code == 0 and len(result.stdout) > 0: #len(result.stdout) == 0 when the driver is not initialized + if result.return_code == 0 and len(result.stdout) > 0: #len(result.stdout) == 0 when the driver is not initialized blob = json.decode(result.stdout) if len(blob.keys()) == 0: fail("rocm-smi succeeded but didn't actually have any GPUs, please report this issue") From 3e6dca433763bec96857d1a5f4710115aea950b9 Mon Sep 17 00:00:00 2001 From: Dragos Carp Date: Fri, 30 Oct 2026 23:53:59 +0100 Subject: [PATCH 4/8] fix: use public C++ toolchain helpers for Bazel 10 compatibility --- mojo/private/BUILD.bazel | 1 - mojo/private/mojo_binary_test.bzl | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/mojo/private/BUILD.bazel b/mojo/private/BUILD.bazel index c71e9f0..584c288 100644 --- a/mojo/private/BUILD.bazel +++ b/mojo/private/BUILD.bazel @@ -16,7 +16,6 @@ bzl_library( "//mojo:providers", "@bazel_skylib//lib:paths", "@bazel_skylib//rules:common_settings", - "@bazel_tools//tools/cpp:toolchain_utils.bzl", "@build_bazel_rules_android//:link_hack.bzl", "@rules_cc//cc:find_cc_toolchain_bzl", "@rules_cc//cc/common", diff --git a/mojo/private/mojo_binary_test.bzl b/mojo/private/mojo_binary_test.bzl index 90419d7..c597ffe 100644 --- a/mojo/private/mojo_binary_test.bzl +++ b/mojo/private/mojo_binary_test.bzl @@ -2,8 +2,8 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") -load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain") load("@build_bazel_rules_android//:link_hack.bzl", "link_hack") # See link_hack.bzl for details +load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain", "use_cc_toolchain") load("@rules_cc//cc/common:cc_common.bzl", "cc_common") load("@rules_cc//cc/common:cc_info.bzl", "CcInfo") load("@rules_python//python:py_info.bzl", "PyInfo") @@ -57,7 +57,7 @@ by bazel. ), } | env_shim_attrs("mojo_compile") -_TOOLCHAINS = use_cpp_toolchain() + [ +_TOOLCHAINS = use_cc_toolchain() + [ _PYTHON_TOOLCHAIN_TYPE, ] @@ -94,7 +94,7 @@ def _format_include(arg): return ["-I", arg.dirname] def _mojo_binary_test_implementation(ctx, *, shared_library = False): - cc_toolchain = find_cpp_toolchain(ctx) + cc_toolchain = find_cc_toolchain(ctx) mojo_toolchain = ctx.exec_groups["mojo_compile"].toolchains["//:toolchain_type"].mojo_toolchain_info py_toolchain = ctx.toolchains[_PYTHON_TOOLCHAIN_TYPE] From efbf63ccc41521c64fdc257522d61c719b9f40bb Mon Sep 17 00:00:00 2001 From: Dragos Carp Date: Sat, 31 Oct 2026 12:09:14 +0100 Subject: [PATCH 5/8] ci: add conclusion check with legacy aliases --- .github/workflows/ci.yaml | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e4d42ea..31dd791 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -104,11 +104,26 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: j178/prek-action@44924fe9ef4a6f88253c4b6b1bf11c689d3ce53d # v3.1.0 - # These six names are required by the existing main CI ruleset. Each reports - # the test matrix and pre-commit results; the legacy Bazel labels are aliases. + # A stable check name for requiring the full test matrix and pre-commit checks. + conclusion: + needs: [test, pre-commit] + runs-on: ubuntu-latest + if: ${{ always() }} + steps: + - name: report success + if: ${{ needs.test.result == 'success' && needs.pre-commit.result == 'success' }} + run: echo success + - name: report failure + if: ${{ needs.test.result != 'success' || needs.pre-commit.result != 'success' }} + run: | + echo '${{ toJSON(needs.*.result) }}' + exit 1 + + # Compatibility aliases for the six checks required by the main CI ruleset. + # These can be removed once the ruleset requires conclusion directly. required-checks: name: test (${{ matrix.os }}, ${{ matrix.bazel }}) - needs: [test, pre-commit] + needs: conclusion if: ${{ always() }} strategy: matrix: @@ -116,10 +131,7 @@ jobs: bazel: [latest, last_rc, last_green] runs-on: ubuntu-latest steps: - - name: Require tests and pre-commit to succeed + - name: Require conclusion to succeed env: - TEST_RESULT: ${{ needs.test.result }} - PRE_COMMIT_RESULT: ${{ needs.pre-commit.result }} - run: | - test "$TEST_RESULT" = success - test "$PRE_COMMIT_RESULT" = success + CONCLUSION_RESULT: ${{ needs.conclusion.result }} + run: test "$CONCLUSION_RESULT" = success From a13ef2ce6b6638d9aa6d8b361342aef8eb3c651e Mon Sep 17 00:00:00 2001 From: Dragos Carp Date: Fri, 13 Nov 2026 23:34:34 +0200 Subject: [PATCH 6/8] ci: adopt release-please for release automation --- .github/workflows/changelog_entry.sh | 19 ++++++++ .github/workflows/publish.yaml | 2 +- .github/workflows/release-please.yaml | 59 ++++++++++++++++++++++++ .github/workflows/release.yaml | 30 ++++++++----- .github/workflows/release_prep.sh | 6 ++- .release-please-manifest.json | 3 ++ CHANGELOG.md | 4 ++ MODULE.bazel | 2 +- README.md | 2 + RELEASING.md | 65 +++++++++++++++++++++++++++ release-please-config.json | 13 ++++++ 11 files changed, 192 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/changelog_entry.sh create mode 100644 .github/workflows/release-please.yaml create mode 100644 .release-please-manifest.json create mode 100644 CHANGELOG.md create mode 100644 RELEASING.md create mode 100644 release-please-config.json diff --git a/.github/workflows/changelog_entry.sh b/.github/workflows/changelog_entry.sh new file mode 100644 index 0000000..578451c --- /dev/null +++ b/.github/workflows/changelog_entry.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Print only the requested version, accepting linked and plain release headings. +# An optional path lets validation inspect the tagged changelog before checkout. +TAG=${1:?Usage: changelog_entry.sh [changelog-path]} +CHANGELOG=${2:-CHANGELOG.md} +if [[ -f "$CHANGELOG" ]]; then + awk -v version="$TAG" ' + /^##? / { + heading = $2 + sub(/^\[/, "", heading) + sub(/\].*$/, "", heading) + if (found) exit + found = (heading == version) + } + found { print } + ' "$CHANGELOG" +fi diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index b3a9e6d..b9e1276 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -23,7 +23,7 @@ jobs: contents: write id-token: write attestations: write - uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v1.6.0 # 3b1b972e41764b9a7498cf9128ed4ed2258a3687 + uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v1.7.0 # 1ae09341a6014e9bea052879c42392ac6b8b632c with: tag_name: ${{ inputs.tag_name }} tag_prefix: '' diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml new file mode 100644 index 0000000..e2be9e7 --- /dev/null +++ b/.github/workflows/release-please.yaml @@ -0,0 +1,59 @@ +name: Release Please + +on: + push: + branches: [main] + workflow_dispatch: + +permissions: {} + +# Separate from release.yaml's group because this workflow calls it. +concurrency: + group: release-please + cancel-in-progress: false + +jobs: + release-please: + if: github.repository == 'modular/rules_mojo' && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + permissions: + actions: write # Dispatch CI on the release PR branch. + contents: write + issues: write + pull-requests: write + outputs: + release_created: ${{ steps.release.outputs.release_created }} + tag_name: ${{ steps.release.outputs.tag_name }} + steps: + # GITHUB_TOKEN-created PRs and tags do not trigger other workflows. + - name: Update release PR and release merged PRs + id: release + uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + config-file: release-please-config.json + manifest-file: .release-please-manifest.json + - name: Run CI on the release PR + if: steps.release.outputs.pr != '' + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + RELEASE_PR: ${{ steps.release.outputs.pr }} + run: | + branch=$(jq -er '.headBranchName' <<< "$RELEASE_PR") + gh workflow run ci.yaml --ref "$branch" + + release: + needs: release-please + # Still package a created release if a later release PR update or CI dispatch fails. + if: always() && needs.release-please.outputs.release_created == 'true' + uses: ./.github/workflows/release.yaml + with: + tag_name: ${{ needs.release-please.outputs.tag_name }} + secrets: + publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }} + permissions: + actions: read + contents: write + id-token: write + attestations: write diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a6e2667..4977280 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -20,21 +20,25 @@ on: description: Existing unprefixed release tag (for example, 0.9.0) required: true type: string + push: + tags: + - '[0-9]*.[0-9]*.[0-9]*' permissions: contents: read -# Serialize manual and callable release runs to prevent competing preparations. +# Serialize release runs to prevent competing preparations. concurrency: group: release cancel-in-progress: false jobs: validate: - if: github.repository == 'modular/rules_mojo' && github.ref == 'refs/heads/main' + if: github.repository == 'modular/rules_mojo' && (github.ref == 'refs/heads/main' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))) runs-on: ubuntu-latest outputs: tag_name: ${{ steps.validate.outputs.tag_name }} + generate_release_notes: ${{ steps.validate.outputs.generate_release_notes }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -44,7 +48,7 @@ jobs: id: validate env: GH_TOKEN: ${{ github.token }} - RELEASE_TAG: ${{ inputs.tag_name }} + RELEASE_TAG: ${{ inputs.tag_name || github.ref_name }} shell: bash run: | set -euo pipefail @@ -66,13 +70,8 @@ jobs: git cat-file -e "$COMMIT:$path" done - # Include all pages and allow retries of drafts, preserving published releases. - PUBLISHED=$(gh api 'repos/modular/rules_mojo/releases?per_page=100' --paginate --slurp \ - | jq --arg tag "$RELEASE_TAG" 'any(.[][]; .tag_name == $tag and .draft == false)') - if [[ "$PUBLISHED" == true ]]; then - echo "GitHub release $RELEASE_TAG is already published" >&2 - exit 1 - fi + # Release Please creates the GitHub release before packaging. Allow + # updating it and retrying uploads, but never republish a BCR version. PUBLISHED=$(gh api repos/bazelbuild/bazel-central-registry/contents/modules/rules_mojo/metadata.json \ -H 'Accept: application/vnd.github.raw+json' \ | jq --arg tag "$RELEASE_TAG" '.versions | index($tag) != null') @@ -81,6 +80,16 @@ jobs: exit 1 fi + ENTRY='' + if git cat-file -e "$COMMIT:CHANGELOG.md" 2>/dev/null; then + git show "$COMMIT:CHANGELOG.md" > "$RUNNER_TEMP/release-changelog.md" + ENTRY=$(bash .github/workflows/changelog_entry.sh "$RELEASE_TAG" "$RUNNER_TEMP/release-changelog.md") + fi + if [[ -n "$ENTRY" ]]; then + echo 'generate_release_notes=false' >> "$GITHUB_OUTPUT" + else + echo 'generate_release_notes=true' >> "$GITHUB_OUTPUT" + fi echo "tag_name=$RELEASE_TAG" >> "$GITHUB_OUTPUT" echo "Validated $RELEASE_TAG at upstream main commit $COMMIT" @@ -95,6 +104,7 @@ jobs: tag_name: ${{ needs.validate.outputs.tag_name }} prerelease: false draft: false + generate_release_notes: ${{ needs.validate.outputs.generate_release_notes == 'true' }} # Cache writes are reserved for upstream main push CI runs. mount_bazel_caches: false release_files: rules_mojo-*.tar.gz diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh index cc14935..747d37d 100755 --- a/.github/workflows/release_prep.sh +++ b/.github/workflows/release_prep.sh @@ -17,7 +17,7 @@ fi PREFIX="rules_mojo-$TAG" ARCHIVE="$PREFIX.tar.gz" git rev-parse --verify "${TAG}^{commit}" > /dev/null -# Keep committed sources intact; the BCR publisher stamps its MODULE.bazel. +# Archive the committed module version reviewed in the release PR. # Refuse to overwrite an existing artifact, and omit gzip timestamps. set -o noclobber git -C "$(git rev-parse --show-toplevel)" archive --format=tar --prefix="${PREFIX}/" "$TAG" | gzip -n > "$ARCHIVE" @@ -35,6 +35,10 @@ tar --create --auto-compress \ --directory "$(bazel --output_base="$DOCS" info bazel-bin)" \ --file "$PWD/${ARCHIVE%.tar.gz}.docs.tar.gz" . +# Use the same changelog entry reviewed in the release PR. +bash .github/workflows/changelog_entry.sh "$TAG" +echo + cat << EOF ## rules_mojo $TAG diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..64f3cdd --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.8.0" +} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a486cfc --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +# Changelog + +Releases after 0.8.0 are recorded here. For earlier releases, see the +[GitHub releases](https://github.com/modular/rules_mojo/releases). diff --git a/MODULE.bazel b/MODULE.bazel index 399cd34..f9c7324 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,6 +1,6 @@ module( name = "rules_mojo", - version = "0", + version = "0.8.0", bazel_compatibility = [">=8.0.0"], ) diff --git a/README.md b/README.md index 11bd46d..4c317b6 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,5 @@ mojo_binary( ``` See the [tests](tests) directory for more examples. + +For release automation and maintainer setup, see [Releasing](RELEASING.md). diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 0000000..a9fb2ce --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,65 @@ +# Releasing + +[Release Please](https://github.com/googleapis/release-please) maintains a release +PR as changes land on upstream `main`. A maintainer reviews and merges that PR +to release. The PR updates `MODULE.bazel`, `CHANGELOG.md`, and the release manifest +using the Bazel release strategy. Tags remain unprefixed, for example `0.9.0`. + +Use Conventional Commit PR titles and squash merges: + +- `fix:` increments the patch version. +- `feat:` increments the minor version. +- `!` or a `BREAKING CHANGE:` footer increments the minor version before 1.0.0 + and the major version afterward. +- Changes such as `chore:` and `ci:` normally do not trigger a release. + +To override the proposed version, include a `Release-As: X.Y.Z` footer in a commit +on `main`, such as a PR's squash commit. Review the updated release PR before +merging it. The initial baseline is the published `0.8.0` release; subsequent +versions are maintained by release-please. + +## Setup and CI + +Release Please uses the built-in `GITHUB_TOKEN`. Enable **Allow GitHub Actions to +create and approve pull requests** in Settings > Actions > General, subject to +organization policy. No separate release-please token is needed. + +BCR publication requires a `modular/bazel-central-registry` fork and the +`BCR_PUBLISH_TOKEN` repository secret with access to push to that fork and open +the registry PR. See the publisher's +[token setup](https://github.com/bazel-contrib/publish-to-bcr#3-create-a-personal-access-token). + +PRs created with `GITHUB_TOKEN` do not automatically trigger other workflows. +The Release Please workflow explicitly dispatches CI on the release PR branch. +This runs the complete Bazel matrix, pre-commit checks, `conclusion`, and the +existing compatibility checks. To rerun CI, dispatch the Test workflow on the +release PR branch. Cache writes remain restricted to upstream `main` push CI. + +## Release and recovery + +After a release PR is merged, Release Please creates its tag and GitHub Release, +then directly calls the Release workflow to test, package source and API docs, +upload attestations, and publish a BCR PR. The GitHub Release is visible before +its assets finish uploading. Final notes contain the reviewed changelog entry +and installation instructions. + +If packaging, uploads, or BCR publication fails, dispatch the +[Release workflow](https://github.com/modular/rules_mojo/actions/workflows/release.yaml) +from `main` with the existing unprefixed tag as `tag_name`. It can update an +existing GitHub Release; it rejects versions already present in BCR. Rerunning +Release Please alone does not retry packaging for an already-created release. + +Manually pushed version tags also start the Release workflow, for example: + +```sh +git fetch upstream +git tag 0.9.0 upstream/main +git push upstream 0.9.0 +``` + +Tags must point to a commit on upstream `main` containing the release automation +and BCR templates. Tags without a matching changelog entry use GitHub-generated +notes alongside installation instructions. Manual tags use the stable-release +pipeline, including tags with prerelease suffixes; use release PRs for routine +releases to keep the module version and manifest synchronized. Tags created by +Release Please do not trigger a second tag-push workflow run. diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..f465a8f --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "bootstrap-sha": "909fe03b2d0a084bddbe736787c8586434845f5a", + "packages": { + ".": { + "release-type": "bazel", + "include-component-in-tag": false, + "include-v-in-tag": false, + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": false + } + } +} From 78bbd47fcb6a59ba5917b2ce3d8c162f8ff887e4 Mon Sep 17 00:00:00 2001 From: Dragos Carp Date: Sat, 21 Nov 2026 16:02:08 +0200 Subject: [PATCH 7/8] ci: validate Conventional Commit PR titles --- .github/workflows/conventional-commits.yaml | 18 +++++++++++++ RELEASING.md | 30 ++++++++++++++++----- 2 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/conventional-commits.yaml diff --git a/.github/workflows/conventional-commits.yaml b/.github/workflows/conventional-commits.yaml new file mode 100644 index 0000000..6107faf --- /dev/null +++ b/.github/workflows/conventional-commits.yaml @@ -0,0 +1,18 @@ +name: Lint PR + +on: + pull_request: + branches: [main] + types: [opened, reopened, edited, synchronize] + +permissions: + pull-requests: read + +jobs: + check: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@2252a14e810aa9b85c2d560bd7070c802206ecf6 # v6.1.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/RELEASING.md b/RELEASING.md index a9fb2ce..85fc5c2 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -5,7 +5,8 @@ PR as changes land on upstream `main`. A maintainer reviews and merges that PR to release. The PR updates `MODULE.bazel`, `CHANGELOG.md`, and the release manifest using the Bazel release strategy. Tags remain unprefixed, for example `0.9.0`. -Use Conventional Commit PR titles and squash merges: +Use [Conventional Commit](https://www.conventionalcommits.org/) PR titles and +squash merges: - `fix:` increments the patch version. - `feat:` increments the minor version. @@ -13,6 +14,12 @@ Use Conventional Commit PR titles and squash merges: and the major version afterward. - Changes such as `chore:` and `ci:` normally do not trigger a release. +The `Validate PR title` check accepts titles such as `fix: correct imports`, +`feat(toolchain): add support`, and `refactor!: remove deprecated API`. Scopes +are optional, and subjects may start with an uppercase letter. Use `!` in the +title to indicate a breaking change; a `BREAKING CHANGE:` footer belongs in the +squash commit body. + To override the proposed version, include a `Release-As: X.Y.Z` footer in a commit on `main`, such as a PR's squash commit. Review the updated release PR before merging it. The initial baseline is the published `0.8.0` release; subsequent @@ -24,16 +31,27 @@ Release Please uses the built-in `GITHUB_TOKEN`. Enable **Allow GitHub Actions t create and approve pull requests** in Settings > Actions > General, subject to organization policy. No separate release-please token is needed. +A repository administrator must configure squash merges to default to the PR +title in Settings > General > Pull Requests. After the title workflow is on +`main` and has reported a result, add `Validate PR title` from GitHub Actions to +the required status checks in the existing `main CI` ruleset. Keep the current +required checks. Adding the workflow alone does not make it a merge requirement. + BCR publication requires a `modular/bazel-central-registry` fork and the `BCR_PUBLISH_TOKEN` repository secret with access to push to that fork and open the registry PR. See the publisher's [token setup](https://github.com/bazel-contrib/publish-to-bcr#3-create-a-personal-access-token). -PRs created with `GITHUB_TOKEN` do not automatically trigger other workflows. -The Release Please workflow explicitly dispatches CI on the release PR branch. -This runs the complete Bazel matrix, pre-commit checks, `conclusion`, and the -existing compatibility checks. To rerun CI, dispatch the Test workflow on the -release PR branch. Cache writes remain restricted to upstream `main` push CI. +Release Please explicitly dispatches the Test workflow on its PR branch, running +the Bazel matrix, pre-commit, `conclusion`, and compatibility checks. Dispatch +Test on that branch to rerun it. Cache writes remain restricted to upstream +`main` push CI. + +Title validation runs separately on PR opens, reopens, edits, and new commits. +For bot-created release PRs, GitHub can place these runs in an approval-required +state. A maintainer with write access selects **Approve workflows to run** in +the PR merge box to start them; editing the description is not required. See +[GitHub's workflow trigger rules](https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/trigger-a-workflow#triggering-a-workflow-from-a-workflow). ## Release and recovery From 5a8955d335f569e39709f067712bac42d34bbe6d Mon Sep 17 00:00:00 2001 From: Dragos Carp Date: Fri, 4 Dec 2026 20:32:02 +0200 Subject: [PATCH 8/8] style: sort Mojo library load symbols --- mojo/mojo_library.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mojo/mojo_library.bzl b/mojo/mojo_library.bzl index c9b6764..9c324b2 100644 --- a/mojo/mojo_library.bzl +++ b/mojo/mojo_library.bzl @@ -5,7 +5,7 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") load("@rules_cc//cc/common:cc_info.bzl", "CcInfo") load("//mojo:providers.bzl", "MojoInfo") -load("//mojo/private:utils.bzl", "MOJO_EXTENSIONS", "collect_mojoinfo", "format_import", "handle_copt", "env_shim_attrs", "is_exec_config", "shim_args") +load("//mojo/private:utils.bzl", "MOJO_EXTENSIONS", "collect_mojoinfo", "env_shim_attrs", "format_import", "handle_copt", "is_exec_config", "shim_args") def _format_include(arg): return ["-I", arg.dirname]