Skip to content

Commit

Permalink
Run tests on arm64 as well
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmoor committed Oct 1, 2020
1 parent 2de28da commit 21a2ff9
Show file tree
Hide file tree
Showing 17 changed files with 220 additions and 64 deletions.
22 changes: 16 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
dist: bionic
# Not technically required but suppresses 'Ruby' in Job status message.
# This also lets us leverage GOARCH below.
language: go
jobs:
include:
- arch: amd64
env: CPU=k8
- arch: arm64
env: CPU=aarch64

install:
- export PATH=$PATH:$HOME/bin && mkdir -p $HOME/bin
- eval $(go env)
# install bazelisk as bazel to install the appropriate bazel version
- wget https://github.com/bazelbuild/bazelisk/releases/download/v1.6.1/bazelisk-linux-amd64 && chmod +x bazelisk-linux-amd64 && mv bazelisk-linux-amd64 $HOME/bin/bazel
- wget https://github.com/bazelbuild/bazelisk/releases/download/v1.6.1/bazelisk-linux-${GOARCH} && chmod +x bazelisk-linux-${GOARCH} && mv bazelisk-linux-${GOARCH} $HOME/bin/bazel

script:
- |
bazel clean --curses=no
bazel build --curses=no //package_manager:dpkg_parser.par
bazel build --curses=no //...
bazel test --curses=no --test_output=errors --test_timeout=900 //...
- bazel clean --curses=no
- bazel build --cpu=${CPU} --curses=no //package_manager:dpkg_parser.par
- bazel build --cpu=${CPU} --curses=no //...
# Run all tests tagged with our architecture:
- bazel test --cpu=${CPU} --curses=no --test_output=errors --test_timeout=900 $(bazel query 'attr("tags", "'${GOARCH}'", "//...")')
# Run all tests not tagged as "manual":
- bazel test --cpu=${CPU} --curses=no --test_output=errors --test_timeout=900 //...

