Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rules_go; tested bazel Go version #95

Merged
merged 10 commits into from
Dec 24, 2023
42 changes: 20 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ templates:

bazel-template: &bazel-template
docker:
- image: us-docker.pkg.dev/u-root-ci/gobusybox/test-bazel:v0.0.1
- image: cimg/go:1.21
working_directory: /home/circleci/go/bazel_gobusybox
environment:
- GOPATH: "/home/circleci/go"
Expand Down Expand Up @@ -98,6 +98,9 @@ workflows:
- clean-gomod
- clean-makebb
- clean-bazel
- build-bazel
- build-bazel-cross
- build-bazel-test
- build-gopath-go118:
requires:
- clean-makebb
Expand Down Expand Up @@ -166,15 +169,6 @@ workflows:
requires:
- clean-makebb
- clean-gomod
- build-bazel:
requires:
- clean-bazel
- build-bazel-cross:
requires:
- clean-bazel
- build-bazel-test:
requires:
- clean-bazel
nightly:
triggers:
- schedule:
Expand Down Expand Up @@ -362,10 +356,11 @@ jobs:
<<: *bazel-template
steps:
- checkout
- run: go install github.com/bazelbuild/bazelisk@latest
- run:
name: run gazelle
command: |
bazel run :gazelle
bazelisk run :gazelle
git status
if [[ -n "$(git status --porcelain .)" ]]; then
echo 'BUILD files are out-of-date: run `bazel run :gazelle` and then check in the changes'
Expand All @@ -375,7 +370,7 @@ jobs:
- run:
name: sync bazel deps.bzl with src/go.mod
command: |
bazel run //:gazelle -- update-repos -from_file=src/go.mod -to_macro=deps.bzl%go_dependencies
bazelisk run //:gazelle -- update-repos -from_file=src/go.mod -to_macro=deps.bzl%go_dependencies
git status
if [[ -n "$(git status --porcelain deps.bzl)" ]]; then
echo 'go.mod deps are out of sync with deps.bzl: run '
Expand All @@ -388,7 +383,7 @@ jobs:
- run:
name: run buildifier
command: |
bazel run :buildifier -- -r .
bazelisk run :buildifier -- -r .
# For some reason, running buildifier or gazelle updates go.sum.
git checkout -- src/go.sum
git status
Expand All @@ -402,33 +397,36 @@ jobs:
<<: *bazel-template
steps:
- checkout
- run: go install github.com/bazelbuild/bazelisk@latest
- run:
name: build busybox
command: |
bazel build //src:bb
bazelisk build //src:bb
./bazel-bin/src/bb_/bb helloworld
- run:
name: build everything (amd64)
command: bazel build //src/...
command: bazelisk build //src/...

build-bazel-cross:
<<: *bazel-template
steps:
- checkout
- run: go install github.com/bazelbuild/bazelisk@latest
- run:
name: bazel cross-compile
command: |
bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64 //src:uroot_bb
bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64 //src:bb
bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm //src:uroot_bb
bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm //src:bb
bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_riscv64 //src:uroot_bb
bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_riscv64 //src:bb
bazelisk build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64 //src:uroot_bb
bazelisk build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64 //src:bb
bazelisk build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm //src:uroot_bb
bazelisk build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm //src:bb
bazelisk build --platforms=@io_bazel_rules_go//go/toolchain:linux_riscv64 //src:uroot_bb
bazelisk build --platforms=@io_bazel_rules_go//go/toolchain:linux_riscv64 //src:bb

build-bazel-test:
<<: *bazel-template
steps:
- checkout
- run: go install github.com/bazelbuild/bazelisk@latest
- run:
name: bazel test
command: bazel query 'tests(//src/...) except attr(tags, notest, //src/...)' | xargs bazel test
command: bazelisk query 'tests(//src/...) except attr(tags, notest, //src/...)' | xargs bazelisk test
11 changes: 0 additions & 11 deletions .circleci/images/test-bazel/Dockerfile

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
/makebb
/bb2
bazel-*

# for now
MODULE.bazel
MODULE.bazel.lock
1 change: 0 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
# gazelle:exclude vendortest
# gazelle:prefix github.com/u-root/gobusybox
# gazelle:go_naming_convention import

gazelle(
name = "gazelle",
)
Expand Down
16 changes: 5 additions & 11 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,31 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "io_bazel_rules_go",
sha256 = "f2dcd210c7095febe54b804bb1cd3a58fe8435a909db2ec04e31542631cf715c",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.31.0/rules_go-v0.31.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.31.0/rules_go-v0.31.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.43.0/rules_go-v0.43.0.zip",
],
)

