Skip to content

Commit

Permalink
ci: build arm64 and amd64 for the PR (#3403)
Browse files Browse the repository at this point in the history
  • Loading branch information
ansrivas committed May 5, 2024
1 parent 360e137 commit c1a43a7
Showing 1 changed file with 137 additions and 2 deletions.
139 changes: 137 additions & 2 deletions .github/workflows/build-pr-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
id-token: write
contents: read
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.head.repo.fork == false
runs-on: ${{ github.event.pull_request.head.repo.fork == true && 'ubuntu-2004-8-cores' || 'ubicloud-standard-8' }}
runs-on: ${{ github.event.pull_request.head.repo.fork == true && 'ubuntu-2004-8-cores' || 'ubicloud-standard-4' }}
steps:
- name: Remove unused tools
run: |
Expand Down Expand Up @@ -94,4 +94,139 @@ jobs:
public.ecr.aws/zinclabs/openobserve-dev:${{ env.GIT_TAG }}-${{ env.GIT_HASH}}-amd64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
cache-to: type=gha,mode=max
platforms: linux/amd64

build_pr_image_arm:
name: build_pr_image_arm
permissions:
id-token: write
contents: read
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.head.repo.fork == false
runs-on: 'ubicloud-standard-8-arm'
steps:
- name: Remove unused tools
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Clone the current repo
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref || github.ref }}
fetch-depth: 0
fetch-tags: true

- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-03-02

- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "21.12"
- uses: actions/setup-node@v4
with:
node-version: 18

- name: Build frontend code
run: cd web && npm install && npm run build

- name: Print rustc cfg
run: rustc --print cfg

- name: Build and run binary
run: |
cargo build --release --features mimalloc --target aarch64-unknown-linux-gnu
mkdir -p bin
mv target/aarch64-unknown-linux-gnu/release/openobserve bin/openobserve
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: arn:aws:iam::058694856476:role/GitHubActionsRole
role-session-name: GithubActionsSession

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set GIT_TAG env
run: |
echo "GIT_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
echo "GIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v5
with:
file: deploy/build/Dockerfile.pr.amd64
context: .
tags: |
public.ecr.aws/zinclabs/openobserve-dev:${{ env.GIT_TAG }}-${{ env.GIT_HASH}}-arm64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/arm64

build:
needs: [build_pr_image, build_pr_image_arm]
runs-on: ubicloud-standard-2-arm
permissions:
id-token: write
contents: read
steps:
- name: Clone the current repo
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref || github.ref }}
fetch-depth: 0
fetch-tags: true
- name: Set GIT_TAG env
run: |
echo "GIT_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
echo "GIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: arn:aws:iam::058694856476:role/GitHubActionsRole
role-session-name: GithubActionsSession

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public

- uses: int128/docker-manifest-create-action@v2
with:
tags: |
public.ecr.aws/zinclabs/openobserve-dev:${{ env.GIT_TAG }}-${{ env.GIT_HASH}}
sources: |
public.ecr.aws/zinclabs/openobserve-dev:${{ env.GIT_TAG }}-${{ env.GIT_HASH}}-amd64
public.ecr.aws/zinclabs/openobserve-dev:${{ env.GIT_TAG }}-${{ env.GIT_HASH}}-arm64
# - name: Create manifests
# run: |
# docker pull public.ecr.aws/zinclabs/openobserve-dev:${{ env.GIT_TAG }}-${{ env.GIT_HASH}}-amd64
# docker pull public.ecr.aws/zinclabs/openobserve-dev:${{ env.GIT_TAG }}-${{ env.GIT_HASH}}-arm64
# sleep 5
# docker manifest create public.ecr.aws/zinclabs/openobserve-dev:${{ env.GIT_TAG }}-${{ env.GIT_HASH}} \
# --amend public.ecr.aws/zinclabs/openobserve-dev:${{ env.GIT_TAG }}-${{ env.GIT_HASH}}-amd64 \
# --amend public.ecr.aws/zinclabs/openobserve-dev:${{ env.GIT_TAG }}-${{ env.GIT_HASH}}-arm64
# sleep 5
# docker manifest push public.ecr.aws/zinclabs/openobserve-dev:${{ env.GIT_TAG }}-${{ env.GIT_HASH}}

0 comments on commit c1a43a7

Please sign in to comment.