Skip to content

Commit

Permalink
make build file more concise; complain about docker strategy and sudo…
Browse files Browse the repository at this point in the history
… permission weirdness; disable remote execution for pkg_tar to avoid CentOS6 Python 3.4 incompatibilty: it's just tar after all.
  • Loading branch information
nickbreen committed Sep 17, 2023
1 parent 122e442 commit cf9fe95
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 122 deletions.
14 changes: 9 additions & 5 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@ common --ui_actions_shown 64
build --incompatible_strict_action_env
build --show_result=20
build --verbose_failures
build --incompatible_enable_cc_toolchain_resolution
build --experimental_platforms_api
test --test_output=errors
test:ci --test_output=all

# Critical features required
build --incompatible_enable_cc_toolchain_resolution
build --experimental_platforms_api

# Expected that tags = ["no-remote-exec"] would have sufficed, but apparently it does not.
# So, disable remote for pkg_tar, it is allowed execute on the host.
build --strategy=PackageTar=worker,sandboxed,local

build:docker --experimental_docker_verbose
build:docker --experimental_enable_docker_sandbox
build:docker --experimental_docker_use_customized_images
build:docker --strategy=CppCompile=docker --strategy=CppLink=docker --strategy=CcStrip=docker --strategy=MakeRpm=docker --strategy=MakeDeb=docker --strategy=PackageTar=docker
build:docker --strategy=CppCompile=docker --strategy=CppLink=docker --strategy=CcStrip=docker --strategy=MakeRpm=docker --strategy=MakeDeb=docker
build:docker --experimental_docker_privileged

build:remote --bes_results_url=http://localhost:8080/invocation/
Expand All @@ -30,8 +36,6 @@ build:bb --remote_executor=grpcs://remote.buildbuddy.io
build:bb --remote_upload_local_results
build:bb --jobs=100

build --toolchain_resolution_debug=@rules_python//python:toolchain_type

# Invalidate all outputs by setting a new value for the environment variable "FUDGE".
# e.g. export FUDGE="$(date)"
build --action_env=FUDGE
Expand Down
153 changes: 36 additions & 117 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_files")
load(":defs.bzl", "platforms", "platforms_test")
load("@rules_cc//cc:defs.bzl", "cc_binary")

# Just conveniences for more concise rules below.
_rpm_platforms = [
"//platforms:centos/6",
"//platforms:centos/7",
"//platforms:fedora/37",
"//platforms:fedora/38",
"//platforms:rockylinux/8",
"//platforms:rockylinux/9",
]

_deb_platforms = [
"//platforms:debian/11",
"//platforms:debian/12",
"//platforms:ubuntu/focal",
"//platforms:ubuntu/jammy",
]

_all_platforms = _deb_platforms + _rpm_platforms

