From 70fa5291a7b709695106566e0b3e655d1923dadd 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] fix: ci Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> --- .bazelci/presubmit.yml | 194 ++++++++++++++---- examples/BUILD | 10 +- examples/build_file_generation/.bazelrc | 5 + examples/build_file_generation/WORKSPACE | 9 + .../build_file_generation/gazelle_python.yaml | 2 +- examples/multi_python_versions/.bazelrc | 5 + examples/pip_parse_vendored/.bazelrc | 5 + python/tests/toolchains/defs.bzl | 1 + tests/BUILD | 1 + tests/pip_repository_entry_points/BUILD | 2 + 10 files changed, 187 insertions(+), 47 deletions(-) create mode 100644 examples/build_file_generation/.bazelrc create mode 100644 examples/multi_python_versions/.bazelrc create mode 100644 examples/pip_parse_vendored/.bazelrc diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 9dd6d9675b..3444a18f60 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -3,60 +3,164 @@ 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_multi_python_versions_linux: + <<: *reusable_build_test_all + name: multi_python_versions integration tests on Linux + working_directory: examples/multi_python_versions + platform: ubuntu2004 + integration_test_multi_python_versions_macos: + <<: *reusable_build_test_all + name: multi_python_versions integration tests on macOS + working_directory: examples/multi_python_versions + platform: macos + integration_test_multi_python_versions_windows: + <<: *reusable_build_test_all + name: multi_python_versions integration tests on Windows + working_directory: examples/multi_python_versions + 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 c982e251b3..b09cbfca63 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -20,29 +20,37 @@ 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 = "multi_python_versions_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/multi_python_versions/.bazelrc b/examples/multi_python_versions/.bazelrc new file mode 100644 index 0000000000..f23315a7a1 --- /dev/null +++ b/examples/multi_python_versions/.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/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"], )