Skip to content

Commit

Permalink
buildbuddy cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
vmagro committed Oct 24, 2024
1 parent dade0cf commit 7b615a7
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 4 deletions.
13 changes: 13 additions & 0 deletions .buckconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,16 @@

[buck2]
file_watcher = watchman
materializations = deferred
sqlite_materializer_state = true
defer_write_actions = true
hash_all_commands = true

[buck2_re_client]
action_cache_address = grpcs://remote.buildbuddy.io
engine_address = grpcs://remote.buildbuddy.io
cas_address = grpcs://remote.buildbuddy.io
http_headers = x-buildbuddy-api-key:$BUILDBUDDY_API_KEY

[build]
execution_platforms = antlir//platforms:exec-platforms
11 changes: 7 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ defaults:

jobs:
test:
runs-on:
# this runner comes with 150GB of disk space
labels: 4-core-ubuntu
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: facebook/install-dotslash@latest
- uses: dtolnay/rust-toolchain@master
with:
Expand All @@ -26,7 +25,7 @@ jobs:
mkfs.btrfs ${{ runner.temp }}/image.btrfs
sudo mount ${{ runner.temp }}/image.btrfs antlir2-out
sudo chown -R $(id -u):$(id -g) antlir2-out
- name: Install deps
- name: Install system deps
run: |
sudo apt install \
cpio jq libcap-dev systemd-container
Expand All @@ -39,6 +38,10 @@ jobs:
- name: Test target graph
run: |
./buck2 bxl //ci:test_target_graph.bxl:test_target_graph
# This secret must be attached to the first buck invocation
env:
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_CLOUD_API_KEY }}


- name: Find tests
run: |
Expand Down
26 changes: 26 additions & 0 deletions platforms/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
load("@prelude//:rules.bzl", "platform")
load("@prelude//platforms:defs.bzl", "execution_platform", "host_configuration")
load(":defs.bzl", "buildbuddy_platform", "exec_platforms")

buildbuddy_platform(
name = "buildbuddy",
cpu_configuration = "config//cpu:x86_64",
os_configuration = "config//os:linux",
visibility = ["PUBLIC"],
)

execution_platform(
name = "host",
cpu_configuration = host_configuration.cpu,
os_configuration = host_configuration.os,
use_windows_path_separators = host_info().os.is_windows,
visibility = ["PUBLIC"],
)

exec_platforms(
name = "exec-platforms",
platforms = [
":buildbuddy",
":host",
]
)
44 changes: 44 additions & 0 deletions platforms/defs.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
def _buildbuddy_platform(ctx):
constraints = {}
constraints.update(ctx.attrs.cpu_configuration[ConfigurationInfo].constraints)
constraints.update(ctx.attrs.os_configuration[ConfigurationInfo].constraints)

configuration = ConfigurationInfo(
constraints = constraints,
values = {},
)

platform = ExecutionPlatformInfo(
label = ctx.label.raw_target(),
configuration = configuration,
executor_config = CommandExecutorConfig(
local_enabled = True,
remote_enabled = True,
use_limited_hybrid = True,
remote_execution_properties = {
# "arch": ctx.attrs.cpu_configuration.label.name,
# "os": ctx.attrs.os_configuration.label.name,
},
remote_execution_use_case = "antlir",
remote_output_paths = "output_paths",
),
)

return [DefaultInfo(), platform]

buildbuddy_platform = rule(attrs = {
"cpu_configuration": attrs.dep(providers = [ConfigurationInfo]),
"os_configuration": attrs.dep(providers = [ConfigurationInfo]),
}, impl = _buildbuddy_platform)

def _exec_platforms(ctx):
return [
DefaultInfo(),
ExecutionPlatformRegistrationInfo(
platforms = [p[ExecutionPlatformInfo] for p in ctx.attrs.platforms],
),
]

exec_platforms = rule(attrs = {
"platforms": attrs.list(attrs.dep(providers = [ExecutionPlatformInfo])),
}, impl = _exec_platforms)

0 comments on commit 7b615a7

Please sign in to comment.