diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 9dd6d9675b..d7ca8ef05b 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -3,60 +3,168 @@ 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/..." 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 + # 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" +.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 + + 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 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..ee9c5550e8 100644 --- a/tests/BUILD +++ b/tests/BUILD @@ -7,4 +7,6 @@ licenses(["notice"]) # Apache 2.0 bazel_integration_test( name = "pip_repository_entry_points_example", timeout = "long", + # The dependencies needed for this test are not cross-platform: https://github.com/bazelbuild/rules_python/issues/260 + tags = ["fix-windows"], ) 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 )