From 023972b9c2ec97b83a3c4e15d7254dcfc251046e Mon Sep 17 00:00:00 2001 From: everpcpc Date: Sun, 14 Jan 2024 13:52:34 +0800 Subject: [PATCH] ci: ci-cloud build both amd64 & arm64 (#14317) --- .github/workflows/cloud.yml | 53 +++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/.github/workflows/cloud.yml b/.github/workflows/cloud.yml index 86c90f72745d..b92831167550 100644 --- a/.github/workflows/cloud.yml +++ b/.github/workflows/cloud.yml @@ -17,9 +17,9 @@ env: RUNNER_PROVIDER: gcp jobs: - build: + info: if: contains(github.event.pull_request.labels.*.name, 'ci-cloud') || contains(github.event.pull_request.labels.*.name, 'ci-benchmark') - runs-on: [self-hosted, X64, Linux, 16c32g, gcp] + runs-on: ubuntu-latest outputs: sha: ${{ steps.sha.outputs.sha }} steps: @@ -32,32 +32,50 @@ jobs: id: sha run: | echo "sha=$(git rev-parse --verify HEAD)" > $GITHUB_OUTPUT + + build: + needs: info + runs-on: [self-hosted, X64, Linux, 16c32g, gcp] + strategy: + matrix: + arch: + - x86_64 + - aarch64 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: "refs/pull/${{ github.event.number }}/merge" - name: Build Release uses: ./.github/actions/build_linux timeout-minutes: 60 with: - sha: ${{ steps.sha.outputs.sha }} - target: x86_64-unknown-linux-gnu + sha: ${{ needs.info.outputs.sha }} + target: ${{ matrix.arch }}-unknown-linux-gnu artifacts: meta,query docker: - needs: build + needs: [info, build] timeout-minutes: 10 runs-on: [self-hosted, X64, Linux, 4c8g, gcp] outputs: tag: ${{ steps.prepare.outputs.tag }} steps: - uses: actions/checkout@v4 - - name: Download artifact + - name: Download artifact for x86_64 uses: ./.github/actions/artifact_download with: - sha: ${{ needs.build.outputs.sha }} + sha: ${{ needs.info.outputs.sha }} target: x86_64-unknown-linux-gnu + path: ./target/x86_64-unknown-linux-gnu/release + artifacts: meta,query + - name: Download artifact for aarch64 + uses: ./.github/actions/artifact_download + with: + sha: ${{ needs.info.outputs.sha }} + target: aarch64-unknown-linux-gnu + path: ./target/aarch64-unknown-linux-gnu/release artifacts: meta,query - - name: Prepare docker build - run: | - mkdir -p ./distro/linux/amd64 - cp ./target/release/databend-* ./distro/linux/amd64 - uses: ./.github/actions/setup_docker id: login with: @@ -66,16 +84,17 @@ jobs: - name: Prepare for docker id: prepare run: | - mkdir -p ./distro/linux/amd64 - cp ./target/release/databend-query ./distro/linux/amd64/databend-query - short_sha=$(echo "${{ needs.build.outputs.sha }}" | cut -c1-7) + mkdir -p ./distro/linux/{amd64,arm64} + cp ./target/x86_64-unknown-linux-gnu/release/databend-query ./distro/linux/amd64/ + cp ./target/aarch64-unknown-linux-gnu/release/databend-query ./distro/linux/arm64/ + short_sha=$(echo "${{ needs.info.outputs.sha }}" | cut -c1-7) echo "tag=pr-${{ github.event.pull_request.number }}-${short_sha}" >> $GITHUB_OUTPUT - name: push service image uses: docker/build-push-action@v3 with: push: true tags: ${{ steps.login.outputs.ecr_repo }}:${{ steps.prepare.outputs.tag }} - platforms: linux/amd64 + platforms: linux/amd64,linux/arm64 context: . file: ./docker/debian/query.Dockerfile - name: Comment on PR @@ -92,11 +111,11 @@ jobs: benchmark: if: contains(github.event.pull_request.labels.*.name, 'ci-benchmark') - needs: [build, docker] + needs: [info, build, docker] uses: ./.github/workflows/reuse.benchmark.yml secrets: inherit with: - sha: ${{ needs.build.outputs.sha }} + sha: ${{ needs.info.outputs.sha }} run_id: ${{ github.run_id }} source: pr source_id: ${{ github.event.pull_request.number }}