# Not built directly, but if done so will fail to build as CppCompile etcetera
# are configured to *only* build in a container.
# This *can* be built directly in an arbitrary container by overriding the
Expand All @@ -24,30 +43,8 @@ cc_binary(
platforms(
name = "hellos",
actual = ":hello",
exec_platforms = [
"//platforms:centos/6",
"//platforms:centos/7",
"//platforms:debian/11",
"//platforms:debian/12",
"//platforms:fedora/37",
"//platforms:fedora/38",
"//platforms:rockylinux/8",
"//platforms:rockylinux/9",
"//platforms:ubuntu/focal",
"//platforms:ubuntu/jammy",
],
target_platforms = [
"//platforms:centos/6",
"//platforms:centos/7",
"//platforms:debian/11",
"//platforms:debian/12",
"//platforms:fedora/37",
"//platforms:fedora/38",
"//platforms:rockylinux/8",
"//platforms:rockylinux/9",
"//platforms:ubuntu/focal",
"//platforms:ubuntu/jammy",
],
exec_platforms = _all_platforms,
target_platforms = _all_platforms,
)

# Will execute all binaries on the host platform.
Expand All @@ -72,18 +69,7 @@ sh_test(
# binary built for the matching platform.
platforms_test(
name = "platform-hello-test-suite",
platforms = [
"//platforms:centos/6",
"//platforms:centos/7",
"//platforms:debian/11",
"//platforms:debian/12",
"//platforms:fedora/37",
"//platforms:fedora/38",
"//platforms:rockylinux/8",
"//platforms:rockylinux/9",
"//platforms:ubuntu/focal",
"//platforms:ubuntu/jammy",
],
platforms = _all_platforms,
test = ":platform-hello-test",
)

Expand All @@ -102,34 +88,14 @@ pkg_tar(
srcs = [":pkg/hello"],
)

# Expand :tar to build for all platforms on each platform.
# Expand :tar to build for all platforms on the host platform! We can do this
# because it's just tar. We do it by omitting the exec_platforms.
# We have to do it for CentOS6 as it happens as its Python 3.4 is too old for
# the pkg_tar rule and it fails.
platforms(
name = "tars",
actual = ":tar",
exec_platforms = [
#"//platforms:centos/6", # CentOS6's Python 3.4 is too old for pkg_tar.
"//platforms:centos/7",
"//platforms:debian/11",
"//platforms:debian/12",
"//platforms:fedora/37",
"//platforms:fedora/38",
"//platforms:rockylinux/8",
"//platforms:rockylinux/9",
"//platforms:ubuntu/focal",
"//platforms:ubuntu/jammy",
],
target_platforms = [
#"//platforms:centos/6", # CentOS6's Python 3.4 is too old for pkg_tar.
"//platforms:centos/7",
"//platforms:debian/11",
"//platforms:debian/12",
"//platforms:fedora/37",
"//platforms:fedora/38",
"//platforms:rockylinux/8",
"//platforms:rockylinux/9",
"//platforms:ubuntu/focal",
"//platforms:ubuntu/jammy",
],
target_platforms = _all_platforms,
)

# Will extract and execute all binaries on the host platform.
Expand All @@ -153,18 +119,7 @@ sh_test(
# binary built for the matching platform.
platforms_test(
name = "platform-tar-test-suite",
platforms = [
# "//platforms:centos/6", # CentOS6's Python 3.4 is too old for pkg_tar.
"//platforms:centos/7",
"//platforms:debian/11",
"//platforms:debian/12",
"//platforms:fedora/37",
"//platforms:fedora/38",
"//platforms:rockylinux/8",
"//platforms:rockylinux/9",
"//platforms:ubuntu/focal",
"//platforms:ubuntu/jammy",
],
platforms = _all_platforms,
test = ":platform-tar-test",
)

Expand All @@ -177,7 +132,7 @@ pkg_rpm(
architecture = "x86_64",
description = "Hello GLIBC",
license = "MIT",
release = "0", # redhat family will need a el6/7/8/9 constraint to switch this on
release = "0", # TODO redhat family will need an el:6/7/8/9 constraint to switch this on as 0.elx
requires = ["glibc"],
spec_template = "//toolchains/rpmbuild:template.spec.tpl", # because RPM's suck
summary = "Hello GLIBC",
Expand All @@ -190,22 +145,8 @@ pkg_rpm(
platforms(
name = "rpms",
actual = ":rpm",
exec_platforms = [
"//platforms:centos/6",
"//platforms:centos/7",
"//platforms:fedora/37",
"//platforms:fedora/38",
"//platforms:rockylinux/8",
"//platforms:rockylinux/9",
],
target_platforms = [
"//platforms:centos/6",
"//platforms:centos/7",
"//platforms:fedora/37",
"//platforms:fedora/38",
"//platforms:rockylinux/8",
"//platforms:rockylinux/9",
],
exec_platforms = _rpm_platforms,
target_platforms = _rpm_platforms,
)

# Will install and execute all binaries on the host platform. Requires running
Expand All @@ -231,14 +172,7 @@ sh_test(
# binary built for the matching platform.
platforms_test(
name = "platform-rpm-test-suite",
platforms = [
"//platforms:centos/6",
"//platforms:centos/7",
"//platforms:fedora/37",
"//platforms:fedora/38",
"//platforms:rockylinux/8",
"//platforms:rockylinux/9",
],
platforms = _rpm_platforms,
test = ":platform-rpm-test",
)

Expand All @@ -260,18 +194,8 @@ pkg_deb(
platforms(
name = "debs",
actual = ":deb",
exec_platforms = [
"//platforms:debian/11",
"//platforms:debian/12",
"//platforms:ubuntu/focal",
"//platforms:ubuntu/jammy",
],
target_platforms = [
"//platforms:debian/11",
"//platforms:debian/12",
"//platforms:ubuntu/focal",
"//platforms:ubuntu/jammy",
],
exec_platforms = _deb_platforms,
target_platforms = _deb_platforms,
)

# Will install and execute all binaries on the host platform. Requires running
Expand All @@ -288,7 +212,7 @@ sh_test(
sh_test(
name = "platform-deb-test",
srcs = ["pkg.test.sh"],
args = ["$(rootpaths :deb)"], # pkg_deb produces two RPM files >:(
args = ["$(rootpaths :deb)"],
data = [":deb"],
)

Expand All @@ -297,11 +221,6 @@ sh_test(
# binary built for the matching platform.
platforms_test(
name = "platform-deb-test-suite",
platforms = [
"//platforms:debian/11",
"//platforms:debian/12",
"//platforms:ubuntu/focal",
"//platforms:ubuntu/jammy",
],
platforms = _deb_platforms,
test = ":platform-deb-test",
)
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,25 @@ What next?

---

Problems...

1. Failures on Ubuntu 23.04/lunar with docker provided by Ubuntu's docker.io package.

bazel test --config docker //:platform-{hello,tar,deb,rpm}-test-suite --keep_going

> FAIL: //:platform-rpm-test_0_centos/6 (see /home/nick/.cache/bazel/_bazel_nick/536d4a2f7bb7c864cad311a4771d7d40/execroot/_main/bazel-out/k8-fastbuild-ST-8ca70333f868/testlogs/platform-rpm-test_0_centos/6/test.log)
> INFO: From Testing //:platform-rpm-test_0_centos/6:
> ==================== Test output for //:platform-rpm-test_0_centos/6:
> + exec platform-rpm-test ./hello-0-0.x86_64.rpm ./hello.rpm
> + sudo rpm --install ./hello-0-0.x86_64.rpm
> sudo: /etc/sudo.conf is owned by uid 65534, should be 0
> sudo: /bin/sudo must be owned by uid 0 and have the setuid bit set
> ================================================================================
and similar for all DEB and RPM tests.

---

References:

- https://bazel.build/extending/config
Expand Down

0 comments on commit cf9fe95

Please sign in to comment.