Skip to content

Commit fe073d7

Browse files
authored
Migrate to bzlmod (#10)
* bzlmod: initial MODULE files * Copy .github and .bcr from rules_proto * simplify for self-hosted runner * update example * Add diff syntax hl * Remove "target" attr
1 parent 33afed0 commit fe073d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+10904
-671
lines changed

.bazelrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
common --noincompatible_disallow_ctx_resolve_tools
2+
3+
# Disk cache configuration
4+
common --disk_cache=~/.cache/bazel-disk-cache
5+
6+
# Repository cache configuration
7+
common --repository_cache=~/.cache/bazel-repository-cache
8+
9+
# remote cache without network
10+
common --remote_cache_async

.bazelversion

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
5.1.1
1+
8.3.1
2+

.bcr/metadata.template.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"homepage": "https://github.com/stackb/bazel-aquery-differ",
3+
"maintainers": [
4+
{
5+
"name": "Paul Cody",
6+
"email": "[email protected]",
7+
"github": "pcj"
8+
}
9+
],
10+
"repository": [
11+
"github:stackb/bazel-aquery-differ"
12+
],
13+
"versions": [],
14+
"yanked_versions": {}
15+
}

.bcr/presubmit.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
bcr_test_module:
2+
module_path: "."
3+
matrix:
4+
platform: ["debian11", "ubuntu2404", "macos"]
5+
bazel: [7.x, 8.x]
6+
tasks:
7+
run_tests:
8+
name: "Run test module"
9+
platform: ${{ platform }}
10+
bazel: ${{ bazel }}
11+
test_targets:
12+
- "//..."

.bcr/source.template.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"integrity": "",
3+
"strip_prefix": "{REPO}-{TAG}",
4+
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{TAG}.tar.gz"
5+
}

.github/workflows/ci.bazelrc

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
# This file contains Bazel settings to apply on CI only.
2-
# It is referenced with a --bazelrc option in the call to bazel in ci.yaml
3-
41
# Debug where options came from
52
build --announce_rc
3+
64
# Don't rely on test logs being easily accessible from the test runner,
75
# though it makes the log noisier.
86
test --test_output=errors
9-
# This directory is configured in GitHub actions to be persisted between runs.
10-
build --disk_cache=$HOME/.cache/bazel
11-
build --repository_cache=$HOME/.cache/bazel-repo
12-
# Allows tests to run bazelisk-in-bazel, since this is the cache folder used
13-
test --test_env=XDG_CACHE_HOME
14-
# Keep until @io_bazel_rules_scala is upgraded
15-
build --incompatible_java_common_parameters=false
7+
8+
# Use remote cache instance
9+
build:cas --remote_instance_name=main
10+
build:cas --remote_cache=grpc://cas.stack.build:50051

.github/workflows/ci.yaml

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,37 @@ name: CI
22

33
# Controls when the action will run.
44
on:
5-
# Triggers the workflow on push or pull request events but only for the master branch
65
push:
76
branches: [master]
87
pull_request:
9-
branches: [master]
10-
11-
# Allows you to run this workflow manually from the Actions tab
128
workflow_dispatch:
139

10+
concurrency:
11+
# Cancel previous actions from the same PR: https://stackoverflow.com/a/72408109
12+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
13+
cancel-in-progress: true
14+
1415
jobs:
1516
test:
16-
# The type of runner that the job will run on
17-
runs-on: ubuntu-latest
18-
19-
# Steps represent a sequence of tasks that will be executed as part of the job
17+
runs-on: self-hosted
2018
steps:
21-
- uses: actions/checkout@v3
22-
23-
- uses: bazelbuild/setup-bazelisk@v2
24-
25-
- name: Mount bazel action cache
26-
uses: actions/cache@v3
27-
if: always()
19+
- uses: actions/checkout@v4
20+
- uses: bazel-contrib/[email protected]
2821
with:
29-
path: "~/.cache/bazel"
30-
key: bazel
31-
32-
- name: Mount bazel repo cache
33-
uses: actions/cache@v3
34-
if: always()
35-
with:
36-
path: "~/.cache/bazel-repo"
37-
key: bazel-repo
22+
# Avoid downloading Bazel every time.
23+
bazelisk-cache: true
24+
- name: bazel build
25+
run: >-
26+
bazelisk
27+
--bazelrc=.github/workflows/ci.bazelrc
28+
--bazelrc=.bazelrc
29+
build
30+
...
3831
3932
- name: bazel test
40-
env:
41-
# Bazelisk will download bazel to here, ensure it is cached between runs.
42-
XDG_CACHE_HOME: ~/.cache/bazel-repo
4333
run: >-
44-
bazel
34+
bazelisk
4535
--bazelrc=.github/workflows/ci.bazelrc
4636
--bazelrc=.bazelrc
4737
test
48-
//pkg/... //cmd/aquerydiff/...
38+
...