notifications:
email: false
8 changes: 5 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,11 @@ http_file(
# Docker rules.
http_archive(
name = "io_bazel_rules_docker",
sha256 = "4521794f0fba2e20f3bf15846ab5e01d5332e587e9ce81629c7f96c793bb7036",
strip_prefix = "rules_docker-0.14.4",
urls = ["https://github.com/bazelbuild/rules_docker/archive/v0.14.4.tar.gz"],
# TODO(mattmoor): Replace this once it merges:
# https://github.com/bazelbuild/rules_docker/pull/1639
sha256 = "adb03ab04bfed4e9d4fc5f1c2ebc4a3beca54fdd0b27fa1ebf8612b26bb50b0e",
strip_prefix = "rules_docker-e81a0ee5c1b57d891ac8489c916db9c3818ea89c",
urls = ["https://github.com/mattmoor/rules_docker/archive/e81a0ee5c1b57d891ac8489c916db9c3818ea89c.tar.gz"],
)

load(
Expand Down
10 changes: 0 additions & 10 deletions base/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
load("@io_bazel_rules_docker//contrib:group.bzl", "group_entry", "group_file")
load("@io_bazel_rules_docker//contrib:passwd.bzl", "passwd_entry", "passwd_tar")
load("@io_bazel_rules_docker//contrib:test.bzl", "container_test")
load("@io_bazel_rules_go//go:def.bzl", "go_binary")

NOBODY = 65534

Expand Down Expand Up @@ -101,13 +100,4 @@ pkg_tar(
package_dir = "etc",
)

go_binary(
name = "check_certs",
srcs = ["testdata/check_certs.go"],
goarch = "amd64",
# Test image is linux based
goos = "linux",
pure = "on",
)

[distro_components(suffix) for suffix in DISTRO_SUFFIXES]
113 changes: 77 additions & 36 deletions base/base.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load("@io_bazel_rules_docker//contrib:test.bzl", "container_test")
load(":distro.bzl", "DISTRO_PACKAGES", "DISTRO_REPOSITORY")
load("//cacerts:cacerts.bzl", "cacerts")
load("//:checksums.bzl", "ARCHITECTURES")
load("@io_bazel_rules_go//go:def.bzl", "go_binary")

NONROOT = 65532

Expand Down Expand Up @@ -70,45 +71,85 @@ def distro_components(distro_suffix):
tars = ["//experimental/busybox:busybox_" + arch + ".tar"],
)

container_test(
name = "debug" + distro_suffix + "_test",
configs = ["testdata/debug.yaml"],
image = ":debug_root_amd64" + distro_suffix,
)
##########################################################################################
# Check that we can overlay a pure Go binary on a static base to check certificates
##########################################################################################
go_binary(
name = "check_certs_" + arch + distro_suffix,
srcs = ["testdata/check_certs.go"],
goarch = arch,
# Test image is linux based
goos = "linux",
pure = "on",
)

container_test(
name = "base" + distro_suffix + "_test",
configs = ["testdata/base.yaml"],
image = ":base_root_amd64" + distro_suffix,
)
container_image(
name = "check_certs_image_" + arch + distro_suffix,
base = "//base:static_root_" + arch + distro_suffix,
files = [":check_certs_" + arch + distro_suffix],
symlinks = {
"/check_certs": "check_certs_" + arch + distro_suffix,
},
visibility = ["//visibility:private"],
)

container_image(
name = "check_certs_image" + distro_suffix,
base = "//base:base_root_amd64" + distro_suffix,
files = [":check_certs"],
visibility = ["//visibility:private"],
)
container_test(
name = "static_" + arch + distro_suffix + "_test",
configs = ["testdata/static.yaml"],
image = ":check_certs_image_" + arch + distro_suffix,
tags = ["manual", arch],
)

container_test(
name = "certs" + distro_suffix + "_test",
configs = ["testdata/certs.yaml"],
image = ":check_certs_image" + distro_suffix,
)
##########################################################################################
# Check that we can invoke openssl in the base image to check certificates.
##########################################################################################
container_test(
name = "openssl_" + arch + distro_suffix + "_test",
configs = ["testdata/certs.yaml"],
image = ":base_root_" + arch + distro_suffix,
tags = ["manual", arch],
)

container_test(
name = "base_release" + distro_suffix + "_test",
configs = ["testdata/" + distro_suffix[1:] + ".yaml"],
image = ":base_root_amd64" + distro_suffix,
)
##########################################################################################
# Check for common base files.
##########################################################################################
container_test(
name = "base_" + arch + distro_suffix + "_test",
configs = ["testdata/base.yaml"],
image = ":base_root_" + arch + distro_suffix,
tags = ["manual", arch],
)

container_test(
name = "debug_release" + distro_suffix + "_test",
configs = ["testdata/" + distro_suffix[1:] + ".yaml"],
image = ":debug_root_amd64" + distro_suffix,
)
##########################################################################################
# Check for busybox
##########################################################################################
container_test(
name = "debug_" + arch + distro_suffix + "_test",
configs = ["testdata/debug.yaml"],
image = ":debug_root_" + arch + distro_suffix,
tags = ["manual", arch],
)

container_test(
name = "static_release" + distro_suffix + "_test",
configs = ["testdata/" + distro_suffix[1:] + ".yaml"],
image = ":static_root_amd64" + distro_suffix,
)
##########################################################################################
# Check the /etc/os-release contents.
##########################################################################################
container_test(
name = "base_release_" + arch + distro_suffix + "_test",
configs = ["testdata/" + distro_suffix[1:] + ".yaml"],
image = ":base_root_" + arch + distro_suffix,
tags = ["manual", arch],
)

container_test(
name = "debug_release_" + arch + distro_suffix + "_test",
configs = ["testdata/" + distro_suffix[1:] + ".yaml"],
image = ":debug_root_" + arch + distro_suffix,
tags = ["manual", arch],
)

container_test(
name = "static_release_" + arch + distro_suffix + "_test",
configs = ["testdata/" + distro_suffix[1:] + ".yaml"],
image = ":static_root_" + arch + distro_suffix,
tags = ["manual", arch],
)
4 changes: 0 additions & 4 deletions base/testdata/certs.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
schemaVersion: "1.0.0"
commandTests:
# Check that Go programs can read the certificates
- name: certs
command: ["/check_certs"]
exitCode: 0
# Check that libssl finds the certificates
- name: openssl verify google
command: ["openssl", "s_client", "-strict", "-verify_return_error", "-connect", "www.google.com:443"]
Expand Down
6 changes: 6 additions & 0 deletions base/testdata/static.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
schemaVersion: "1.0.0"
commandTests:
# Check that Go programs can read the certificates
- name: certs
command: ["/check_certs"]
exitCode: 0
11 changes: 11 additions & 0 deletions cpus/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
load("//:checksums.bzl", "ARCHITECTURES")

config_setting(
name = "aarch64",
values = {"cpu": "aarch64"},
)

config_setting(
name = "k8",
values = {"cpu": "k8"},
)
4 changes: 4 additions & 0 deletions examples/cc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ load("@io_bazel_rules_docker//contrib:test.bzl", "container_test")
size = "small",
configs = ["testdata/hello.yaml"],
image = ":hello" + distro_suffix,
tags = [
"amd64",
"manual",
],
) for distro_suffix in DISTRO_SUFFIXES]
4 changes: 4 additions & 0 deletions examples/dotnet/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ load("@io_bazel_rules_docker//contrib:test.bzl", "container_test")
size = "small",
configs = ["testdata/hello" + suffix + ".yaml"],
image = ":hello" + suffix,
tags = [
"amd64",
"manual",
],
) for suffix in ("_debian10", "_core_aspnet_debian10", "_core_runtime_debian10", "_core_sdk_debian10")]
4 changes: 4 additions & 0 deletions examples/java/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ load("@io_bazel_rules_docker//contrib:test.bzl", "container_test")
size = "small",
configs = ["testdata/hello" + distro_suffix + ".yaml"],
image = ":hello" + distro_suffix,
tags = [
"amd64",
"manual",
],
) for distro_suffix in DISTRO_SUFFIXES]
4 changes: 4 additions & 0 deletions examples/nodejs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ load("@io_bazel_rules_docker//contrib:test.bzl", "container_test")
name = "hello" + distro_suffix + "_test",
configs = ["testdata/hello.yaml"],
image = ":hello" + distro_suffix,
tags = [
"amd64",
"manual",
],
) for distro_suffix in DISTRO_SUFFIXES]
4 changes: 4 additions & 0 deletions examples/nonroot/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,9 @@ go_binary(
name = "check_user" + distro_suffix + "_test",
configs = ["testdata/user.yaml"],
image = ":check_user_image" + distro_suffix,
tags = [
"amd64",
"manual",
],
visibility = ["//visibility:private"],
) for distro_suffix in DISTRO_SUFFIXES]
10 changes: 5 additions & 5 deletions examples/rust/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ load("@io_bazel_rules_docker//rust:image.bzl", "rust_image")

