Skip to content

Commit 9a7a9e0

Browse files
authored
enabling auto-publishing to BCR (#109)
This adds the template files so that the Publish to BCR app can publish new releases of this repo to Bazel Central Repository as Bazel modules.
1 parent ca8b93a commit 9a7a9e0

13 files changed

Lines changed: 1219 additions & 0 deletions

File tree

.bazelignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
examples

.bcr/metadata.template.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"homepage": "https://github.com/uber/hermetic_cc_toolchain",
3+
"maintainers": [
4+
{
5+
"email": "sungyoon@uber.com",
6+
"github": "sywhang",
7+
"name": "Sung Yoon Whang"
8+
},
9+
{
10+
"email": "zplin@uber.com",
11+
"github": "linzhp",
12+
"name": "Zhongpeng Lin"
13+
}
14+
],
15+
"repository": [
16+
"github:uber/hermetic_cc_toolchain"
17+
],
18+
"versions": [],
19+
"yanked_versions": {}
20+
}

.bcr/presubmit.yml

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

.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": "",
4+
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{TAG}.tar.gz"
5+
}

.buildkite/pipeline.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ steps:
2323
# command: apt-get update && apt-get install --no-install-recommends -y wine64 python3 ca-certificates && ci/zig-utils
2424
- label: "Test rules_cc example"
2525
command: ci/prepare_git && ci/test_example rules_cc
26+
- label: "Test bzlmod example"
27+
command: ci/prepare_git && ci/test_example bzlmod
2628
- label: "mod-tidy and update-repos"
2729
command: tools/mod-tidy && git diff --exit-code
2830
agents:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
/bazel-out
77
/bazel-testlogs
88
/bazel-x
9+
/examples/bzlmod/bazel-*

examples/bzlmod/.bazelrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
common --enable_bzlmod
2+
test --sandbox_default_allow_network=false
3+
test --test_output=errors
4+
5+
build --verbose_failures
6+
build --worker_sandboxing
7+
8+
build --experimental_reuse_sandbox_directories
9+
build --incompatible_enable_cc_toolchain_resolution
10+
build --action_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
11+
build --experimental_output_directory_naming_scheme=diff_against_baseline

examples/bzlmod/BUILD.bazel

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright 2023 Uber Technologies, Inc.
2+
# Licensed under the MIT License
3+
4+
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
5+
load("@hermetic_cc_toolchain//rules:platform.bzl", "platform_binary", "platform_test")
6+
7+
go_library(
8+
name = "cgo_lib",
9+
srcs = ["cgo.go"],
10+
cgo = True,
11+
importpath = "github.com/uber/hermetic_cc_toolchain/test/bzlmod",
12+
visibility = ["//visibility:private"],
13+
)
14+
15+
go_test(
16+
name = "cgo_test",
17+
srcs = ["cgo_test.go"],
18+
embed = [":cgo_lib"],
19+
)
20+
21+
go_binary(
22+
name = "cgo",
23+
embed = [":cgo_lib"],
24+
gc_linkopts = select({
25+
"@platforms//os:macos": [
26+
"-w", # https://github.com/ziglang/zig/issues/15439
27+
"-buildmode=pie", # https://github.com/ziglang/zig/issues/15438
28+
],
29+
"//conditions:default": [],
30+
}),
31+
visibility = ["//visibility:public"],
32+
)

examples/bzlmod/MODULE.bazel

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module(
2+
name = "hermetic_cc_toolchain_bcr_tests",
3+
version = "0.1.0",
4+
)
5+
6+
bazel_dep(
7+
name = "hermetic_cc_toolchain",
8+
version = "",
9+
)
10+
local_path_override(
11+
module_name = "hermetic_cc_toolchain",
12+
path = "../..",
13+
)
14+
15+
toolchains = use_extension("@hermetic_cc_toolchain//toolchain:ext.bzl", "toolchains")
16+
use_repo(toolchains, "zig_sdk")
17+
18+
register_toolchains(
19+
"@zig_sdk//toolchain:linux_amd64_gnu.2.31",
20+
"@zig_sdk//toolchain:linux_arm64_gnu.2.31",
21+
"@zig_sdk//toolchain:darwin_amd64",
22+
"@zig_sdk//toolchain:darwin_arm64",
23+
"@zig_sdk//toolchain:windows_amd64",
24+
"@zig_sdk//toolchain:windows_arm64",
25+
)
26+
27+
bazel_dep(
28+
name = "rules_go",
29+
version = "0.41.0",
30+
repo_name = "io_bazel_rules_go",
31+
)

0 commit comments

Comments
 (0)