Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"homepage": "https://github.com/modular/rules_mojo",
"maintainers": [
{
"email": "keithbsmiley@gmail.com",
"github": "keith",
"name": "Keith Smiley",
"github_user_id": 283886
},
{
"email": "atrotta@modular.com",
"github": "Ahajha",
"name": "Alex Trotta",
"github_user_id": 44127594
}
],
"repository": [
"github:modular/rules_mojo"
],
"versions": [],
"yanked_versions": {}
}
13 changes: 13 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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:
- '//...'
- '-//tests/python:deps_python_test' # TODO: re-enable when fixed
8 changes: 8 additions & 0 deletions .bcr/source.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +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": {}
}
33 changes: 33 additions & 0 deletions .github/RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Releasing rules_mojo

The Release Please workflow runs on pushes to upstream `main` and can also be
dispatched manually. It maintains a release PR containing `CHANGELOG.md`,
`MODULE.bazel`, and `.release-please-manifest.json`, starting from release 0.8.0.
Conventional Commits determine the next version: `fix:` increments the patch,
`feat:` increments the minor, and breaking changes increment the minor while
the project is below 1.0. Review the version and changelog before merging the
release PR; use release-please's `Release-As:` commit footer for an explicit
version, including the first major release.

Merging the release PR creates an unprefixed tag and GitHub release, then calls
the release workflow directly to test, build archives and API documentation,
attest artifacts, and publish to the BCR. The reviewed changelog is included in
the final release notes. The Bazel release strategy updates the module's own
version without changing dependency versions.

Repository setup requires these secrets:

- `RELEASE_PLEASE_TOKEN`: a dedicated bot PAT or equivalent token with repository
contents, issues, and pull requests read/write access. Unlike `GITHUB_TOKEN`,
this allows release PRs to trigger required CI. Keep this separate from the
registry token.
- `BCR_PUBLISH_TOKEN`: the token required by `bazel-contrib/publish-to-bcr` for
pushing to `modular/bazel-central-registry` and opening the registry PR.

There is no scheduled release or cooldown; maintainers control release timing
by merging the release PR. A GitHub release exists before its assets finish
building. If artifact publishing fails, rerun the failed jobs, or dispatch the
Release workflow on `main` with the tag and `existing_release` enabled. This
explicit option allows updating an existing release; versions already in the
BCR remain protected. For a manual tag without a GitHub release, leave
`existing_release` disabled.
97 changes: 52 additions & 45 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ 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
name: test (${{ matrix.os }}, ${{ matrix.bazel }})
strategy:
matrix:
os:
Expand All @@ -24,50 +22,21 @@ jobs:
bazel:
- 8.x
- 9.x
- latest
- last_rc
- last_green
mojo:
- default
include:
- os: macos-15
bazel: 8.x
mojo: 1.0.0
- os: ubuntu-latest
bazel: 8.x
mojo: 1.0.0
- os: ubuntu-24.04-arm
bazel: 8.x
mojo: 1.0.0
- os: macos-15
bazel: 8.x
mojo: 1.1.0
- os: ubuntu-latest
bazel: 8.x
mojo: 1.1.0
- os: ubuntu-24.04-arm
bazel: 8.x
mojo: 1.1.0
# Unlike 10.x, 10.* includes release candidates.
- '10.*'
fail-fast: false
runs-on: ${{ matrix.os }}
env:
USE_BAZEL_VERSION: ${{ matrix.bazel }}
steps:
- uses: actions/checkout@v4
- name: Select Mojo version
if: matrix.mojo != 'default'
env:
MOJO_VERSION: ${{ matrix.mojo }}
run: |
python3 - <<'PY'
import os
from pathlib import Path

module = Path("MODULE.bazel")
source = module.read_text()
assert source.count("mojo.toolchain()") == 1
module.write_text(source.replace("mojo.toolchain()", f'mojo.toolchain(version = "{os.environ["MOJO_VERSION"]}")'))
PY
- 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: Bazel Info
run: |
bazel version
Expand All @@ -81,3 +50,41 @@ 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

pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: j178/prek-action@44924fe9ef4a6f88253c4b6b1bf11c689d3ce53d # v3.1.0

# 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: conclusion
if: ${{ always() }}
strategy:
matrix:
os: [macos-15, ubuntu-latest]
bazel: [latest, last_rc, last_green]
runs-on: ubuntu-latest
steps:
- name: Require conclusion to succeed
env:
CONCLUSION_RESULT: ${{ needs.conclusion.result }}
run: test "$CONCLUSION_RESULT" = success
36 changes: 36 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
49 changes: 49 additions & 0 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release Please

on:
push:
branches: [main]
workflow_dispatch:

permissions:
contents: read

# 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'
permissions:
contents: write
issues: write
pull-requests: write
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: googleapis/release-please-action@5c625bfb5d1ff62eadeeb3772007f7f66fdcf071 # v4.4.1
id: release
with:
# A dedicated token lets release PRs trigger required CI checks.
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
config-file: release-please-config.json
manifest-file: .release-please-manifest.json

release:
needs: release-please
if: needs.release-please.outputs.release_created == 'true'
uses: ./.github/workflows/release.yaml
with:
tag_name: ${{ needs.release-please.outputs.tag_name }}
existing_release: true
secrets:
publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }}
permissions:
actions: read
contents: write
id-token: write
attestations: write
Loading
Loading