Skip to content

Commit 2edddd3

Browse files
committed
ci/buildifier: Install and run with bazel
Signed-off-by: Ryan Northey <ryan@synca.io>
1 parent 9be9637 commit 2edddd3

File tree

4 files changed

+43
-12
lines changed

4 files changed

+43
-12
lines changed

.bazelversion

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.2.0
1+
5.4.0

.github/workflows/format.yml

+3-10
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,10 @@ jobs:
6666
steps:
6767
- uses: actions/checkout@v2
6868

69-
- uses: actions/setup-go@v2
70-
with:
71-
go-version: '^1.16'
72-
73-
- name: Install dependencies
74-
run: |
75-
go install github.com/bazelbuild/buildtools/buildifier@latest
76-
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
77-
7869
- name: Format (buildifier)
79-
run: find . -name "WORKSPACE" -o -name "*BUILD*" -o -name "*.bzl" | xargs -n1 buildifier -mode=check
70+
run: |
71+
BAZEL_FILES="$(find . -name "WORKSPACE" -o -name "*BUILD*" -o -name "*.bzl" | xargs -I{} echo ${PWD}/{})"
72+
bazel run @com_github_bazelbuild_buildtools//buildifier -- --mode=check ${BAZEL_FILES}
8073
8174
cargo_raze:
8275
name: check format with cargo-raze

bazel/dependencies.bzl

+11-1
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,29 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
1516
load("@bazel-zig-cc//toolchain:defs.bzl", zig_register_toolchains = "register_toolchains")
1617
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
18+
load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies")
1719
load("@proxy_wasm_cpp_host//bazel/cargo/wasmsign:crates.bzl", "wasmsign_fetch_remote_crates")
1820
load("@proxy_wasm_cpp_host//bazel/cargo/wasmtime:crates.bzl", "wasmtime_fetch_remote_crates")
1921
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
2022
load("@rules_fuzzing//fuzzing:init.bzl", "rules_fuzzing_init")
2123
load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies")
2224
load("@rules_python//python:pip.bzl", "pip_install")
2325
load("@rules_rust//rust:repositories.bzl", "rust_repositories", "rust_repository_set")
26+
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains")
2427

25-
def proxy_wasm_cpp_host_dependencies():
28+
GO_VERSION = "1.20.3"
29+
30+
# Set go_version=host to use host go
31+
def proxy_wasm_cpp_host_dependencies(go_version = GO_VERSION):
2632
# Bazel extensions.
2733

34+
go_rules_dependencies()
35+
go_register_toolchains(version = go_version)
36+
gazelle_dependencies()
37+
2838
rules_foreign_cc_dependencies()
2939

3040
rules_fuzzing_dependencies()

bazel/repositories.bzl

+28
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,34 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
1919
def proxy_wasm_cpp_host_repositories():
2020
# Bazel extensions.
2121

22+
maybe(
23+
http_archive,
24+
name = "io_bazel_rules_go",
25+
sha256 = "80a98277ad1311dacd837f9b16db62887702e9f1d1c4c9f796d0121a46c8e184",
26+
urls = [
27+
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip",
28+
"https://github.com/bazelbuild/rules_go/releases/download/v0.46.1/rules_go-v0.46.0.zip",
29+
],
30+
)
31+
32+
maybe(
33+
http_archive,
34+
name = "bazel_gazelle",
35+
sha256 = "32938bda16e6700063035479063d9d24c60eda8d79fd4739563f50d331cb3209",
36+
urls = [
37+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.35.0/bazel-gazelle-v0.35.0.tar.gz",
38+
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.35.0/bazel-gazelle-v0.35.0.tar.gz",
39+
],
40+
)
41+
42+
maybe(
43+
http_archive,
44+
name = "com_github_bazelbuild_buildtools",
45+
urls = ["https://github.com/bazelbuild/buildtools/archive/v6.4.0.tar.gz"],
46+
sha256 = "05c3c3602d25aeda1e9dbc91d3b66e624c1f9fdadf273e5480b489e744ca7269",
47+
strip_prefix = "buildtools-6.4.0",
48+
)
49+
2250
maybe(
2351
http_archive,
2452
name = "bazel_skylib",

0 commit comments

Comments
 (0)