Skip to content

Commit 7157c36

Browse files
committed
Add CI
1 parent c59c9c9 commit 7157c36

File tree

23 files changed

+1357
-279
lines changed

23 files changed

+1357
-279
lines changed

.github/workflows/master.yaml

+697
Large diffs are not rendered by default.

.github/workflows/pull-requests.yaml

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
{
2+
"jobs": {
3+
"build_and_test": {
4+
"runs-on": "ubuntu-latest",
5+
"steps": [
6+
{
7+
"name": "Check out source code",
8+
"uses": "actions/checkout@v1"
9+
},
10+
{
11+
"name": "Installing Bazel",
12+
"run": "v=$(cat .bazelversion) && curl -L https://github.com/bazelbuild/bazel/releases/download/${v}/bazel-${v}-linux-x86_64 > ~/bazel && chmod +x ~/bazel && echo ~ >> ${GITHUB_PATH}"
13+
},
14+
{
15+
"name": "Bazel mod tidy",
16+
"run": "bazel mod tidy"
17+
},
18+
{
19+
"name": "Gazelle",
20+
"run": "rm -f $(find . -name '*.pb.go' | sed -e 's/[^/]*$/BUILD.bazel/') && bazel run //:gazelle"
21+
},
22+
{
23+
"name": "Buildifier",
24+
"run": "bazel run @com_github_bazelbuild_buildtools//:buildifier"
25+
},
26+
{
27+
"name": "Gofmt",
28+
"run": "bazel run @cc_mvdan_gofumpt//:gofumpt -- -w -extra $(pwd)"
29+
},
30+
{
31+
"name": "Clang format",
32+
"run": "find . -name '*.proto' -exec bazel run @llvm_toolchain_llvm//:bin/clang-format -- -i {} +"
33+
},
34+
{
35+
"name": "GitHub workflows",
36+
"run": "bazel build //tools/github_workflows && cp bazel-bin/tools/github_workflows/*.yaml .github/workflows"
37+
},
38+
{
39+
"name": "Protobuf generation",
40+
"run": "if [ -d pkg/proto ]; then\n find . bazel-bin/pkg/proto -name '*.pb.go' -delete || true\n bazel build $(bazel query --output=label 'kind(\"go_proto_library\", //...)')\n find bazel-bin/pkg/proto -name '*.pb.go' | while read f; do\n cat $f > $(echo $f | sed -e 's|.*/pkg/proto/|pkg/proto/|')\n done\nfi\n"
41+
},
42+
{
43+
"name": "Embedded asset generation",
44+
"run": "bazel build $(git grep '^[[:space:]]*//go:embed ' | sed -e 's|\\(.*\\)/.*//go:embed |//\\1:|; s|\"||g; s| .*||' | sort -u)\ngit grep '^[[:space:]]*//go:embed ' | sed -e 's|\\(.*\\)/.*//go:embed |\\1/|' | while read o; do\n if [ -e \"bazel-bin/$o\" ]; then\n rm -rf \"$o\"\n cp -r \"bazel-bin/$o\" \"$o\"\n find \"$o\" -type f -exec chmod -x {} +\n fi\ndone\n"
45+
},
46+
{
47+
"name": "Test style conformance",
48+
"run": "git add . && git diff --exit-code HEAD --"
49+
},
50+
{
51+
"name": "linux_amd64: build and test",
52+
"run": "bazel test --test_output=errors --platforms=@rules_go//go/toolchain:linux_amd64 //..."
53+
},
54+
{
55+
"name": "linux_386: build and test",
56+
"run": "bazel test --test_output=errors --platforms=@rules_go//go/toolchain:linux_386 //..."
57+
},
58+
{
59+
"name": "linux_arm: build and test",
60+
"run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm //..."
61+
},
62+
{
63+
"name": "linux_arm64: build and test",
64+
"run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm64 //..."
65+
},
66+
{
67+
"name": "darwin_amd64: build and test",
68+
"run": "bazel build --platforms=@rules_go//go/toolchain:darwin_amd64 //..."
69+
},
70+
{
71+
"name": "darwin_arm64: build and test",
72+
"run": "bazel build --platforms=@rules_go//go/toolchain:darwin_arm64 //..."
73+
},
74+
{
75+
"name": "freebsd_amd64: build and test",
76+
"run": "bazel build --platforms=@rules_go//go/toolchain:freebsd_amd64 //cmd/bonanza_bazel //cmd/bonanza_builder //cmd/bonanza_scheduler //cmd/bonanza_storage_frontend //cmd/bonanza_storage_shard //cmd/bonanza_worker"
77+
},
78+
{
79+
"name": "windows_amd64: build and test",
80+
"run": "bazel build --platforms=@rules_go//go/toolchain:windows_amd64 //cmd/bonanza_bazel //cmd/bonanza_builder //cmd/bonanza_scheduler //cmd/bonanza_storage_frontend //cmd/bonanza_storage_shard //cmd/bonanza_worker"
81+
}
82+
]
83+
}
84+
},
85+
"name": "pull-requests",
86+
"on": {
87+
"pull_request": {
88+
"branches": [
89+
"main",
90+
"master"
91+
]
92+
}
93+
}
94+
}

