Skip to content

Commit 4be8c53

Browse files
committed
Migrate to Bzlmod. WORKSPACE files were deprecated in Bazel 8, and won't be supported in 9.
Signed-off-by: Steffen Smolka <steffen.smolka@gmail.com>
1 parent 9590de3 commit 4be8c53

File tree

5 files changed

+60
-8
lines changed

5 files changed

+60
-8
lines changed

.github/workflows/ci-build-proto.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,22 @@ on:
1414

1515
jobs:
1616
build:
17+
1718
strategy:
1819
matrix:
19-
os:
20-
- ubuntu-22.04
21-
- ubuntu-24.04
22-
- ubuntu-latest
20+
# We only test on the oldest version we want to support and latest, and
21+
# hope things also work for versions in the middle.
22+
os: [ubuntu-22.04, ubuntu-latest]
23+
bazel_version: [6.x, latest]
24+
# Don't abort other runs when one of them fails, to ease debugging.
25+
fail-fast: false
26+
2327
runs-on: ${{ matrix.os }}
28+
29+
env:
30+
USE_BAZEL_VERSION: ${{ matrix.bazel_version }}
31+
KEY: bazel-${{ matrix.bazel_version }}-${{ matrix.os }}
32+
2433
steps:
2534
- uses: actions/checkout@v4
2635
with:
@@ -33,9 +42,9 @@ jobs:
3342
path: "~/.cache/bazel"
3443
# Create a new cache entry whenever Bazel files change.
3544
# See https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows
36-
key: bazel-${{ matrix.os }}-${{ hashFiles('**/*.bazel*') }}
45+
key: ${{ env.KEY }}-${{ hashFiles('**/*.bazel*', '**/*.bzl') }}
3746
restore-keys: |
38-
bazel-${{ matrix.os }}-
47+
${{ env.KEY }}
3948
4049
- name: Save start time
4150
uses: josStorer/get-current-time@v2
@@ -85,4 +94,4 @@ jobs:
8594
if: always() && (github.ref_name == 'main' || env.duration > 300)
8695
with:
8796
path: "~/.cache/bazel"
88-
key: bazel-${{ matrix.os }}-${{ hashFiles('**/*.bazel*') }}-${{ github.run_id }}
97+
key: ${{ env.KEY }}-${{ hashFiles('**/*.bazel*', '**/*.bzl') }}-${{ github.run_id }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*~
33
docs/v1/build/
44
bazel-*
5+
*.lock
56
.DS_Store
67
build
78
dist

proto/.bazelversion

Lines changed: 0 additions & 1 deletion
This file was deleted.

proto/MODULE.bazel

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
module(
2+
name = "p4runtime",
3+
repo_name = "com_github_p4lang_p4runtime",
4+
)
5+
6+
bazel_dep(name = "bazel_skylib", version = "1.7.1")
7+
8+
bazel_dep(
9+
name = "googleapis",
10+
version = "0.0.0-20240819-fe8ba054a",
11+
repo_name = "com_google_googleapis",
12+
)
13+
switched_rules = use_extension("@com_google_googleapis//:extensions.bzl", "switched_rules")
14+
switched_rules.use_languages(
15+
cc = True,
16+
go = True,
17+
grpc = True,
18+
python = True,
19+
)
20+
use_repo(switched_rules, "com_google_googleapis_imports")
21+
22+
bazel_dep(name = "grpc", version = "1.68.0", repo_name = "com_github_grpc_grpc")
23+
24+
bazel_dep(
25+
name = "protobuf",
26+
version = "29.1",
27+
repo_name = "com_google_protobuf",
28+
)
29+
30+
bazel_dep(name = "rules_license", version = "1.0.0")
31+
32+
bazel_dep(name = "rules_proto", version = "7.0.2")
33+
34+
bazel_dep(
35+
name = "rules_go",
36+
version = "0.50.1",
37+
repo_name = "io_bazel_rules_go",
38+
)

proto/WORKSPACE.bzlmod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# https://bazel.build/external/migration#workspace.bzlmod
2+
#
3+
# This file is intentionally empty. When bzlmod is enabled and this
4+
# file exists, the contents of WORKSPACE.bazel is ignored. This prevents
5+
# bzlmod builds from unintentionally depending on the WORKSPACE.bazel file.

0 commit comments

Comments
 (0)