feat: test bzlmod usage on CI (#16319)
Closes #16319
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/16319 from protocolbuffers:bcr d66845cfcb
PiperOrigin-RevId: 619939078
pull/16280/head
parent
62620979c2
commit
71e4061ace
|
@ -0,0 +1,23 @@
|
||||||
|
name: Bazel
|
||||||
|
|
||||||
|
# Controls when the action will run.
|
||||||
|
on:
|
||||||
|
# Triggers the workflow on push or pull request events but only for the main branch
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
# Cancel previous actions from the same PR or branch except 'main' branch.
|
||||||
|
# See https://docs.github.com/en/actions/using-jobs/using-concurrency and https://docs.github.com/en/actions/learn-github-actions/contexts for more info.
|
||||||
|
group: concurrency-group::${{ github.workflow }}::${{ github.event.pull_request.number > 0 && format('pr-{0}', github.event.pull_request.number) || github.ref_name }}${{ github.ref_name == 'main' && format('::{0}', github.run_id) || ''}}
|
||||||
|
cancel-in-progress: ${{ github.ref_name != 'main' }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v6
|
||||||
|
with:
|
||||||
|
folders: '["examples"]'
|
|
@ -213,3 +213,6 @@ compile_commands.json
|
||||||
|
|
||||||
# Ignore GHA NodeJS files
|
# Ignore GHA NodeJS files
|
||||||
.github/**/node_modules/
|
.github/**/node_modules/
|
||||||
|
|
||||||
|
# Ignore Bzlmod lock file until it is more stable
|
||||||
|
MODULE.bazel.lock
|
||||||
|
|
21
MODULE.bazel
21
MODULE.bazel
|
@ -1,2 +1,23 @@
|
||||||
# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel
|
# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel
|
||||||
# https://github.com/protocolbuffers/protobuf/issues/14313
|
# https://github.com/protocolbuffers/protobuf/issues/14313
|
||||||
|
module(
|
||||||
|
name = "protobuf",
|
||||||
|
compatibility_level = 1,
|
||||||
|
version = "27.0",
|
||||||
|
)
|
||||||
|
|
||||||
|
# LOWER BOUND dependency versions.
|
||||||
|
# Bzlmod follows MVS:
|
||||||
|
# https://bazel.build/versions/6.0.0/build/bzlmod#version-resolution
|
||||||
|
# Thus the highest version in their module graph is resolved.
|
||||||
|
bazel_dep(name = "abseil-cpp", repo_name = "com_google_absl", version = "20230802.0.bcr.1")
|
||||||
|
bazel_dep(name = "bazel_skylib", version = "1.4.1")
|
||||||
|
bazel_dep(name = "jsoncpp", version = "1.9.5")
|
||||||
|
bazel_dep(name = "rules_cc", version = "0.0.9")
|
||||||
|
bazel_dep(name = "rules_java", version = "4.0.0")
|
||||||
|
bazel_dep(name = "rules_jvm_external", version = "5.1")
|
||||||
|
bazel_dep(name = "rules_pkg", version = "0.7.0")
|
||||||
|
bazel_dep(name = "rules_proto", version = "4.0.0")
|
||||||
|
bazel_dep(name = "rules_python", version = "0.10.2")
|
||||||
|
bazel_dep(name = "platforms", version = "0.0.8")
|
||||||
|
bazel_dep(name = "zlib", version = "1.2.11")
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
7.1.0
|
|
@ -4,6 +4,7 @@
|
||||||
# the WORKSPACE file in the same directory with this BUILD file for an
|
# the WORKSPACE file in the same directory with this BUILD file for an
|
||||||
# example.
|
# example.
|
||||||
|
|
||||||
|
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
||||||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_proto_library")
|
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_proto_library")
|
||||||
load("@rules_java//java:defs.bzl", "java_binary", "java_lite_proto_library", "java_proto_library")
|
load("@rules_java//java:defs.bzl", "java_binary", "java_lite_proto_library", "java_proto_library")
|
||||||
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
|
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
|
||||||
|
@ -113,6 +114,14 @@ java_binary(
|
||||||
deps = [":addressbook_java_lite_proto"],
|
deps = [":addressbook_java_lite_proto"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
build_test(
|
||||||
|
name = "test",
|
||||||
|
targets = [
|
||||||
|
":add_person_cpp",
|
||||||
|
":add_person_java",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
# Files included in all source distributions
|
# Files included in all source distributions
|
||||||
pkg_files(
|
pkg_files(
|
||||||
name = "dist_files",
|
name = "dist_files",
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
"""Bazel module dependencies"""
|
||||||
|
bazel_dep(name = "protobuf", version = "0.0.0", dev_dependency = True, repo_name = "com_google_protobuf")
|
||||||
|
|
||||||
|
local_path_override(
|
||||||
|
module_name = "protobuf",
|
||||||
|
path = "..",
|
||||||
|
)
|
||||||
|
|
||||||
|
bazel_dep(name = "bazel_skylib", version = "1.0.3")
|
||||||
|
bazel_dep(name = "rules_cc", version = "0.0.1")
|
||||||
|
bazel_dep(name = "rules_java", version = "7.3.0")
|
||||||
|
bazel_dep(name = "rules_pkg", version = "0.7.0")
|
||||||
|
bazel_dep(name = "rules_proto", version = "4.0.0")
|
|
@ -28,6 +28,15 @@ local_repository(
|
||||||
path = "..",
|
path = "..",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Needed because protobuf_deps brings rules_python 0.26.0 which is broken:
|
||||||
|
# https://github.com/bazelbuild/rules_python/issues/1543
|
||||||
|
http_archive(
|
||||||
|
name = "rules_python",
|
||||||
|
sha256 = "5868e73107a8e85d8f323806e60cad7283f34b32163ea6ff1020cf27abef6036",
|
||||||
|
strip_prefix = "rules_python-0.25.0",
|
||||||
|
url = "https://github.com/bazelbuild/rules_python/releases/download/0.25.0/rules_python-0.25.0.tar.gz",
|
||||||
|
)
|
||||||
|
|
||||||
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
|
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
|
||||||
|
|
||||||
protobuf_deps()
|
protobuf_deps()
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
# This file shadows WORKSPACE in builds with `--enable_bzlmod`
|
|
@ -162,8 +162,8 @@ cc_library(
|
||||||
hdrs = ["time_util.h"],
|
hdrs = ["time_util.h"],
|
||||||
strip_include_prefix = "/src",
|
strip_include_prefix = "/src",
|
||||||
visibility = [
|
visibility = [
|
||||||
"//:__subpackages__",
|
# Needed when building from within the /examples repository
|
||||||
"@com_google_protobuf_examples//:__subpackages__",
|
"//visibility:public",
|
||||||
],
|
],
|
||||||
deps = [
|
deps = [
|
||||||
"//src/google/protobuf",
|
"//src/google/protobuf",
|
||||||
|
|
Loading…
Reference in New Issue