Skip to content

Commit

Permalink
enabling auto-publishing to BCR (uber#109)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
linzhp authored Aug 22, 2023
1 parent ca8b93a commit 9a7a9e0
Show file tree
Hide file tree
Showing 13 changed files with 1,219 additions and 0 deletions.
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
examples
20 changes: 20 additions & 0 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"homepage": "https://github.com/uber/hermetic_cc_toolchain",
"maintainers": [
{
"email": "[email protected]",
"github": "sywhang",
"name": "Sung Yoon Whang"
},
{
"email": "[email protected]",
"github": "linzhp",
"name": "Zhongpeng Lin"
}
],
"repository": [
"github:uber/hermetic_cc_toolchain"
],
"versions": [],
"yanked_versions": {}
}
10 changes: 10 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
bcr_test_module:
module_path: "examples/bzlmod"
matrix:
platform: ["debian11", "macos", "macos_arm64", "ubuntu2004_arm64"]
tasks:
run_tests:
name: "Run test module"
platform: ${{ platform }}
test_targets:
- "//..."
5 changes: 5 additions & 0 deletions .bcr/source.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"integrity": "",
"strip_prefix": "",
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{TAG}.tar.gz"
}
2 changes: 2 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ steps:
# command: apt-get update && apt-get install --no-install-recommends -y wine64 python3 ca-certificates && ci/zig-utils
- label: "Test rules_cc example"
command: ci/prepare_git && ci/test_example rules_cc
- label: "Test bzlmod example"
command: ci/prepare_git && ci/test_example bzlmod
- label: "mod-tidy and update-repos"
command: tools/mod-tidy && git diff --exit-code
agents:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/bazel-out
/bazel-testlogs
/bazel-x
/examples/bzlmod/bazel-*
11 changes: 11 additions & 0 deletions examples/bzlmod/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
common --enable_bzlmod
test --sandbox_default_allow_network=false
test --test_output=errors

build --verbose_failures
build --worker_sandboxing

build --experimental_reuse_sandbox_directories
build --incompatible_enable_cc_toolchain_resolution
build --action_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
build --experimental_output_directory_naming_scheme=diff_against_baseline
32 changes: 32 additions & 0 deletions examples/bzlmod/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2023 Uber Technologies, Inc.
# Licensed under the MIT License

load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
load("@hermetic_cc_toolchain//rules:platform.bzl", "platform_binary", "platform_test")

go_library(
name = "cgo_lib",
srcs = ["cgo.go"],
cgo = True,
importpath = "github.com/uber/hermetic_cc_toolchain/test/bzlmod",
visibility = ["//visibility:private"],
)

go_test(
name = "cgo_test",
srcs = ["cgo_test.go"],
embed = [":cgo_lib"],
)

go_binary(
name = "cgo",
embed = [":cgo_lib"],
gc_linkopts = select({
"@platforms//os:macos": [
"-w", # https://github.com/ziglang/zig/issues/15439
"-buildmode=pie", # https://github.com/ziglang/zig/issues/15438
],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
)
31 changes: 31 additions & 0 deletions examples/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module(
name = "hermetic_cc_toolchain_bcr_tests",
version = "0.1.0",
)

bazel_dep(
name = "hermetic_cc_toolchain",
version = "",
)
local_path_override(
module_name = "hermetic_cc_toolchain",
path = "../..",
)

toolchains = use_extension("@hermetic_cc_toolchain//toolchain:ext.bzl", "toolchains")
use_repo(toolchains, "zig_sdk")

register_toolchains(
"@zig_sdk//toolchain:linux_amd64_gnu.2.31",
"@zig_sdk//toolchain:linux_arm64_gnu.2.31",
"@zig_sdk//toolchain:darwin_amd64",
"@zig_sdk//toolchain:darwin_arm64",
"@zig_sdk//toolchain:windows_amd64",
"@zig_sdk//toolchain:windows_arm64",
)

bazel_dep(
name = "rules_go",
version = "0.41.0",
repo_name = "io_bazel_rules_go",
)
Loading

0 comments on commit 9a7a9e0

Please sign in to comment.