http_archive(
name = "bazel_gazelle",
sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("//:deps.bzl", "go_dependencies")
load("@io_bazel_rules_go//extras:embed_data_deps.bzl", "go_embed_data_dependencies")

# gazelle:repository_macro deps.bzl%go_dependencies
go_dependencies()

go_rules_dependencies()

go_register_toolchains(version = "1.17")
go_register_toolchains(version = "1.20")

gazelle_dependencies()

go_embed_data_dependencies()

http_archive(
name = "com_google_protobuf",
sha256 = "9b4ee22c250fe31b16f1a24d61467e40780a3fbb9b91c3b65be2a376ed913a1a",
Expand All @@ -60,6 +53,7 @@ load("@bazel_gazelle//:deps.bzl", "go_repository")

go_repository(
name = "com_github_u-root_u-root",
commit = "5be789964f562ae78cc5e41899f26c7c01b3a645",
#commit = "5be789964f562ae78cc5e41899f26c7c01b3a645",
commit = "v0.11.0",
importpath = "github.com/u-root/u-root",
)
25 changes: 12 additions & 13 deletions deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def go_dependencies():
sum = "h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=",
version = "v1.1.1",
)

go_repository(
name = "com_github_u_root_uio",
importpath = "github.com/u-root/uio",
Expand All @@ -29,8 +28,8 @@ def go_dependencies():
go_repository(
name = "com_github_yuin_goldmark",
importpath = "github.com/yuin/goldmark",
sum = "h1:/vn0k+RBvwlxEmP5E7SZMqNxPhfMVFEJiykr15/0XKM=",
version = "v1.4.1",
sum = "h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=",
version = "v1.4.13",
)
go_repository(
name = "org_golang_x_crypto",
Expand All @@ -41,26 +40,26 @@ def go_dependencies():
go_repository(
name = "org_golang_x_mod",
importpath = "golang.org/x/mod",
sum = "h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=",
version = "v0.6.0-dev.0.20220106191415-9b9b3d81d5e3",
sum = "h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=",
version = "v0.14.0",
)
go_repository(
name = "org_golang_x_net",
importpath = "golang.org/x/net",
sum = "h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY=",
version = "v0.0.0-20211015210444-4f30a5c0130f",
sum = "h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=",
version = "v0.19.0",
)
go_repository(
name = "org_golang_x_sync",
importpath = "golang.org/x/sync",
sum = "h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=",
version = "v0.0.0-20210220032951-036812b2e83c",
sum = "h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=",
version = "v0.5.0",
)
go_repository(
name = "org_golang_x_sys",
importpath = "golang.org/x/sys",
sum = "h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0=",
version = "v0.0.0-20211019181941-9d821ace8654",
sum = "h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=",
version = "v0.15.0",
)
go_repository(
name = "org_golang_x_term",
Expand All @@ -78,8 +77,8 @@ def go_dependencies():
go_repository(
name = "org_golang_x_tools",
importpath = "golang.org/x/tools",
sum = "h1:7pRxY7wImc7ZuraadLIgpQciyWy5Lca9AfC0wRGeWyE=",
version = "v0.1.11-0.20220322213029-87a8611856c1",
sum = "h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA=",
version = "v0.16.1",
)
go_repository(
name = "org_golang_x_xerrors",
Expand Down
6 changes: 4 additions & 2 deletions src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ uroot_linux_core_cmds = [
"@com_github_u-root_u-root//cmds/core/find",
"@com_github_u-root_u-root//cmds/core/free",
"@com_github_u-root_u-root//cmds/core/fusermount",
"@com_github_u-root_u-root//cmds/core/gpgv",
# TODO: reenable when https://github.com/bazelbuild/rules_go/issues/3799 is fixed.
#"@com_github_u-root_u-root//cmds/core/gpgv",
"@com_github_u-root_u-root//cmds/core/gpt",
"@com_github_u-root_u-root//cmds/core/grep",
"@com_github_u-root_u-root//cmds/core/gzip",
Expand Down Expand Up @@ -150,7 +151,8 @@ uroot_linux_boot_cmds = [
"@com_github_u-root_u-root//cmds/boot/boot",
"@com_github_u-root_u-root//cmds/boot/fbnetboot",
"@com_github_u-root_u-root//cmds/boot/localboot",
"@com_github_u-root_u-root//cmds/boot/pxeboot",
# TODO: reenable when https://github.com/bazelbuild/rules_go/issues/3799 is fixed.
#"@com_github_u-root_u-root//cmds/boot/pxeboot",
"@com_github_u-root_u-root//cmds/boot/systemboot",
]

Expand Down
11 changes: 4 additions & 7 deletions src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ require (
github.com/google/goterm v0.0.0-20200907032337-555d40f16ae2
github.com/hashicorp/go-multierror v1.1.1
github.com/u-root/uio v0.0.0-20210528151154-e40b768296a7
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654
golang.org/x/tools v0.1.11-0.20220322213029-87a8611856c1
golang.org/x/mod v0.14.0
golang.org/x/sys v0.15.0
golang.org/x/tools v0.16.1
)

require (
github.com/hashicorp/errwrap v1.0.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
)
require github.com/hashicorp/errwrap v1.0.0 // indirect
15 changes: 7 additions & 8 deletions src/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/u-root/uio v0.0.0-20210528151154-e40b768296a7 h1:XMAtQHwKjWHIRwg+8Nj/rzUomQY1q6cM3ncA0wP8GU4=
github.com/u-root/uio v0.0.0-20210528151154-e40b768296a7/go.mod h1:LpEX5FO/cB+WF4TYGY1V5qktpaZLkKkSegbr0V4eYXA=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.1.11-0.20220322213029-87a8611856c1 h1:7pRxY7wImc7ZuraadLIgpQciyWy5Lca9AfC0wRGeWyE=
golang.org/x/tools v0.1.11-0.20220322213029-87a8611856c1/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA=
golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0=
Loading