Skip to content

Commit 3b69d1a

Browse files
jpopadakEdSchouten
andauthored
Upgrade Go and dependencies (#8)
* Upgrade dependencies to latest * Upgrade bazel to 8.4.1 * Start using gazelle:proto_import_prefix --------- Co-authored-by: Ed Schouten <eschouten@apple.com>
1 parent 605ebe3 commit 3b69d1a

File tree

18 files changed

+645
-402
lines changed

18 files changed

+645
-402
lines changed

.bazelrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
build --host_cxxopt=-std=c++17
21
run --workspace_status_command="bash tools/workspace-status.sh"
2+
common --enable_platform_specific_config
3+
common --incompatible_enable_proto_toolchain_resolution
4+
common --protocopt=--fatal_warnings
5+
6+
# Required to make protobuf compile on Windows
7+
common:windows --host_cxxopt=/std:c++17 --define=protobuf_allow_msvc=true

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.3.1
1+
8.4.1

.github/workflows/master.yaml

Lines changed: 101 additions & 19 deletions
Large diffs are not rendered by default.

.github/workflows/pull-requests.yaml

Lines changed: 66 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,136 @@
11
{
22
"jobs": {
33
"build_and_test": {
4-
"runs-on": "ubuntu-latest",
4+
"name": "build_and_test ${{ matrix.host.os }}",
5+
"runs-on": "${{ matrix.host.os }}",
56
"steps": [
67
{
78
"name": "Check out source code",
89
"uses": "actions/checkout@v1"
910
},
1011
{
1112
"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+
"run": "v=$(cat .bazelversion) && curl -L https://github.com/bazelbuild/bazel/releases/download/${v}/bazel-${v}-${{matrix.host.bazel_os}}-x86_64 > ~/bazel && chmod +x ~/bazel && echo ~ >> ${GITHUB_PATH}",
14+
"shell": "bash"
1315
},
1416
{
17+
"if": "matrix.host.platform_name == 'windows_amd64'",
18+
"name": "Override .bazelrc",
19+
"run": "echo \"startup --output_base=D:/bazel_output\" >> .bazelrc"
20+
},
21+
{
22+
"if": "matrix.host.lint",
1523
"name": "Bazel mod tidy",
1624
"run": "bazel mod tidy"
1725
},
1826
{
27+
"if": "matrix.host.lint",
1928
"name": "Gazelle",
2029
"run": "rm -f $(find . -name '*.pb.go' | sed -e 's/[^/]*$/BUILD.bazel/') && bazel run //:gazelle"
2130
},
2231
{
32+
"if": "matrix.host.lint",
2333
"name": "Buildifier",
2434
"run": "bazel run @com_github_bazelbuild_buildtools//:buildifier"
2535
},
2636
{
37+
"if": "matrix.host.lint",
2738
"name": "Gofmt",
2839
"run": "bazel run @cc_mvdan_gofumpt//:gofumpt -- -w -extra $(pwd)"
2940
},
3041
{
42+
"if": "matrix.host.lint",
3143
"name": "Clang format",
3244
"run": "find . -name '*.proto' -exec bazel run @llvm_toolchain_llvm//:bin/clang-format -- -i {} +"
3345
},
3446
{
47+
"if": "matrix.host.lint",
3548
"name": "GitHub workflows",
3649
"run": "bazel build //tools/github_workflows && cp bazel-bin/tools/github_workflows/*.yaml .github/workflows"
3750
},
3851
{
52+
"if": "matrix.host.lint",
3953
"name": "Protobuf generation",
4054
"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"
4155
},
4256
{
57+
"if": "matrix.host.lint",
4358
"name": "Embedded asset generation",
4459
"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"
4560
},
4661
{
62+
"if": "matrix.host.lint",
4763
"name": "Test style conformance",
4864
"run": "git add . && git diff --exit-code HEAD --"
4965
},
5066
{
67+
"if": "matrix.host.lint",
5168
"name": "Golint",
5269
"run": "bazel run @org_golang_x_lint//golint -- -set_exit_status $(pwd)/..."
5370
},
5471
{
55-
"name": "linux_amd64: build and test",
56-
"run": "bazel test --test_output=errors --platforms=@rules_go//go/toolchain:linux_amd64 //..."
72+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_amd64'",
73+
"name": "linux_amd64: build${{ matrix.host.platform_name == 'linux_amd64' && ' and test' || '' }}",
74+
"run": "bazel ${{ matrix.host.platform_name == 'linux_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_amd64 //..."
5775
},
5876
{
59-
"name": "linux_386: build and test",
60-
"run": "bazel test --test_output=errors --platforms=@rules_go//go/toolchain:linux_386 //..."
77+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_386'",
78+
"name": "linux_386: build${{ matrix.host.platform_name == 'linux_amd64' && ' and test' || '' }}",
79+
"run": "bazel ${{ matrix.host.platform_name == 'linux_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_386 //..."
6180
},
6281
{
63-
"name": "linux_arm: build and test",
64-
"run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm //..."
82+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_arm'",
83+
"name": "linux_arm: build${{ matrix.host.platform_name == 'linux_arm' && ' and test' || '' }}",
84+
"run": "bazel ${{ matrix.host.platform_name == 'linux_arm' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_arm //..."
6585
},
6686
{
67-
"name": "linux_arm64: build and test",
68-
"run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm64 //..."
87+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_arm64'",
88+
"name": "linux_arm64: build${{ matrix.host.platform_name == 'linux_arm64' && ' and test' || '' }}",
89+
"run": "bazel ${{ matrix.host.platform_name == 'linux_arm64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_arm64 //..."
6990
},
7091
{
71-
"name": "darwin_amd64: build and test",
72-
"run": "bazel build --platforms=@rules_go//go/toolchain:darwin_amd64 //..."
92+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'darwin_amd64'",
93+
"name": "darwin_amd64: build${{ matrix.host.platform_name == 'darwin_amd64' && ' and test' || '' }}",
94+
"run": "bazel ${{ matrix.host.platform_name == 'darwin_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:darwin_amd64 //..."
7395
},
7496
{
75-
"name": "darwin_arm64: build and test",
76-
"run": "bazel build --platforms=@rules_go//go/toolchain:darwin_arm64 //..."
97+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'darwin_arm64'",
98+
"name": "darwin_arm64: build${{ matrix.host.platform_name == 'darwin_arm64' && ' and test' || '' }}",
99+
"run": "bazel ${{ matrix.host.platform_name == 'darwin_arm64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:darwin_arm64 //..."
77100
},
78101
{
79-
"name": "freebsd_amd64: build and test",
80-
"run": "bazel build --platforms=@rules_go//go/toolchain:freebsd_amd64 //cmd/bb_asg_lifecycle_hook //cmd/bb_autoscaler"
102+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'freebsd_amd64'",
103+
"name": "freebsd_amd64: build${{ matrix.host.platform_name == 'freebsd_amd64' && ' and test' || '' }}",
104+
"run": "bazel ${{ matrix.host.platform_name == 'freebsd_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:freebsd_amd64 //..."
81105
},
82106
{
83-
"name": "windows_amd64: build and test",
84-
"run": "bazel build --platforms=@rules_go//go/toolchain:windows_amd64 //cmd/bb_asg_lifecycle_hook //cmd/bb_autoscaler"
107+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'windows_amd64'",
108+
"name": "windows_amd64: build${{ matrix.host.platform_name == 'windows_amd64' && ' and test' || '' }}",
109+
"run": "bazel ${{ matrix.host.platform_name == 'windows_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:windows_amd64 //..."
85110
}
86-
]
111+
],
112+
"strategy": {
113+
"matrix": {
114+
"host": [
115+
{
116+
"bazel_os": "linux",
117+
"cross_compile": true,
118+
"lint": true,
119+
"os": "ubuntu-latest",
120+
"platform_name": "linux_amd64",
121+
"upload": true
122+
},
123+
{
124+
"bazel_os": "windows",
125+
"cross_compile": false,
126+
"lint": false,
127+
"os": "windows-latest",
128+
"platform_name": "windows_amd64",
129+
"upload": false
130+
}
131+
]
132+
}
133+
}
87134
}
88135
},
89136
"name": "pull-requests",

BUILD.bazel

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
load("@gazelle//:def.bzl", "gazelle")
22

3-
# gazelle:go_naming_convention_external import
43
# gazelle:go_naming_convention_external import
54
# gazelle:prefix github.com/buildbarn/bb-autoscaler
5+
# gazelle:proto_import_prefix github.com/buildbarn/bb-autoscaler
66
# gazelle:resolve go github.com/bazelbuild/remote-apis/build/bazel/remote/execution/v2 @bazel_remote_apis//build/bazel/remote/execution/v2:remote_execution_go_proto
77
# gazelle:resolve go github.com/bazelbuild/remote-apis/build/bazel/semver @bazel_remote_apis//build/bazel/semver:semver_go_proto
88
# gazelle:resolve proto build/bazel/remote/execution/v2/remote_execution.proto @bazel_remote_apis//build/bazel/remote/execution/v2:remote_execution_proto
99
# gazelle:resolve proto go build/bazel/remote/execution/v2/remote_execution.proto @bazel_remote_apis//build/bazel/remote/execution/v2:remote_execution_go_proto
10-
# gazelle:resolve proto go pkg/proto/configuration/cloud/aws/aws.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/cloud/aws
11-
# gazelle:resolve proto go pkg/proto/configuration/global/global.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/global
12-
# gazelle:resolve proto go pkg/proto/configuration/grpc/grpc.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/grpc
13-
# gazelle:resolve proto go pkg/proto/configuration/http/http.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/http
14-
# gazelle:resolve proto pkg/proto/configuration/cloud/aws/aws.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/cloud/aws:aws_proto
15-
# gazelle:resolve proto pkg/proto/configuration/global/global.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/global:global_proto
16-
# gazelle:resolve proto pkg/proto/configuration/grpc/grpc.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/grpc:grpc_proto
17-
# gazelle:resolve proto pkg/proto/configuration/http/http.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/http:http_proto
10+
# gazelle:resolve_regexp proto github.com/buildbarn/bb-storage/(.*)/(.*)\.proto @com_github_buildbarn_bb_storage//$1:${2}_proto
11+
# gazelle:resolve_regexp proto go github.com/buildbarn/bb-storage/(.*)/(.*)\.proto @com_github_buildbarn_bb_storage//$1:$2
1812
gazelle(
1913
name = "gazelle",
2014
)

MODULE.bazel

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,28 @@ bazel_dep(name = "com_github_buildbarn_bb_storage")
66
bazel_dep(name = "com_github_buildbarn_go_xdr")
77
bazel_dep(name = "gazelle", version = "0.45.0")
88
bazel_dep(name = "jsonnet_go", version = "0.21.0")
9+
bazel_dep(name = "toolchains_protoc", version = "0.5.0") # must come BEFORE protobuf so the toolchain registration wins
910
bazel_dep(name = "protobuf", version = "31.1")
10-
bazel_dep(name = "rules_go", version = "0.56.1")
11+
bazel_dep(name = "rules_go", version = "0.57.0")
1112
bazel_dep(name = "rules_jsonnet", version = "0.7.2")
1213
bazel_dep(name = "rules_proto", version = "7.1.0")
13-
bazel_dep(name = "toolchains_llvm", version = "1.4.0")
14+
bazel_dep(name = "toolchains_llvm", version = "1.5.0")
1415

1516
git_override(
1617
module_name = "bazel_remote_apis",
17-
commit = "9ef19c6b5fbf77d6dd9d84d75fbb5a20a6b62ef1",
18+
commit = "824e1ba94b2db15f68ceff97ae6da503fbc26985",
1819
remote = "https://github.com/bazelbuild/remote-apis.git",
1920
)
2021

2122
git_override(
2223
module_name = "com_github_buildbarn_bb_remote_execution",
23-
commit = "58b88e8adfbd4cb5c32905383ef9c35ea1f9598e",
24+
commit = "78a187fdbd351f57e3db9e31e3f59161eca26b17",
2425
remote = "https://github.com/buildbarn/bb-remote-execution.git",
2526
)
2627

2728
git_override(
2829
module_name = "com_github_buildbarn_bb_storage",
29-
commit = "985dacd564471beea22d17d59f9f8876047a7ff4",
30+
commit = "1170df56abab658861ba90c0e57b58ed14b721a2",
3031
remote = "https://github.com/buildbarn/bb-storage.git",
3132
)
3233

0 commit comments

Comments
 (0)