.github/workflows/format.yaml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.github/workflows/publish.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Publish new releases to Bazel Central Registry.
2+
name: Publish to BCR
3+
on:
4+
# Run the publish workflow after a successful release
5+
# Will be triggered from the release.yaml workflow
6+
workflow_call:
7+
inputs:
8+
tag_name:
9+
required: true
10+
type: string
11+
secrets:
12+
publish_token:
13+
required: true
14+
# In case of problems, let release engineers retry by manually dispatching
15+
# the workflow from the GitHub UI
16+
workflow_dispatch:
17+
inputs:
18+
tag_name:
19+
description: git tag being released
20+
required: true
21+
type: string
22+
jobs:
23+
publish:
24+
uses: bazel-contrib/publish-to-bcr/.github/workflows/[email protected]
25+
with:
26+
draft: false
27+
tag_name: ${{ inputs.tag_name }}
28+
# GitHub repository which is a fork of the upstream where the Pull Request will be opened.
29+
registry_fork: stackb/bazel-central-registry
30+
permissions:
31+
attestations: write
32+
contents: write
33+
id-token: write
34+
secrets:
35+
# Necessary to push to the BCR fork, and to open a pull request against a registry
36+
publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }}

.github/workflows/release.yaml

Lines changed: 30 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,37 @@
11
# Cut a release whenever a new tag is pushed to the repo.
2-
# You should use an annotated tag, like `git tag -a v1.2.3`
3-
# and put the release notes into the commit message for the tag.
42
name: Release
5-
63
on:
4+
# Can be triggered from the tag.yaml workflow
5+
workflow_call:
6+
inputs:
7+
tag_name:
8+
required: true
9+
type: string
10+
secrets:
11+
publish_token:
12+
required: true
13+
# Or, developers can manually push a tag from their clone
714
push:
815
tags:
916
- "v*.*.*"
10-
17+
permissions:
18+
id-token: write
19+
attestations: write
20+
contents: write
1121
jobs:
12-
build:
13-
runs-on: ubuntu-latest
14-
steps:
15-
- name: Checkout
16-
uses: actions/checkout@v3
17-
18-
- name: Set output
19-
id: vars
20-
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
21-
22-
- name: Mount bazel action cache
23-
uses: actions/cache@v3
24-
if: always()
25-
with:
26-
path: "~/.cache/bazel"
27-
key: bazel
28-
29-
- name: Mount bazel repo cache
30-
uses: actions/cache@v3
31-
if: always()
32-
with:
33-
path: "~/.cache/bazel-repo"
34-
key: bazel-repo
35-
36-
- name: build release binaries
37-
env:
38-
# Bazelisk will download bazel to here
39-
XDG_CACHE_HOME: ~/.cache/bazel-repo
40-
run: >-
41-
bazel
42-
--bazelrc=.github/workflows/ci.bazelrc
43-
--bazelrc=.bazelrc
44-
build
45-
//cmd/aquerydiff:all
46-
47-
- name: Prepare release assets
48-
env:
49-
# Bazelisk will download bazel to here
50-
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
51-
run: >-
52-
cp bazel-bin/cmd/aquerydiff/aquerydiff_darwin_amd64.zip aquerydiff_darwin_amd64.${{ env.RELEASE_VERSION }}.zip &&
53-
cp bazel-bin/cmd/aquerydiff/aquerydiff_darwin_arm64.zip aquerydiff_darwin_arm64.${{ env.RELEASE_VERSION }}.zip &&
54-
cp bazel-bin/cmd/aquerydiff/aquerydiff_linux_amd64.zip aquerydiff_linux_amd64.${{ env.RELEASE_VERSION }}.zip &&
55-
cp bazel-bin/cmd/aquerydiff/aquerydiff_linux_arm64.zip aquerydiff_linux_arm64.${{ env.RELEASE_VERSION }}.zip &&
56-
cp bazel-bin/cmd/aquerydiff/aquerydiff_windows_amd64.zip aquerydiff_windows_amd64.${{ env.RELEASE_VERSION }}.zip &&
57-
echo "done"
58-
59-
- name: Release
60-
env:
61-
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
62-
uses: softprops/action-gh-release@v1
63-
with:
64-
files: |
65-
aquerydiff_darwin_amd64.${{ env.RELEASE_VERSION }}.zip
66-
aquerydiff_darwin_arm64.${{ env.RELEASE_VERSION }}.zip
67-
aquerydiff_linux_amd64.${{ env.RELEASE_VERSION }}.zip
68-
aquerydiff_linux_arm64.${{ env.RELEASE_VERSION }}.zip
69-
aquerydiff_windows_amd64.${{ env.RELEASE_VERSION }}.zip
22+
release:
23+
uses: bazel-contrib/.github/.github/workflows/[email protected]
24+
# uses: ./.github/workflows/release_ruleset.yaml # copied-from: bazel-contrib/.github/.github/workflows/[email protected]
25+
with:
26+
prerelease: false
27+
release_files: rules_proto-*.tar.gz
28+
tag_name: ${{ inputs.tag_name || github.ref_name }}
29+
secrets:
30+
inherit
31+
publish:
32+
needs: release
33+
uses: ./.github/workflows/publish.yaml
34+
with:
35+
tag_name: ${{ inputs.tag_name || github.ref_name }}
36+
secrets:
37+
publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }}

0 commit comments

Comments
 (0)