BUILD.bazel

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
12
load("@gazelle//:def.bzl", "gazelle")
23

34
exports_files(["LICENSE"])
@@ -22,3 +23,7 @@ exports_files(["LICENSE"])
2223
gazelle(
2324
name = "gazelle",
2425
)
26+
27+
buildifier(
28+
name = "buildifier",
29+
)

MODULE.bazel

+19-6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ bazel_dep(name = "gazelle", version = "0.42.0")
99
bazel_dep(name = "googleapis", version = "0.0.0-20241220-5e258e33")
1010
bazel_dep(name = "protobuf", version = "29.3")
1111
bazel_dep(name = "rules_go", version = "0.53.0")
12+
bazel_dep(name = "rules_jsonnet", version = "0.6.0")
1213
bazel_dep(name = "rules_proto", version = "7.1.0")
1314
bazel_dep(name = "toolchains_llvm", version = "1.3.0")
1415

@@ -27,6 +28,7 @@ git_override(
2728
git_override(
2829
module_name = "com_github_buildbarn_bb_storage",
2930
commit = "85aafcb236ac1365a693d9390a6813db99dbaa0f",
31+
patches = ["//:patches/com_github_buildbarn_bb_storage/no-golint.diff"],
3032
remote = "https://github.com/buildbarn/bb-storage.git",
3133
)
3234

@@ -62,6 +64,7 @@ go_deps.from_file(go_mod = "//:go.mod")
6264
use_repo(
6365
go_deps,
6466
"cc_mvdan_gofumpt",
67+
"com_github_bazelbuild_buildtools",
6568
"com_github_bluekeyes_go_gitdiff",
6669
"com_github_buildbarn_go_cdc",
6770
"com_github_google_uuid",
@@ -83,11 +86,25 @@ use_repo(
8386
)
8487

8588
go_deps_dev = use_extension("@gazelle//:extensions.bzl", "go_deps", dev_dependency = True)
89+
go_deps_dev.module_override(
90+
patches = ["//:patches/com_github_bluekeyes_go_gitdiff/no-drop-a-b-slash.diff"],
91+
path = "github.com/bluekeyes/go-gitdiff",
92+
)
93+
go_deps_dev.gazelle_override(
94+
build_file_generation = "on",
95+
path = "github.com/cncf/xds/go",
96+
)
97+
go_deps_dev.module_override(
98+
patches = ["@com_github_buildbarn_bb_storage//:patches/com_github_grpc_ecosystem_go_grpc_prometheus/client-metrics-prevent-handled-twice.diff"],
99+
path = "github.com/grpc-ecosystem/go-grpc-prometheus",
100+
)
86101
go_deps_dev.module_override(
87102
patches = [
88-
"//:patches/com_github_bluekeyes_go_gitdiff/no-drop-a-b-slash.diff",
103+
"@com_github_buildbarn_bb_remote_execution//:patches/com_github_hanwen_go_fuse_v2/direntrylist-offsets-and-testability.diff",
104+
"@com_github_buildbarn_bb_remote_execution//:patches/com_github_hanwen_go_fuse_v2/writeback-cache.diff",
105+
"@com_github_buildbarn_bb_remote_execution//:patches/com_github_hanwen_go_fuse_v2/notify-testability.diff",
89106
],
90-
path = "github.com/bluekeyes/go-gitdiff",
107+
path = "github.com/hanwen/go-fuse/v2",
91108
)
92109
go_deps_dev.module_override(
93110
patches = ["@com_github_buildbarn_bb_storage//:patches/org_golang_x_sys/o-search.diff"],
@@ -111,10 +128,6 @@ go_deps_dev.module_override(
111128
],
112129
path = "go.starlark.net",
113130
)
114-
go_deps_dev.gazelle_override(
115-
build_file_generation = "on",
116-
path = "github.com/cncf/xds/go",
117-
)
118131

119132
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm", dev_dependency = True)
120133
llvm.toolchain(

cmd/bonanza_builder/BUILD.bazel

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@com_github_buildbarn_bb_storage//tools:container.bzl", "container_push_official", "multiarch_go_image")
12
load("@rules_go//go:def.bzl", "go_binary", "go_library")
23

34
go_library(
@@ -46,3 +47,14 @@ go_binary(
4647
embed = [":bonanza_builder_lib"],
4748
visibility = ["//visibility:public"],
4849
)
50+
51+
multiarch_go_image(
52+
name = "bonanza_builder_container",
53+
binary = ":bonanza_builder",
54+
)
55+
56+
container_push_official(
57+
name = "bonanza_builder_container_push",
58+
component = "bonanza-builder",
59+
image = ":bonanza_builder_container",
60+
)

cmd/bonanza_scheduler/BUILD.bazel

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@com_github_buildbarn_bb_storage//tools:container.bzl", "container_push_official", "multiarch_go_image")
12
load("@rules_go//go:def.bzl", "go_binary", "go_library")
23

34
go_library(
@@ -30,3 +31,14 @@ go_binary(
3031
embed = [":bonanza_scheduler_lib"],
3132
visibility = ["//visibility:public"],
3233
)
34+
35+
multiarch_go_image(
36+
name = "bonanza_scheduler_container",
37+
binary = ":bonanza_scheduler",
38+
)
39+
40+
container_push_official(
41+
name = "bonanza_scheduler_container_push",
42+
component = "bonanza-scheduler",
43+
image = ":bonanza_scheduler_container",
44+
)

cmd/bonanza_storage_frontend/BUILD.bazel

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@com_github_buildbarn_bb_storage//tools:container.bzl", "container_push_official", "multiarch_go_image")
12
load("@rules_go//go:def.bzl", "go_binary", "go_library")
23

34
go_library(
@@ -37,3 +38,14 @@ go_binary(
3738
embed = [":bonanza_storage_frontend_lib"],
3839
visibility = ["//visibility:public"],
3940
)
41+
42+
multiarch_go_image(
43+
name = "bonanza_storage_frontend_container",
44+
binary = ":bonanza_storage_frontend",
45+
)
46+
47+
container_push_official(
48+
name = "bonanza_storage_frontend_container_push",
49+
component = "bonanza-storage-frontend",
50+
image = ":bonanza_storage_frontend_container",
51+
)

cmd/bonanza_storage_shard/BUILD.bazel

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@com_github_buildbarn_bb_storage//tools:container.bzl", "container_push_official", "multiarch_go_image")
12
load("@rules_go//go:def.bzl", "go_binary", "go_library")
23

34
go_library(
@@ -31,3 +32,14 @@ go_binary(
3132
embed = [":bonanza_storage_shard_lib"],
3233
visibility = ["//visibility:public"],
3334
)
35+
36+
multiarch_go_image(
37+
name = "bonanza_storage_shard_container",
38+
binary = ":bonanza_storage_shard",
39+
)
40+
41+
container_push_official(
42+
name = "bonanza_storage_shard_container_push",
43+
component = "bonanza-storage-shard",
44+
image = ":bonanza_storage_shard_container",
45+
)

cmd/bonanza_worker/BUILD.bazel

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@com_github_buildbarn_bb_storage//tools:container.bzl", "container_push_official", "multiarch_go_image")
12
load("@rules_go//go:def.bzl", "go_binary", "go_library")
23

34
go_library(
@@ -36,3 +37,14 @@ go_binary(
3637
embed = [":bonanza_worker_lib"],
3738
visibility = ["//visibility:public"],
3839
)
40+
41+
multiarch_go_image(
42+
name = "bonanza_worker_container",
43+
binary = ":bonanza_worker",
44+
)
45+
46+
container_push_official(
47+
name = "bonanza_worker_container_push",
48+
component = "bonanza-worker",
49+
image = ":bonanza_worker_container",
50+
)

0 commit comments

Comments
 (0)