# NOTE: Bazel Rust rules don't support cross-compilation yet,
# so at this time it's required that you build on the same platform as the image
rust_image(
name = "rust_example",
srcs = ["src/main.rs"],
base = "//cc:cc_debian10",
)
# rust_image(
# name = "rust_example",
# srcs = ["src/main.rs"],
# base = "//cc:cc_debian10",
# )
24 changes: 24 additions & 0 deletions experimental/python2.7/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ DISTRO_DEBS = {
name = "python27" + distro_suffix + "_test",
configs = ["testdata/python27.yaml"],
image = ":python27" + distro_suffix,
tags = [
"amd64",
"manual",
],
) for distro_suffix in ("_debian9", "_debian10")]

# tests for version-specific things
Expand All @@ -74,13 +78,21 @@ container_test(
size = "medium",
configs = ["testdata/debian9.yaml"],
image = ":python27_debian9",
tags = [
"amd64",
"manual",
],
)

container_test(
name = "debian10_test",
size = "medium",
configs = ["testdata/debian10.yaml"],
image = ":python27_debian10",
tags = [
"amd64",
"manual",
],
)

genrule(
Expand All @@ -95,13 +107,21 @@ sh_binary(
name = "generate_ldconfig_cache",
srcs = ["generate_ldconfig_cache.py"],
data = [":python27_debian9"],
tags = [
"amd64",
"manual",
],
)

genrule(
name = "ld_so_cache_new",
srcs = [":python27_debian9"],
outs = ["ld.so.cache.new"],
cmd = "$(location :generate_ldconfig_cache) $(OUTS)",
tags = [
"amd64",
"manual",
],
tools = [":generate_ldconfig_cache"],
)

Expand All @@ -116,4 +136,8 @@ sh_test(
":ld.so.cache",
":ld.so.cache.new",
],
tags = [
"amd64",
"manual",
],
)
12 changes: 12 additions & 0 deletions experimental/python3/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ DISTRO_VERSION = {
size = "medium",
configs = ["testdata/python3.yaml"],
image = ":python3" + distro_suffix,
tags = [
"amd64",
"manual",
],
) for distro_suffix in ("_debian9", "_debian10")]

# tests for version-specific things
Expand All @@ -94,12 +98,20 @@ DISTRO_VERSION = {
size = "medium",
configs = ["testdata/debian9.yaml"],
image = ":python3" + user + "_debian9",
tags = [
"amd64",
"manual",
],
),
container_test(
name = "debian10" + user + "_test",
size = "medium",
configs = ["testdata/debian10.yaml"],
image = ":python3" + user + "_debian10",
tags = [
"amd64",
"manual",
],
),
] for user in [
"",
Expand Down
Loading

0 comments on commit 21a2ff9

Please sign in to comment.