From 269ee39a61a25332cbd2724154873560068e1729 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 4 Feb 2024 18:23:40 +0800 Subject: [PATCH] ci(chore): build arm binary in release and docker (#14969) (#14979) --- ci/docker-compose.yml | 8 +++++- ci/scripts/release.sh | 50 +++++++++++++++++++++++--------------- ci/workflows/docker.yml | 22 +++++++++++++++-- ci/workflows/main-cron.yml | 24 ++++++++++++++++-- 4 files changed, 80 insertions(+), 24 deletions(-) diff --git a/ci/docker-compose.yml b/ci/docker-compose.yml index 9047fda1737eb..e8a88b95faed5 100644 --- a/ci/docker-compose.yml +++ b/ci/docker-compose.yml @@ -116,7 +116,7 @@ services: volumes: - ..:/risingwave - release-env: + release-env-x86: # build binaries on a earlier Linux distribution (therefore with earlier version GLIBC) # See https://github.com/risingwavelabs/risingwave/issues/4556 for more details. # @@ -132,6 +132,12 @@ services: volumes: - ..:/mnt + release-env-arm: + image: quay.io/pypa/manylinux2014_aarch64 + working_dir: /mnt + volumes: + - ..:/mnt + elasticsearch: container_name: elasticsearch image: docker.elastic.co/elasticsearch/elasticsearch:7.11.0 diff --git a/ci/scripts/release.sh b/ci/scripts/release.sh index 32d9b801a7e26..1596d44518cd3 100755 --- a/ci/scripts/release.sh +++ b/ci/scripts/release.sh @@ -4,6 +4,7 @@ set -euo pipefail REPO_ROOT=${PWD} +ARCH="$(uname -m)" echo "--- Check env" if [ "${BUILDKITE_SOURCE}" != "schedule" ] && [ "${BUILDKITE_SOURCE}" != "webhook" ] && [[ -z "${BINARY_NAME+x}" ]]; then @@ -11,22 +12,22 @@ if [ "${BUILDKITE_SOURCE}" != "schedule" ] && [ "${BUILDKITE_SOURCE}" != "webhoo fi echo "--- Install aws cli" -curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" +curl "https://awscli.amazonaws.com/awscli-exe-linux-${ARCH}.zip" -o "awscliv2.zip" unzip -q awscliv2.zip && ./aws/install && mv /usr/local/bin/aws /bin/aws echo "--- Install lld" # The lld in the CentOS 7 repository is too old and contains a bug that causes a linker error. # So we install a newer version here. (17.0.6, latest version at the time of writing) # It is manually built in the same environent and uploaded to S3. -aws s3 cp s3://ci-deps-dist/llvm-lld-manylinux2014_x86_64.tar.gz . -tar -zxvf llvm-lld-manylinux2014_x86_64.tar.gz --directory=/usr/local +aws s3 cp s3://ci-deps-dist/llvm-lld-manylinux2014_${ARCH}.tar.gz . +tar -zxvf llvm-lld-manylinux2014_${ARCH}.tar.gz --directory=/usr/local ld.lld --version echo "--- Install dependencies for openssl" yum install -y perl-core echo "--- Install java and maven" -yum install -y java-11-openjdk java-11-openjdk-devel wget python3 cyrus-sasl-devel +yum install -y java-11-openjdk java-11-openjdk-devel wget python3 python3-devel cyrus-sasl-devel pip3 install toml-cli wget https://ci-deps-dist.s3.amazonaws.com/apache-maven-3.9.3-bin.tar.gz && tar -zxvf apache-maven-3.9.3-bin.tar.gz export PATH="${REPO_ROOT}/apache-maven-3.9.3/bin:$PATH" @@ -40,8 +41,13 @@ source ci/scripts/common.sh unset RUSTC_WRAPPER # disable sccache echo "--- Install protoc3" -curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.15.8/protoc-3.15.8-linux-x86_64.zip -unzip -o protoc-3.15.8-linux-x86_64.zip -d protoc +PROTOC_ARCH=${ARCH} +if [ ${ARCH} == "aarch64" ]; then + # shellcheck disable=SC1068 + PROTOC_ARCH="aarch_64" +fi +curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.15.8/protoc-3.15.8-linux-${PROTOC_ARCH}.zip +unzip -o protoc-3.15.8-linux-${PROTOC_ARCH}.zip -d protoc mv ./protoc/bin/protoc /usr/local/bin/ mv ./protoc/include/* /usr/local/include/ @@ -63,11 +69,11 @@ cd target/release && chmod +x risingwave risectl echo "--- Upload nightly binary to s3" if [ "${BUILDKITE_SOURCE}" == "schedule" ]; then - tar -czvf risingwave-"$(date '+%Y%m%d')"-x86_64-unknown-linux.tar.gz risingwave - aws s3 cp risingwave-"$(date '+%Y%m%d')"-x86_64-unknown-linux.tar.gz s3://risingwave-nightly-pre-built-binary + tar -czvf risingwave-"$(date '+%Y%m%d')"-${ARCH}-unknown-linux.tar.gz risingwave + aws s3 cp risingwave-"$(date '+%Y%m%d')"-${ARCH}-unknown-linux.tar.gz s3://risingwave-nightly-pre-built-binary elif [[ -n "${BINARY_NAME+x}" ]]; then - tar -czvf risingwave-${BINARY_NAME}-x86_64-unknown-linux.tar.gz risingwave - aws s3 cp risingwave-${BINARY_NAME}-x86_64-unknown-linux.tar.gz s3://risingwave-nightly-pre-built-binary + tar -czvf risingwave-${BINARY_NAME}-${ARCH}-unknown-linux.tar.gz risingwave + aws s3 cp risingwave-${BINARY_NAME}-${ARCH}-unknown-linux.tar.gz s3://risingwave-nightly-pre-built-binary fi echo "--- Build connector node" @@ -88,23 +94,29 @@ if [[ -n "${BUILDKITE_TAG}" ]]; then dnf install -y gh echo "--- Release create" - gh release create "${BUILDKITE_TAG}" --notes "release ${BUILDKITE_TAG}" -d -p + response=$(gh api repos/risingwavelabs/risingwave/releases/tags/${BUILDKITE_TAG} 2>&1) + if [[ $response == *"Not Found"* ]]; then + echo "Tag ${BUILDKITE_TAG} does not exist. Creating release..." + gh release create "${BUILDKITE_TAG}" --notes "release ${BUILDKITE_TAG}" -d -p + else + echo "Tag ${BUILDKITE_TAG} already exists. Skipping release creation." + fi echo "--- Release upload risingwave asset" - tar -czvf risingwave-"${BUILDKITE_TAG}"-x86_64-unknown-linux.tar.gz risingwave - gh release upload "${BUILDKITE_TAG}" risingwave-"${BUILDKITE_TAG}"-x86_64-unknown-linux.tar.gz + tar -czvf risingwave-"${BUILDKITE_TAG}"-${ARCH}-unknown-linux.tar.gz risingwave + gh release upload "${BUILDKITE_TAG}" risingwave-"${BUILDKITE_TAG}"-${ARCH}-unknown-linux.tar.gz echo "--- Release upload risingwave debug info" - tar -czvf risingwave-"${BUILDKITE_TAG}"-x86_64-unknown-linux.dwp.tar.gz risingwave.dwp - gh release upload "${BUILDKITE_TAG}" risingwave-"${BUILDKITE_TAG}"-x86_64-unknown-linux.dwp.tar.gz + tar -czvf risingwave-"${BUILDKITE_TAG}"-${ARCH}-unknown-linux.dwp.tar.gz risingwave.dwp + gh release upload "${BUILDKITE_TAG}" risingwave-"${BUILDKITE_TAG}"-${ARCH}-unknown-linux.dwp.tar.gz echo "--- Release upload risectl asset" - tar -czvf risectl-"${BUILDKITE_TAG}"-x86_64-unknown-linux.tar.gz risectl - gh release upload "${BUILDKITE_TAG}" risectl-"${BUILDKITE_TAG}"-x86_64-unknown-linux.tar.gz + tar -czvf risectl-"${BUILDKITE_TAG}"-${ARCH}-unknown-linux.tar.gz risectl + gh release upload "${BUILDKITE_TAG}" risectl-"${BUILDKITE_TAG}"-${ARCH}-unknown-linux.tar.gz echo "--- Release upload risingwave-all-in-one asset" - tar -czvf risingwave-"${BUILDKITE_TAG}"-x86_64-unknown-linux-all-in-one.tar.gz risingwave libs - gh release upload "${BUILDKITE_TAG}" risingwave-"${BUILDKITE_TAG}"-x86_64-unknown-linux-all-in-one.tar.gz + tar -czvf risingwave-"${BUILDKITE_TAG}"-${ARCH}-unknown-linux-all-in-one.tar.gz risingwave libs + gh release upload "${BUILDKITE_TAG}" risingwave-"${BUILDKITE_TAG}"-{ARCH}-unknown-linux-all-in-one.tar.gz fi diff --git a/ci/workflows/docker.yml b/ci/workflows/docker.yml index d97d99af7691d..bcf1b605eb96b 100644 --- a/ci/workflows/docker.yml +++ b/ci/workflows/docker.yml @@ -46,14 +46,14 @@ steps: DOCKER_TOKEN: docker-token retry: *auto-retry - - label: "pre build binary" + - label: "pre build binary: amd64" command: "ci/scripts/release.sh" plugins: - seek-oss/aws-sm#v2.3.1: env: GITHUB_TOKEN: github-token - docker-compose#v4.9.0: - run: release-env + run: release-env-x86 config: ci/docker-compose.yml mount-buildkite-agent: true propagate-environment: true @@ -61,3 +61,21 @@ steps: - BINARY_NAME - GITHUB_TOKEN retry: *auto-retry + + - label: "pre build binary: aarch64 " + command: "ci/scripts/release.sh" + plugins: + - seek-oss/aws-sm#v2.3.1: + env: + GITHUB_TOKEN: github-token + - docker-compose#v4.9.0: + run: release-env-arm + config: ci/docker-compose.yml + mount-buildkite-agent: true + propagate-environment: true + environment: + - BINARY_NAME + - GITHUB_TOKEN + agents: + queue: "linux-arm64" + retry: *auto-retry diff --git a/ci/workflows/main-cron.yml b/ci/workflows/main-cron.yml index 357de0fd0b692..0ea0cc9967458 100644 --- a/ci/workflows/main-cron.yml +++ b/ci/workflows/main-cron.yml @@ -843,7 +843,7 @@ steps: timeout_in_minutes: 10 retry: *auto-retry - - label: "release" + - label: "release amd64" command: "ci/scripts/release.sh" if: build.tag != null plugins: @@ -851,7 +851,7 @@ steps: env: GITHUB_TOKEN: github-token - docker-compose#v4.9.0: - run: release-env + run: release-env-x86 config: ci/docker-compose.yml mount-buildkite-agent: true environment: @@ -861,6 +861,26 @@ steps: timeout_in_minutes: 60 retry: *auto-retry + - label: "release aarch64" + command: "ci/scripts/release.sh" + if: build.tag != null + plugins: + - seek-oss/aws-sm#v2.3.1: + env: + GITHUB_TOKEN: github-token + - docker-compose#v4.9.0: + run: release-env-arm + config: ci/docker-compose.yml + mount-buildkite-agent: true + environment: + - GITHUB_TOKEN + - BUILDKITE_TAG + - BUILDKITE_SOURCE + agents: + queue: "linux-arm64" + timeout_in_minutes: 60 + retry: *auto-retry + - label: "release docker image: amd64" command: "ci/scripts/docker.sh" key: "build-amd64"