From ea3f644eefc0afb7ab66806e33a6b5189ff8f5f3 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Tue, 4 Feb 2025 10:51:13 -0800 Subject: [PATCH] Replace Kokoro ARM build with GitHub Actions The Kokoro aarch64 build runs on x86 with an emulator, and has always been flaky due to the slow execution speed. At present it is continually failing due to deadline exceededs. GitHub Actions is running on aarch64 hardware, so is much faster (4 minutes vs 30 minutes, without including the speedup from GitHub Action's caching). --- .github/workflows/branch-testing.yml | 41 ++++++++++++++++++++ buildscripts/kokoro/linux_aarch64.cfg | 13 ------- buildscripts/kokoro/linux_aarch64.sh | 17 -------- buildscripts/qemu_helpers/prepare_qemu.sh | 26 ------------- buildscripts/run_arm64_tests_in_docker.sh | 47 ----------------------- 5 files changed, 41 insertions(+), 103 deletions(-) create mode 100644 .github/workflows/branch-testing.yml delete mode 100644 buildscripts/kokoro/linux_aarch64.cfg delete mode 100755 buildscripts/kokoro/linux_aarch64.sh delete mode 100755 buildscripts/qemu_helpers/prepare_qemu.sh delete mode 100755 buildscripts/run_arm64_tests_in_docker.sh diff --git a/.github/workflows/branch-testing.yml b/.github/workflows/branch-testing.yml new file mode 100644 index 0000000000..ece8ec4cd5 --- /dev/null +++ b/.github/workflows/branch-testing.yml @@ -0,0 +1,41 @@ +name: GitHub Actions Branch Testing + +on: + push: + branches: + - master + - 'v1.*' + schedule: + - cron: '54 19 * * SUN' # weekly at a "random" time + +permissions: + contents: read + +jobs: + arm64: + runs-on: ubuntu-24.04-arm + strategy: + matrix: + jre: [17] + fail-fast: false # Should swap to true if we grow a large matrix + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.jre }} + distribution: 'temurin' + + - name: Gradle cache + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Build + run: ./gradlew -Dorg.gradle.parallel=true -Dorg.gradle.jvmargs='-Xmx1g' -PskipAndroid=true -PskipCodegen=true -PerrorProne=false test + diff --git a/buildscripts/kokoro/linux_aarch64.cfg b/buildscripts/kokoro/linux_aarch64.cfg deleted file mode 100644 index 325d910c5e..0000000000 --- a/buildscripts/kokoro/linux_aarch64.cfg +++ /dev/null @@ -1,13 +0,0 @@ -# Config file for internal CI - -# Location of the continuous shell script in repository. -build_file: "grpc-java/buildscripts/kokoro/linux_aarch64.sh" -timeout_mins: 60 - -action { - define_artifacts { - regex: "github/grpc-java/**/build/test-results/**/sponge_log.xml" - regex: "github/grpc-java/mvn-artifacts/**" - regex: "github/grpc-java/artifacts/**" - } -} diff --git a/buildscripts/kokoro/linux_aarch64.sh b/buildscripts/kokoro/linux_aarch64.sh deleted file mode 100755 index f4a1292efb..0000000000 --- a/buildscripts/kokoro/linux_aarch64.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -set -veux -o pipefail - -if [[ -f /VERSION ]]; then - cat /VERSION -fi - -readonly GRPC_JAVA_DIR="$(cd "$(dirname "$0")"/../.. && pwd)" - -. "$GRPC_JAVA_DIR"/buildscripts/kokoro/kokoro.sh -trap spongify_logs EXIT - -cd github/grpc-java - -buildscripts/qemu_helpers/prepare_qemu.sh - -buildscripts/run_arm64_tests_in_docker.sh diff --git a/buildscripts/qemu_helpers/prepare_qemu.sh b/buildscripts/qemu_helpers/prepare_qemu.sh deleted file mode 100755 index be0d733344..0000000000 --- a/buildscripts/qemu_helpers/prepare_qemu.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# -# Setup and configure qemu userspace emulator on kokoro worker so that we can seamlessly emulate processes running -# inside docker containers. - -set -ex - -# show pre-existing qemu registration -cat /proc/sys/fs/binfmt_misc/qemu-aarch64 || true - -# Kokoro ubuntu1604 workers have already qemu-user and qemu-user-static packages installed, but it's and old version that: -# * prints warning about some syscalls (e.g "qemu: Unsupported syscall: 278") -# * doesn't register with binfmt_misc with the persistent ("F") flag we need (see below) -# -# To overcome the above limitations, we use the https://github.com/multiarch/qemu-user-static -# docker image to provide a new enough version of qemu-user-static and register it with -# the desired binfmt_misc flags. The most important flag we need is "F" (set by "--persistent yes"), -# which allows the qemu-aarch64-static binary to be loaded eagerly at the time of registration with binfmt_misc. -# That way, we can emulate aarch64 binaries running inside docker containers transparently, without needing the emulator -# binary to be accessible from the docker image we're emulating. -# Note that on newer distributions (such as glinux), simply "apt install qemu-user-static" is sufficient -# to install qemu-user-static with the right flags. -docker run --rm --privileged multiarch/qemu-user-static:5.2.0-2 --reset --credential yes --persistent yes - -# Print current qemu reqistration to make sure everything is setup correctly. -cat /proc/sys/fs/binfmt_misc/qemu-aarch64 diff --git a/buildscripts/run_arm64_tests_in_docker.sh b/buildscripts/run_arm64_tests_in_docker.sh deleted file mode 100755 index 76ef64ac6b..0000000000 --- a/buildscripts/run_arm64_tests_in_docker.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -set -ex - -readonly grpc_java_dir="$(dirname "$(readlink -f "$0")")/.." - -if [[ -t 0 ]]; then - DOCKER_ARGS="-it" -else - # The input device on kokoro is not a TTY, so -it does not work. - DOCKER_ARGS= -fi - - -cat <> "${grpc_java_dir}/gradle.properties" -skipAndroid=true -skipCodegen=true -org.gradle.parallel=true -org.gradle.jvmargs=-Xmx1024m -EOF - -export JAVA_OPTS="-Duser.home=/grpc-java/.current-user-home -Djava.util.prefs.userRoot=/grpc-java/.current-user-home/.java/.userPrefs" - -# build under x64 docker image to save time over building everything under -# aarch64 emulator. We've already built and tested the protoc binaries -# so for the rest of the build we will be using "-PskipCodegen=true" -# avoid further complicating the build. -docker run $DOCKER_ARGS --rm=true -v "${grpc_java_dir}":/grpc-java -w /grpc-java \ - --user "$(id -u):$(id -g)" -e JAVA_OPTS \ - openjdk:11-jdk-slim-buster \ - ./gradlew build -x test - -# Build and run java tests under aarch64 image. -# To be able to run this docker container on x64 machine, one needs to have -# qemu-user-static properly registered with binfmt_misc. -# The most important flag binfmt_misc flag we need is "F" (set by "--persistent yes"), -# which allows the qemu-aarch64-static binary to be loaded eagerly at the time of registration with binfmt_misc. -# That way, we can emulate aarch64 binaries running inside docker containers transparently, without needing the emulator -# binary to be accessible from the docker image we're emulating. -# Note that on newer distributions (such as glinux), simply "apt install qemu-user-static" is sufficient -# to install qemu-user-static with the right flags. -# A note on the "docker run" args used: -# - run docker container under current user's UID to avoid polluting the workspace -# - set the user.home property to avoid creating a "?" directory under grpc-java -docker run $DOCKER_ARGS --rm=true -v "${grpc_java_dir}":/grpc-java -w /grpc-java \ - --user "$(id -u):$(id -g)" -e JAVA_OPTS \ - arm64v8/openjdk:11-jdk-slim-buster \ - ./gradlew build