Skip to content

Commit 02be104

Browse files
committed
[Python dist] Build aarch64 in different Kokoro job
1 parent 558821b commit 02be104

File tree

9 files changed

+69
-10
lines changed

9 files changed

+69
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
us-docker.pkg.dev/grpc-testing/testing-images-public/python_alpine_aarch64:086c6b7ba4177b5c086a4e1e36019fdd1d86a061@sha256:da5d191e62811fd3470d593aa9a7c2bfc8ee7d3453db92db13d62edb2eb9f39e
1+
us-docker.pkg.dev/grpc-testing/testing-images-public/python_alpine_aarch64:78b5c9d459ceaedfa8dc8fa6dc52ce11666dd581@sha256:bcdfc865daa8c61dc6f9b67ddab63d47fcacb109ed57de5b9a7673dff907e02c

tools/dockerfile/distribtest/python_alpine_aarch64/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM python:3.10-alpine3.14
15+
# this an aarch64 image
16+
FROM arm64v8/python:3.10-alpine
1617

1718
# Our test infrastructure demands bash
1819
RUN apk update && apk add bash

tools/internal_ci/linux/grpc_distribtests_python.cfg

+5
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ action {
2424
regex: "github/grpc/artifacts/**"
2525
}
2626
}
27+
28+
env_vars {
29+
key: "TASK_RUNNER_EXTRA_FILTERS"
30+
value: "-e aarch64 musllinux_1_1"
31+
}

tools/internal_ci/linux/grpc_distribtests_python.sh

+19-6
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ cd $(dirname $0)/../../..
2323

2424
source tools/internal_ci/helper_scripts/prepare_build_linux_rc
2525

26-
# some distribtests use a pre-registered binfmt_misc hook
27-
# to automatically execute foreign binaries (such as aarch64)
28-
# under qemu emulator.
29-
source tools/internal_ci/helper_scripts/prepare_qemu_rc
26+
if [[ "${TASK_RUNNER_EXTRA_FILTERS}" == "aarch64 musllinux_1_1" ]]; then
27+
echo "Skipping prepare_qemu_rc'"
28+
else
29+
# some distribtests use a pre-registered binfmt_misc hook
30+
# to automatically execute foreign binaries (such as aarch64)
31+
# under qemu emulator.
32+
source tools/internal_ci/helper_scripts/prepare_qemu_rc
33+
fi
3034

