From 1b64423ef308d5268e7cec698e8de671aa201785 Mon Sep 17 00:00:00 2001 From: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> Date: Tue, 11 Oct 2022 18:52:08 -0700 Subject: [PATCH 1/4] refactor: ci with multiple tasks Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> --- .bazelci/presubmit.yml | 178 +++++++++++++----- examples/BUILD | 9 +- examples/build_file_generation/.bazelrc | 5 + examples/build_file_generation/WORKSPACE | 9 + .../build_file_generation/gazelle_python.yaml | 2 +- examples/pip_parse_vendored/.bazelrc | 5 + python/tests/toolchains/defs.bzl | 1 + tests/BUILD | 1 + tests/pip_repository_entry_points/BUILD | 2 + 9 files changed, 165 insertions(+), 47 deletions(-) create mode 100644 examples/build_file_generation/.bazelrc create mode 100644 examples/pip_parse_vendored/.bazelrc diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 9dd6d9675b..8d050d99a1 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -3,60 +3,148 @@ buildifier: version: latest # keep this argument in sync with .pre-commit-config.yaml warnings: "all" -all_targets: &all_targets +.reusable_config: &reusable_config build_targets: + - "--" - "..." # As a regression test for #225, check that wheel targets still build when # their package path is qualified with the repo name. - "@rules_python//examples/wheel/..." + # Gazelle is not fully Windows compatible: https://github.com/bazelbuild/bazel-gazelle/issues/1122 + - "-//gazelle/..." build_flags: - - "--keep_going" - # We control Bazel version in integration tests, so we don't need USE_BAZEL_VERSION for tests. - skip_use_bazel_version_for_test: true + - "--keep_going" test_targets: - "--" - "..." -platforms: - ubuntu2004: - <<: *all_targets + # Gazelle is not fully Windows compatible: https://github.com/bazelbuild/bazel-gazelle/issues/1122 + - "-//gazelle/..." + test_flags: + - "--test_tag_filters=-integration-test" +.reusable_build_test_all: &reusable_build_test_all + build_targets: ["..."] + test_targets: ["..."] +tasks: + gazelle_extension: + name: Test the Gazelle extension + platform: ubuntu2004 + build_targets: ["//gazelle/..."] + test_targets: ["//gazelle/..."] + linux: + <<: *reusable_config + name: Default test on Linux + platform: ubuntu2004 macos: - <<: *all_targets + <<: *reusable_config + name: Default test on macOS + platform: macos windows: - build_targets: - - "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245 - - "..." - # Gazelle is not fully Windows compatible: https://github.com/bazelbuild/bazel-gazelle/issues/1122 - - "-//gazelle/..." - # As a regression test for #225, check that wheel targets still build when - # their package path is qualified with the repo name. - - "@rules_python//examples/wheel/..." - # We control Bazel version in integration tests, so we don't need USE_BAZEL_VERSION for tests. - skip_use_bazel_version_for_test: true - test_targets: - - "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245 - - "..." - # Gazelle is not fully Windows compatible: https://github.com/bazelbuild/bazel-gazelle/issues/1122 - - "-//gazelle/..." - # The dependencies needed for this test are not cross-platform: https://github.com/bazelbuild/rules_python/issues/260 - - "-//tests:pip_repository_entry_points_example" + <<: *reusable_config + name: Default test on Windows + platform: windows + test_flags: + - "--test_tag_filters=-integration-test,-fix-windows" + rbe: + <<: *reusable_config + name: Test on RBE + platform: rbe_ubuntu1604 test_flags: - - "--test_tag_filters=-fix-windows" - rbe_ubuntu1604: - build_targets: - - "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245 - - "..." - # We control Bazel version in integration tests, so we don't need USE_BAZEL_VERSION for tests. - skip_use_bazel_version_for_test: true - test_targets: - - "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245 - - "..." - # TODO: The toolchain tests do not currently work in RBE - - "-//python/tests/toolchains/..." - # TODO: The integration tests do not currently work on RBE - # This list is the result of `bazel query 'filter(".*_example$", attr(generator_function, bazel_integration_test, //...))'` - - "-//examples:bzlmod_example" - - "-//examples:pip_install_example" - - "-//examples:pip_parse_example" - - "-//examples:pip_parse_vendored_example" - - "-//examples:pip_repository_annotations_example" - - "-//tests:pip_repository_entry_points_example" + - "--test_tag_filters=-integration-test,-acceptance-test" + + integration_test_build_file_generation_linux: + <<: *reusable_build_test_all + name: build_file_generation integration tests on Linux + working_directory: examples/build_file_generation + platform: ubuntu2004 + integration_test_build_file_generation_macos: + <<: *reusable_build_test_all + name: build_file_generation integration tests on macOS + working_directory: examples/build_file_generation + platform: macos + integration_test_build_file_generation_windows: + <<: *reusable_build_test_all + name: build_file_generation integration tests on Windows + working_directory: examples/build_file_generation + platform: windows + + integration_test_bzlmod_linux: + <<: *reusable_build_test_all + name: bzlmod integration tests on Linux + working_directory: examples/bzlmod + platform: ubuntu2004 + integration_test_bzlmod_macos: + <<: *reusable_build_test_all + name: bzlmod integration tests on macOS + working_directory: examples/bzlmod + platform: macos + integration_test_bzlmod_windows: + <<: *reusable_build_test_all + name: bzlmod integration tests on Windows + working_directory: examples/bzlmod + platform: windows + + integration_test_pip_install_linux: + <<: *reusable_build_test_all + name: pip_install integration tests on Linux + working_directory: examples/pip_install + platform: ubuntu2004 + integration_test_pip_install_macos: + <<: *reusable_build_test_all + name: pip_install integration tests on macOS + working_directory: examples/pip_install + platform: macos + integration_test_pip_install_windows: + <<: *reusable_build_test_all + name: pip_install integration tests on Windows + working_directory: examples/pip_install + platform: windows + + integration_test_pip_parse_linux: + <<: *reusable_build_test_all + name: pip_parse integration tests on Linux + working_directory: examples/pip_parse + platform: ubuntu2004 + integration_test_pip_parse_macos: + <<: *reusable_build_test_all + name: pip_parse integration tests on macOS + working_directory: examples/pip_parse + platform: macos + integration_test_pip_parse_windows: + <<: *reusable_build_test_all + name: pip_parse integration tests on Windows + working_directory: examples/pip_parse + platform: windows + + integration_test_pip_parse_vendored_linux: + <<: *reusable_build_test_all + name: pip_parse_vendored integration tests on Linux + working_directory: examples/pip_parse_vendored + platform: ubuntu2004 + integration_test_pip_parse_vendored_macos: + <<: *reusable_build_test_all + name: pip_parse_vendored integration tests on macOS + working_directory: examples/pip_parse_vendored + platform: macos + # TODO(f0rmiga): fix this test under Windows. It needs to be consistent on + # characters across all platforms. + # integration_test_pip_parse_vendored_windows: + # <<: *reusable_build_test_all + # name: pip_parse_vendored integration tests on Windows + # working_directory: examples/pip_parse_vendored + # platform: windows + + integration_test_pip_repository_annotations_linux: + <<: *reusable_build_test_all + name: pip_repository_annotations integration tests on Linux + working_directory: examples/pip_repository_annotations + platform: ubuntu2004 + integration_test_pip_repository_annotations_macos: + <<: *reusable_build_test_all + name: pip_repository_annotations integration tests on macOS + working_directory: examples/pip_repository_annotations + platform: macos + integration_test_pip_repository_annotations_windows: + <<: *reusable_build_test_all + name: pip_repository_annotations integration tests on Windows + working_directory: examples/pip_repository_annotations + platform: windows diff --git a/examples/BUILD b/examples/BUILD index ee4d7e4861..c27ca6b92e 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -20,24 +20,31 @@ licenses(["notice"]) # Apache 2.0 bazel_integration_test( name = "pip_install_example", timeout = "long", + tags = ["integration-test"], ) bazel_integration_test( name = "pip_parse_example", timeout = "long", + tags = ["integration-test"], ) bazel_integration_test( name = "pip_parse_vendored_example", timeout = "long", - tags = ["fix-windows"], + tags = [ + "fix-windows", + "integration-test", + ], ) bazel_integration_test( name = "pip_repository_annotations_example", timeout = "long", + tags = ["integration-test"], ) bazel_integration_test( name = "bzlmod_example", + tags = ["integration-test"], ) diff --git a/examples/build_file_generation/.bazelrc b/examples/build_file_generation/.bazelrc new file mode 100644 index 0000000000..f23315a7a1 --- /dev/null +++ b/examples/build_file_generation/.bazelrc @@ -0,0 +1,5 @@ +test --test_output=errors + +# Windows requires these for multi-python support: +build --enable_runfiles +startup --windows_enable_symlinks diff --git a/examples/build_file_generation/WORKSPACE b/examples/build_file_generation/WORKSPACE index 51c923f133..63ea962920 100644 --- a/examples/build_file_generation/WORKSPACE +++ b/examples/build_file_generation/WORKSPACE @@ -48,10 +48,19 @@ local_repository( path = "../..", ) +load("@rules_python//python:repositories.bzl", "python_register_toolchains") + +python_register_toolchains( + name = "python39", + python_version = "3.9", +) + +load("@python39//:defs.bzl", "interpreter") load("@rules_python//python:pip.bzl", "pip_parse") pip_parse( name = "pip", + python_interpreter_target = interpreter, requirements_lock = "//:requirements_lock.txt", ) diff --git a/examples/build_file_generation/gazelle_python.yaml b/examples/build_file_generation/gazelle_python.yaml index a005b43d0f..8e68c1ddd0 100644 --- a/examples/build_file_generation/gazelle_python.yaml +++ b/examples/build_file_generation/gazelle_python.yaml @@ -129,4 +129,4 @@ manifest: pip_repository: name: pip incremental: true -integrity: c47bf2ca0a185cf6b8815d4a61e26e7457564e931de76c70653277e4eccfadc8 +integrity: 4b3eed2cb51741419e11bd12a4533f285d059fda8029deaf6fedfe0fcda1b782 diff --git a/examples/pip_parse_vendored/.bazelrc b/examples/pip_parse_vendored/.bazelrc new file mode 100644 index 0000000000..f23315a7a1 --- /dev/null +++ b/examples/pip_parse_vendored/.bazelrc @@ -0,0 +1,5 @@ +test --test_output=errors + +# Windows requires these for multi-python support: +build --enable_runfiles +startup --windows_enable_symlinks diff --git a/python/tests/toolchains/defs.bzl b/python/tests/toolchains/defs.bzl index 2abc1ed149..653cde6657 100644 --- a/python/tests/toolchains/defs.bzl +++ b/python/tests/toolchains/defs.bzl @@ -172,4 +172,5 @@ def acceptance_tests(): ), python_version = python_version, target_compatible_with = meta.compatible_with, + tags = ["acceptance-test"], ) diff --git a/tests/BUILD b/tests/BUILD index b37a5a4232..3d1f3b8369 100644 --- a/tests/BUILD +++ b/tests/BUILD @@ -7,4 +7,5 @@ licenses(["notice"]) # Apache 2.0 bazel_integration_test( name = "pip_repository_entry_points_example", timeout = "long", + tags = ["integration-test"], ) diff --git a/tests/pip_repository_entry_points/BUILD b/tests/pip_repository_entry_points/BUILD index 386a7cc886..20ff3f3169 100644 --- a/tests/pip_repository_entry_points/BUILD +++ b/tests/pip_repository_entry_points/BUILD @@ -28,6 +28,8 @@ py_test( "YAMLLINT_ENTRY_POINT": "$(rootpath {})".format(pip_parsed_yamllint), }, main = "pip_repository_entry_points_test.py", + # The dependencies needed for this test are not cross-platform: https://github.com/bazelbuild/rules_python/issues/260 + tags = ["fix-windows"], deps = ["@rules_python//python/runfiles"], ) From 913daf82a4503e21038d6b235e2e29af76cdd7b2 Mon Sep 17 00:00:00 2001 From: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> Date: Wed, 12 Oct 2022 08:51:17 -0700 Subject: [PATCH 2/4] fix: tags Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> --- examples/BUILD | 9 +-------- tests/BUILD | 3 ++- tests/pip_repository_entry_points/BUILD | 2 -- tools/bazel_integration_test/bazel_integration_test.bzl | 4 ++++ 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/examples/BUILD b/examples/BUILD index c27ca6b92e..ee4d7e4861 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -20,31 +20,24 @@ licenses(["notice"]) # Apache 2.0 bazel_integration_test( name = "pip_install_example", timeout = "long", - tags = ["integration-test"], ) bazel_integration_test( name = "pip_parse_example", timeout = "long", - tags = ["integration-test"], ) bazel_integration_test( name = "pip_parse_vendored_example", timeout = "long", - tags = [ - "fix-windows", - "integration-test", - ], + tags = ["fix-windows"], ) bazel_integration_test( name = "pip_repository_annotations_example", timeout = "long", - tags = ["integration-test"], ) bazel_integration_test( name = "bzlmod_example", - tags = ["integration-test"], ) diff --git a/tests/BUILD b/tests/BUILD index 3d1f3b8369..ee9c5550e8 100644 --- a/tests/BUILD +++ b/tests/BUILD @@ -7,5 +7,6 @@ licenses(["notice"]) # Apache 2.0 bazel_integration_test( name = "pip_repository_entry_points_example", timeout = "long", - tags = ["integration-test"], + # The dependencies needed for this test are not cross-platform: https://github.com/bazelbuild/rules_python/issues/260 + tags = ["fix-windows"], ) diff --git a/tests/pip_repository_entry_points/BUILD b/tests/pip_repository_entry_points/BUILD index 20ff3f3169..386a7cc886 100644 --- a/tests/pip_repository_entry_points/BUILD +++ b/tests/pip_repository_entry_points/BUILD @@ -28,8 +28,6 @@ py_test( "YAMLLINT_ENTRY_POINT": "$(rootpath {})".format(pip_parsed_yamllint), }, main = "pip_repository_entry_points_test.py", - # The dependencies needed for this test are not cross-platform: https://github.com/bazelbuild/rules_python/issues/260 - tags = ["fix-windows"], deps = ["@rules_python//python/runfiles"], ) diff --git a/tools/bazel_integration_test/bazel_integration_test.bzl b/tools/bazel_integration_test/bazel_integration_test.bzl index 92d64e5dfa..704a525adb 100644 --- a/tools/bazel_integration_test/bazel_integration_test.bzl +++ b/tools/bazel_integration_test/bazel_integration_test.bzl @@ -88,6 +88,9 @@ def bazel_integration_test(name, **kwargs): workspace_files = workspace_files, ) + tags = kwargs.pop("tags", []) + tags.append("integration-test") + py_test( name = name, srcs = [Label("//tools/bazel_integration_test:test_runner.py")], @@ -100,5 +103,6 @@ def bazel_integration_test(name, **kwargs): "_%s_config" % name, workspace_files, ], + tags = tags, **kwargs ) From a78d4265d118415b86993590f19b44c84b94dc4c Mon Sep 17 00:00:00 2001 From: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> Date: Wed, 12 Oct 2022 08:51:43 -0700 Subject: [PATCH 3/4] fix: add missing integration test to CI Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> --- .bazelci/presubmit.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 8d050d99a1..d68f663251 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -148,3 +148,21 @@ tasks: name: pip_repository_annotations integration tests on Windows working_directory: examples/pip_repository_annotations platform: windows + + integration_test_pip_repository_entry_points_linux: + <<: *reusable_build_test_all + name: pip_repository_entry_points integration tests on Linux + working_directory: tests/pip_repository_entry_points + platform: ubuntu2004 + integration_test_pip_repository_entry_points_macos: + <<: *reusable_build_test_all + name: pip_repository_entry_points integration tests on macOS + working_directory: tests/pip_repository_entry_points + platform: macos + # TODO(f0rmiga): fix me. The dependencies needed for this test are not cross-platform: + # https://github.com/bazelbuild/rules_python/issues/260 + # integration_test_pip_repository_entry_points_windows: + # <<: *reusable_build_test_all + # name: pip_repository_entry_points integration tests on Windows + # working_directory: tests/pip_repository_entry_points + # platform: windows From a892cc61bc5cca0670680cbd15b983bfddc91833 Mon Sep 17 00:00:00 2001 From: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> Date: Wed, 12 Oct 2022 08:52:13 -0700 Subject: [PATCH 4/4] fix: comment about Gazelle and Windows Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> --- .bazelci/presubmit.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index d68f663251..d7ca8ef05b 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -10,14 +10,16 @@ buildifier: # As a regression test for #225, check that wheel targets still build when # their package path is qualified with the repo name. - "@rules_python//examples/wheel/..." - # Gazelle is not fully Windows compatible: https://github.com/bazelbuild/bazel-gazelle/issues/1122 - "-//gazelle/..." build_flags: - "--keep_going" test_targets: - "--" - "..." - # Gazelle is not fully Windows compatible: https://github.com/bazelbuild/bazel-gazelle/issues/1122 + # The gazelle tests are not compatible with Windows, so we only test them + # on Linux. The build file generation, which uses this Gazelle extension, + # runs on all platforms, and is asserted by the build_file_generation + # integration tests below. - "-//gazelle/..." test_flags: - "--test_tag_filters=-integration-test"