From b88674490e05dbee5c80976dc57a1dd5a2631482 Mon Sep 17 00:00:00 2001 From: UebelAndre Date: Thu, 1 Jul 2021 21:01:10 -0700 Subject: [PATCH] Removed python test dependencies from public API --- .bazelci/presubmit.yml | 2 +- WORKSPACE | 5 ++ container/BUILD | 91 -------------------- repositories/deps.bzl | 2 - tests/container/BUILD | 91 ++++++++++++++++++++ {container => tests/container}/image_test.py | 2 +- 6 files changed, 98 insertions(+), 95 deletions(-) rename {container => tests/container}/image_test.py (99%) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 141ccb56e..f40d28b66 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -109,7 +109,6 @@ tasks: - -//tests/docker/util:test_extracted_file - -//tests/docker/util:test_extracted_file_impl # Tests included on macos - - //container:image_test - //container/go/pkg/compat:go_default_test - //container/go/pkg/oci:go_default_test - //docker/util:config_stripper_test @@ -125,6 +124,7 @@ tasks: - //tests/container:distroless_fixed_id_digest_test_impl - //tests/container:distroless_fixed_id_image_digest_test - //tests/container:distroless_fixed_id_image_digest_test_impl + - //tests/container:image_test - //tests/container:k8s_pause_arm64_digest_test - //tests/container:k8s_pause_arm64_digest_test_impl - //tests/container:pause_tar_test_0_tar_gz diff --git a/WORKSPACE b/WORKSPACE index 5a2576914..07a3919f1 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -39,6 +39,11 @@ container_deps() load("//repositories:images.bzl", test_images = "images") +# py_deps are test dependencies only +load("//repositories:py_repositories.bzl", "py_deps") + +py_deps() + test_images() load( diff --git a/container/BUILD b/container/BUILD index bc4e41e88..99821197e 100644 --- a/container/BUILD +++ b/container/BUILD @@ -50,97 +50,6 @@ py_library( visibility = ["//visibility:public"], ) -TEST_TARGETS = [ - ":base_with_entrypoint", - ":base_with_volume", - ":derivative_with_cmd", - ":derivative_with_shadowed_cmd", - ":derivative_with_volume", - ":directory_with_tar_base", - ":files_base", - ":files_with_files_base", - ":files_in_layer_with_files_base", - ":files_with_tar_base", - ":tar_base", - ":tar_with_mtimes_preserved", - ":tar_with_files_base", - ":tar_with_tar_base", - ":tars_in_layer_with_tar_base", - ":docker_tarball_base", - ":layers_with_docker_tarball_base", - # TODO(mattmoor): Re-enable once archive is visible - # "generated_tarball", - ":with_unix_epoch_creation_time", - ":with_millisecond_unix_epoch_creation_time", - ":with_rfc_3339_creation_time", - ":with_stamped_creation_time", - ":with_default_stamped_creation_time", - ":with_base_stamped_image", - ":with_env", - ":layers_with_env", - ":with_double_env", - ":with_label", - ":with_double_label", - ":with_stamp_label", - ":with_user", - ":workdir_with_tar_base", - ":link_with_files_base", - ":build_with_tag", - ":with_passwd", - ":with_passwd_tar", - ":with_group", - ":with_empty_files", - ":with_empty_dirs", - ":gen_image", - ":data_path_image", - ":no_data_path_image", - ":absolute_data_path_image", - ":root_data_path_image", - ":dummy_repository", - # TODO(mattmoor): Re-enable once archive is visible - # "extras_with_deb", - ":bundle_test", - ":stamped_bundle_test", - ":pause_based", - ":dashdash_entrypoint", - ":base_based_warning", - ":cc_based_warning", - "/pause_piecemeal:image", - "/pause_piecemeal_gz:image", - # Re-enable once https://github.com/bazelbuild/rules_d/issues/14 is fixed. - # "d_image", - ":java_image", - ":py_image", - ":py_image_with_symlinks_in_data", - ":py_image_complex", - ":war_image", - ":flat", - ":flatten_with_tarball_base", - ":nodejs_image", - ":compressed_experiment", -] - -TEST_DATA = [ - "//testdata%s.tar" % t - for t in TEST_TARGETS -] + [ - "//testdata:push_compression_gzip_fast", - "//testdata:push_compression_gzip_normal", - "//testdata:stamped_bundle_test", - "//testdata:stamp_info_file.txt", - "//tests/container:basic_windows_image.tar", -] - -py_test( - name = "image_test", - size = "medium", - srcs = ["image_test.py"], - data = TEST_DATA, - python_version = "PY3", - srcs_version = "PY3", - deps = ["@containerregistry"], -) - bzl_library( name = "bundle", srcs = ["bundle.bzl"], diff --git a/repositories/deps.bzl b/repositories/deps.bzl index 460d41150..83afd8015 100644 --- a/repositories/deps.bzl +++ b/repositories/deps.bzl @@ -20,7 +20,6 @@ repository. """ load(":go_repositories.bzl", "go_deps") -load(":py_repositories.bzl", "py_deps") def deps(): """Pull in external dependencies needed by rules in this repo. @@ -31,4 +30,3 @@ def deps(): already. """ go_deps() - py_deps() diff --git a/tests/container/BUILD b/tests/container/BUILD index 4f9707321..5758a58d3 100644 --- a/tests/container/BUILD +++ b/tests/container/BUILD @@ -878,3 +878,94 @@ bzl_library( srcs = ["pull_info_validation_test.bzl"], visibility = ["//visibility:private"], ) + +TEST_TARGETS = [ + ":base_with_entrypoint", + ":base_with_volume", + ":derivative_with_cmd", + ":derivative_with_shadowed_cmd", + ":derivative_with_volume", + ":directory_with_tar_base", + ":files_base", + ":files_with_files_base", + ":files_in_layer_with_files_base", + ":files_with_tar_base", + ":tar_base", + ":tar_with_mtimes_preserved", + ":tar_with_files_base", + ":tar_with_tar_base", + ":tars_in_layer_with_tar_base", + ":docker_tarball_base", + ":layers_with_docker_tarball_base", + # TODO(mattmoor): Re-enable once archive is visible + # "generated_tarball", + ":with_unix_epoch_creation_time", + ":with_millisecond_unix_epoch_creation_time", + ":with_rfc_3339_creation_time", + ":with_stamped_creation_time", + ":with_default_stamped_creation_time", + ":with_base_stamped_image", + ":with_env", + ":layers_with_env", + ":with_double_env", + ":with_label", + ":with_double_label", + ":with_stamp_label", + ":with_user", + ":workdir_with_tar_base", + ":link_with_files_base", + ":build_with_tag", + ":with_passwd", + ":with_passwd_tar", + ":with_group", + ":with_empty_files", + ":with_empty_dirs", + ":gen_image", + ":data_path_image", + ":no_data_path_image", + ":absolute_data_path_image", + ":root_data_path_image", + ":dummy_repository", + # TODO(mattmoor): Re-enable once archive is visible + # "extras_with_deb", + ":bundle_test", + ":stamped_bundle_test", + ":pause_based", + ":dashdash_entrypoint", + ":base_based_warning", + ":cc_based_warning", + "/pause_piecemeal:image", + "/pause_piecemeal_gz:image", + # Re-enable once https://github.com/bazelbuild/rules_d/issues/14 is fixed. + # "d_image", + ":java_image", + ":py_image", + ":py_image_with_symlinks_in_data", + ":py_image_complex", + ":war_image", + ":flat", + ":flatten_with_tarball_base", + ":nodejs_image", + ":compressed_experiment", +] + +TEST_DATA = [ + "//testdata%s.tar" % t + for t in TEST_TARGETS +] + [ + "//testdata:push_compression_gzip_fast", + "//testdata:push_compression_gzip_normal", + "//testdata:stamped_bundle_test", + "//testdata:stamp_info_file.txt", + "//tests/container:basic_windows_image.tar", +] + +py_test( + name = "image_test", + size = "medium", + srcs = ["image_test.py"], + data = TEST_DATA, + python_version = "PY3", + srcs_version = "PY3", + deps = ["@containerregistry"], +) diff --git a/container/image_test.py b/tests/container/image_test.py similarity index 99% rename from container/image_test.py rename to tests/container/image_test.py index 06abbdb0a..bf2442521 100644 --- a/container/image_test.py +++ b/tests/container/image_test.py @@ -300,7 +300,7 @@ def test_with_default_stamped_creation_time(self): # https://bazel-review.googlesource.com/c/bazel/+/48211 # Assume that any value for 'created' within a reasonable bound is fine. self.assertLessEqual(now - created, datetime.timedelta(minutes=15)) - + def test_with_base_stamped_image(self): # {BUILD_TIMESTAMP} should be the default when `stamp = True` is configured # in the base image and `creation_time` isn't explicitly defined.