3135
# configure ccache
3236
source tools/internal_ci/helper_scripts/prepare_ccache_rc
@@ -40,7 +44,11 @@ mkdir -p input_artifacts
4044
cp -r artifacts/* input_artifacts/ || true
4145

4246
# This step simply collects python artifacts from subdirectories of input_artifacts/ and copies them to artifacts/
43-
tools/run_tests/task_runner.py -f package linux python -x build_packages/sponge_log.xml || FAILED="true"
47+
if [[ "${TASK_RUNNER_EXTRA_FILTERS}" == "aarch64 musllinux_1_1" ]]; then
48+
tools/run_tests/task_runner.py -f package linux python ${TASK_RUNNER_EXTRA_FILTERS} -x build_packages/sponge_log.xml || FAILED="true"
49+
else
50+
tools/run_tests/task_runner.py -f package linux python -x build_packages/sponge_log.xml || FAILED="true"
51+
fi
4452

4553
# the next step expects to find the artifacts from the previous step in the "input_artifacts" folder.
4654
# in addition to that, preserve the contents of "artifacts" directory since we want kokoro
@@ -52,7 +60,12 @@ cp -r artifacts/* input_artifacts/ || true
5260
# Run all python linux distribtests
5361
# We run the distribtests even if some of the artifacts have failed to build, since that gives
5462
# a better signal about which distribtest are affected by the currently broken artifact builds.
55-
tools/run_tests/task_runner.py -f distribtest linux python ${TASK_RUNNER_EXTRA_FILTERS} -j 12 -x distribtests/sponge_log.xml || FAILED="true"
63+
if [[ "${TASK_RUNNER_EXTRA_FILTERS}" == "aarch64 musllinux_1_1" ]]; then
64+
# We're using alpine as tag in distribtest targets.
65+
tools/run_tests/task_runner.py -f distribtest linux python aarch64 alpine -j 12 -x distribtests/sponge_log.xml || FAILED="true"
66+
else
67+
tools/run_tests/task_runner.py -f distribtest linux python ${TASK_RUNNER_EXTRA_FILTERS} -j 12 -x distribtests/sponge_log.xml || FAILED="true"
68+
fi
5669

5770
# This step checks if any of the artifacts exceeds a per-file size limit.
5871
tools/internal_ci/helper_scripts/check_python_artifacts_size.sh

tools/internal_ci/linux/pull_request/grpc_examples_tests_cpp.cfg

+10
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,13 @@ action {
2323
regex: "github/grpc/reports/**"
2424
}
2525
}
26+
27+
env_vars {
28+
key: "TASK_RUNNER_EXTRA_FILTERS"
29+
value: "aarch64 -e x64 x86 armv7"
30+
}
31+
32+
# env_vars {
33+
# key: "TASK_RUNNER_EXCLUDE_FILTERS"
34+
# value: "x64 x86 armv7"
35+
# }

tools/internal_ci/linux/release/grpc_distribtests_python.cfg

+5
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ action {
2424
regex: "github/grpc/artifacts/**"
2525
}
2626
}
27+
28+
env_vars {
29+
key: "TASK_RUNNER_EXTRA_FILTERS"
30+
value: "-e aarch64 musllinux_1_1"
31+
}

tools/run_tests/artifacts/package_targets.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,18 @@ def build_jobspec(self, inner_jobs=None):
142142
class PythonPackage:
143143
"""Collects python eggs and wheels created in the artifact phase"""
144144

145-
def __init__(self):
145+
def __init__(self, platform="", arch=""):
146146
self.name = "python_package"
147147
self.labels = ["package", "python", "linux"]
148+
self.platform = platform
149+
self.arch = arch
150+
if self.platform:
151+
self.labels.append(platform)
152+
self.name += "_" + platform
153+
if self.arch:
154+
self.labels.append(arch)
155+
self.name += "_" + arch
156+
148157

149158
def pre_build_jobspecs(self):
150159
return []
@@ -154,9 +163,12 @@ def build_jobspec(self, inner_jobs=None):
154163
# since the python package build does very little, we can use virtually
155164
# any image that has new-enough python, so reusing one of the images used
156165
# for artifact building seems natural.
166+
dockerfile_dir = "tools/dockerfile/grpc_artifact_python_manylinux2014_x64"
167+
if "musllinux_1_1" in self.platform and "aarch64" in self.arch:
168+
dockerfile_dir = "tools/dockerfile/grpc_artifact_python_musllinux_1_1_aarch64"
157169
return create_docker_jobspec(
158170
self.name,
159-
"tools/dockerfile/grpc_artifact_python_manylinux2014_x64",
171+
dockerfile_dir,
160172
"tools/run_tests/artifacts/build_package_python.sh",
161173
environ={"PYTHON": "/opt/python/cp39-cp39/bin/python"},
162174
)
@@ -189,5 +201,6 @@ def targets():
189201
CSharpPackage("windows"),
190202
RubyPackage(),
191203
PythonPackage(),
204+
PythonPackage("musllinux_1_1", "aarch64"),
192205
PHPPackage(),
193206
]

tools/run_tests/python_utils/jobset.py

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def strip_non_ascii_chars(s):
4545
def sanitized_environment(env):
4646
sanitized = {}
4747
for key, value in list(env.items()):
48+
sys.stderr.write(f"strip_non_ascii_chars key: {key}, value: {value}\n"); sys.stderr.flush()
4849
sanitized[strip_non_ascii_chars(key)] = strip_non_ascii_chars(value)
4950
return sanitized
5051

tools/run_tests/task_runner.py

+11
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ def _create_build_map():
7171
default=[],
7272
help="Filter targets to build with AND semantics.",
7373
)
74+
argp.add_argument(
75+
"-e",
76+
"--exclude",
77+
choices=sorted(_BUILD_MAP.keys()),
78+
nargs="+",
79+
default=[],
80+
help="Target labels to exclude from building.",
81+
)
7482
argp.add_argument("-j", "--jobs", default=multiprocessing.cpu_count(), type=int)
7583
argp.add_argument(
7684
"-x",
@@ -106,6 +114,9 @@ def _create_build_map():
106114
# Among targets selected by -b, filter out those that don't match the filter
107115
targets = [t for t in targets if all(f in t.labels for f in args.filter)]
108116

117+
# Exclude target if it has ALL of the specified exclude labels.
118+
targets = [t for t in targets if not all(l in args.exclude for l in t.labels)]
119+
109120
print("Will build %d targets:" % len(targets))
110121
for target in targets:
111122
print(" %s, labels %s" % (target.name, target.labels))

0 commit comments

Comments
 (0)