diff --git a/tools/dockerfile/distribtest/python_alpine_aarch64.current_version b/tools/dockerfile/distribtest/python_alpine_aarch64.current_version index a3efd8f5bcc0b..5b3080154e40a 100644 --- a/tools/dockerfile/distribtest/python_alpine_aarch64.current_version +++ b/tools/dockerfile/distribtest/python_alpine_aarch64.current_version @@ -1 +1 @@ -us-docker.pkg.dev/grpc-testing/testing-images-public/python_alpine_aarch64:086c6b7ba4177b5c086a4e1e36019fdd1d86a061@sha256:da5d191e62811fd3470d593aa9a7c2bfc8ee7d3453db92db13d62edb2eb9f39e \ No newline at end of file +us-docker.pkg.dev/grpc-testing/testing-images-public/python_alpine_aarch64:78b5c9d459ceaedfa8dc8fa6dc52ce11666dd581@sha256:bcdfc865daa8c61dc6f9b67ddab63d47fcacb109ed57de5b9a7673dff907e02c \ No newline at end of file diff --git a/tools/dockerfile/distribtest/python_alpine_aarch64/Dockerfile b/tools/dockerfile/distribtest/python_alpine_aarch64/Dockerfile index a7500e39aa557..27d25043fc704 100644 --- a/tools/dockerfile/distribtest/python_alpine_aarch64/Dockerfile +++ b/tools/dockerfile/distribtest/python_alpine_aarch64/Dockerfile @@ -12,7 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM python:3.10-alpine3.14 +# this an aarch64 image +FROM arm64v8/python:3.10-alpine # Our test infrastructure demands bash RUN apk update && apk add bash diff --git a/tools/internal_ci/linux/arm64/grpc_distribtests_python_arm64.cfg b/tools/internal_ci/linux/arm64/grpc_distribtests_python_arm64.cfg index ffc02e606df42..f166d92fd5f16 100644 --- a/tools/internal_ci/linux/arm64/grpc_distribtests_python_arm64.cfg +++ b/tools/internal_ci/linux/arm64/grpc_distribtests_python_arm64.cfg @@ -15,7 +15,7 @@ # Config file for the internal CI (in protobuf text format) # Location of the continuous shell script in repository. -build_file: "grpc/tools/internal_ci/linux/grpc_distribtests_python_arm64.sh" +build_file: "grpc/tools/internal_ci/linux/grpc_distribtests_python.sh" timeout_mins: 240 action { define_artifacts { @@ -24,3 +24,8 @@ action { regex: "github/grpc/artifacts/**" } } + +env_vars { + key: "TASK_RUNNER_EXTRA_FILTERS" + value: "aarch64 musllinux_1_1" +} diff --git a/tools/internal_ci/linux/grpc_distribtests_python.cfg b/tools/internal_ci/linux/grpc_distribtests_python.cfg index ee17d7a29202f..f7a6ea46a1f77 100644 --- a/tools/internal_ci/linux/grpc_distribtests_python.cfg +++ b/tools/internal_ci/linux/grpc_distribtests_python.cfg @@ -24,3 +24,8 @@ action { regex: "github/grpc/artifacts/**" } } + +env_vars { + key: "TASK_RUNNER_EXTRA_FILTERS" + value: "-e aarch64 musllinux_1_1" +} diff --git a/tools/internal_ci/linux/grpc_distribtests_python.sh b/tools/internal_ci/linux/grpc_distribtests_python.sh index dd5dba63dcf95..ce3541485d3ae 100755 --- a/tools/internal_ci/linux/grpc_distribtests_python.sh +++ b/tools/internal_ci/linux/grpc_distribtests_python.sh @@ -23,10 +23,19 @@ cd $(dirname $0)/../../.. source tools/internal_ci/helper_scripts/prepare_build_linux_rc -# some distribtests use a pre-registered binfmt_misc hook -# to automatically execute foreign binaries (such as aarch64) -# under qemu emulator. -source tools/internal_ci/helper_scripts/prepare_qemu_rc +IS_AARCH64_MUSL="" +if [[ "${TASK_RUNNER_EXTRA_FILTERS}" == "aarch64 musllinux_1_1" || "${TASK_RUNNER_EXTRA_FILTERS}" == "presubmit aarch64 musllinux_1_1" ]]; then + IS_AARCH64_MUSL="True" +fi + +if [[ "${IS_AARCH64_MUSL}" == "True" ]]; then + echo "Skipping prepare_qemu_rc'" +else + # some distribtests use a pre-registered binfmt_misc hook + # to automatically execute foreign binaries (such as aarch64) + # under qemu emulator. + source tools/internal_ci/helper_scripts/prepare_qemu_rc +fi # configure ccache source tools/internal_ci/helper_scripts/prepare_ccache_rc @@ -40,7 +49,12 @@ mkdir -p input_artifacts cp -r artifacts/* input_artifacts/ || true # This step simply collects python artifacts from subdirectories of input_artifacts/ and copies them to artifacts/ -tools/run_tests/task_runner.py -f package linux python -x build_packages/sponge_log.xml || FAILED="true" +if [[ "${IS_AARCH64_MUSL}" == "True" ]]; then + # Not using TASK_RUNNER_EXTRA_FILTERS since we don't have a target with presubmit tag. + tools/run_tests/task_runner.py -f package linux python musllinux_1_1 aarch64 -x build_packages/sponge_log.xml || FAILED="true" +else + tools/run_tests/task_runner.py -f package linux python -x build_packages/sponge_log.xml || FAILED="true" +fi # the next step expects to find the artifacts from the previous step in the "input_artifacts" folder. # in addition to that, preserve the contents of "artifacts" directory since we want kokoro @@ -52,7 +66,12 @@ cp -r artifacts/* input_artifacts/ || true # Run all python linux distribtests # We run the distribtests even if some of the artifacts have failed to build, since that gives # a better signal about which distribtest are affected by the currently broken artifact builds. -tools/run_tests/task_runner.py -f distribtest linux python ${TASK_RUNNER_EXTRA_FILTERS} -j 12 -x distribtests/sponge_log.xml || FAILED="true" +if [[ "${IS_AARCH64_MUSL}" == "True" ]]; then + # We're using alpine as tag in distribtest targets. + tools/run_tests/task_runner.py -f distribtest linux python aarch64 alpine -j 12 -x distribtests/sponge_log.xml || FAILED="true" +else + tools/run_tests/task_runner.py -f distribtest linux python ${TASK_RUNNER_EXTRA_FILTERS} -j 12 -x distribtests/sponge_log.xml || FAILED="true" +fi # This step checks if any of the artifacts exceeds a per-file size limit. tools/internal_ci/helper_scripts/check_python_artifacts_size.sh diff --git a/tools/internal_ci/linux/pull_request/grpc_distribtests_python.cfg b/tools/internal_ci/linux/pull_request/grpc_distribtests_python.cfg index ccc02bff0226d..7696736086d43 100644 --- a/tools/internal_ci/linux/pull_request/grpc_distribtests_python.cfg +++ b/tools/internal_ci/linux/pull_request/grpc_distribtests_python.cfg @@ -27,5 +27,5 @@ action { env_vars { key: "TASK_RUNNER_EXTRA_FILTERS" - value: "presubmit" + value: "presubmit -e aarch64 musllinux_1_1" } diff --git a/tools/internal_ci/linux/pull_request/grpc_distribtests_python_arm64.cfg b/tools/internal_ci/linux/pull_request/grpc_distribtests_python_arm64.cfg index 80f51498c0795..0eb0a74388553 100644 --- a/tools/internal_ci/linux/pull_request/grpc_distribtests_python_arm64.cfg +++ b/tools/internal_ci/linux/pull_request/grpc_distribtests_python_arm64.cfg @@ -15,7 +15,7 @@ # Config file for the internal CI (in protobuf text format) # Location of the continuous shell script in repository. -build_file: "grpc/tools/internal_ci/linux/grpc_distribtests_python_arm64.sh" +build_file: "grpc/tools/internal_ci/linux/grpc_distribtests_python.sh" timeout_mins: 240 action { define_artifacts { @@ -27,5 +27,5 @@ action { env_vars { key: "TASK_RUNNER_EXTRA_FILTERS" - value: "presubmit" + value: "presubmit aarch64 musllinux_1_1" } diff --git a/tools/internal_ci/linux/pull_request/grpc_examples_tests_cpp.cfg b/tools/internal_ci/linux/pull_request/grpc_examples_tests_cpp.cfg index 5eef82d3e3a5e..0237477b6322f 100644 --- a/tools/internal_ci/linux/pull_request/grpc_examples_tests_cpp.cfg +++ b/tools/internal_ci/linux/pull_request/grpc_examples_tests_cpp.cfg @@ -23,3 +23,13 @@ action { regex: "github/grpc/reports/**" } } + +env_vars { + key: "TASK_RUNNER_EXTRA_FILTERS" + value: "aarch64 -e x64 x86 armv7" +} + +# env_vars { +# key: "TASK_RUNNER_EXCLUDE_FILTERS" +# value: "x64 x86 armv7" +# } diff --git a/tools/internal_ci/linux/release/grpc_distribtests_python.cfg b/tools/internal_ci/linux/release/grpc_distribtests_python.cfg index 6ed2e7d67f603..bd44c7cc862e8 100644 --- a/tools/internal_ci/linux/release/grpc_distribtests_python.cfg +++ b/tools/internal_ci/linux/release/grpc_distribtests_python.cfg @@ -24,3 +24,8 @@ action { regex: "github/grpc/artifacts/**" } } + +env_vars { + key: "TASK_RUNNER_EXTRA_FILTERS" + value: "-e aarch64 musllinux_1_1" +} diff --git a/tools/run_tests/artifacts/package_targets.py b/tools/run_tests/artifacts/package_targets.py index dabfb452880d9..8cffe7b98106b 100644 --- a/tools/run_tests/artifacts/package_targets.py +++ b/tools/run_tests/artifacts/package_targets.py @@ -142,9 +142,17 @@ def build_jobspec(self, inner_jobs=None): class PythonPackage: """Collects python eggs and wheels created in the artifact phase""" - def __init__(self): + def __init__(self, platform="", arch=""): self.name = "python_package" self.labels = ["package", "python", "linux"] + self.platform = platform + self.arch = arch + if self.platform: + self.labels.append(platform) + self.name += "_" + platform + if self.arch: + self.labels.append(arch) + self.name += "_" + arch def pre_build_jobspecs(self): return [] @@ -154,9 +162,16 @@ def build_jobspec(self, inner_jobs=None): # since the python package build does very little, we can use virtually # any image that has new-enough python, so reusing one of the images used # for artifact building seems natural. + dockerfile_dir = ( + "tools/dockerfile/grpc_artifact_python_manylinux2014_x64" + ) + if "musllinux_1_1" in self.platform and "aarch64" in self.arch: + dockerfile_dir = ( + "tools/dockerfile/grpc_artifact_python_musllinux_1_1_aarch64" + ) return create_docker_jobspec( self.name, - "tools/dockerfile/grpc_artifact_python_manylinux2014_x64", + dockerfile_dir, "tools/run_tests/artifacts/build_package_python.sh", environ={"PYTHON": "/opt/python/cp39-cp39/bin/python"}, ) @@ -189,5 +204,6 @@ def targets(): CSharpPackage("windows"), RubyPackage(), PythonPackage(), + PythonPackage("musllinux_1_1", "aarch64"), PHPPackage(), ] diff --git a/tools/run_tests/task_runner.py b/tools/run_tests/task_runner.py index fb2502d2a282e..1ecaaa63a69c8 100755 --- a/tools/run_tests/task_runner.py +++ b/tools/run_tests/task_runner.py @@ -71,6 +71,14 @@ def _create_build_map(): default=[], help="Filter targets to build with AND semantics.", ) +argp.add_argument( + "-e", + "--exclude", + choices=sorted(_BUILD_MAP.keys()), + nargs="+", + default=[], + help="Target labels to exclude from building.", +) argp.add_argument("-j", "--jobs", default=multiprocessing.cpu_count(), type=int) argp.add_argument( "-x", @@ -106,6 +114,9 @@ def _create_build_map(): # Among targets selected by -b, filter out those that don't match the filter targets = [t for t in targets if all(f in t.labels for f in args.filter)] +# Exclude target if it has ALL of the specified exclude labels. +targets = [t for t in targets if not all(l in args.exclude for l in t.labels)] + print("Will build %d targets:" % len(targets)) for target in targets: print(" %s, labels %s" % (target.name, target.labels))