Skip to content

Commit

Permalink
don't build psibase-contrib during PR on arm
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Mart committed May 14, 2024
1 parent e14bad7 commit 8b7be6f
Showing 1 changed file with 105 additions and 5 deletions.
110 changes: 105 additions & 5 deletions .github/workflows/contributor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@ jobs:
name: psibase-contributor
strategy:
matrix:
runner: [ubuntu-latest, arm-runner-1]
include:
- runner: ubuntu-latest
platform: "linux/amd64"
platform_short: "amd64"
- runner: arm-runner-1
platform: "linux/arm64"
platform_short: "arm64"
runs-on: ${{ matrix.runner }}
services:
registry:
Expand Down Expand Up @@ -175,12 +171,116 @@ jobs:
name: psibase_contributor-${{ matrix.platform_short }}
path: psibase_contributor-${{ matrix.platform_short }}.tar
retention-days: 1

# Arm64 runners don't have docker installed, so can't use the registry service to load
# local images. Therefore, for now we must skip PR builds of psibase-contributor on arm.
# Once arm-runners are out of beta, the runners will have docker installed on them by default,
# and this special job can be deleted, and the arm64 runner can be added as a matrix option
# to the prior job.
psibase-contributor-arm64:
name: psibase-contributor-arm64
strategy:
matrix:
include:
- runner: arm-runner-1
platform: "linux/arm64"
platform_short: "arm64"
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: false
fetch-depth: 0

- name: Building ${{ matrix.platform_short }}
run: true

# Docker install step can be removed after arm runners are out of beta
- name: Install docker
if: matrix.runner == 'arm-runner-1'
run: |
sudo apt-get update
sudo apt-get install -yq ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
# Install
sudo apt-get install -yq docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Give current user permission to run docker without sudo
sudo usermod -aG docker $USER
sudo apt-get install -yq acl
sudo setfacl --modify user:$USER:rw /var/run/docker.sock
- name: Config docker buildx
if: ${{ github.event_name != 'pull_request' }}
uses: docker/setup-buildx-action@v3

- name: Login in to registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set BASE_IMAGE
id: base_img
env:
NEW_BASE: ${{ inputs.new_base }}
IS_PR: ${{ github.event_name == 'pull_request' }}
run: |
if [[ "$NEW_BASE" == "true" && "$IS_PR" == "true" ]]; then
echo "Skipping PR build on arm64"
elif [[ "$NEW_BASE" == "true" ]]; then
echo "BASE_IMAGE=ghcr.io/gofractally/psibase-builder-ubuntu-2204:${{ github.sha }}" >> $GITHUB_OUTPUT
else
latest_tag=$(./.github/scripts/latest-tag.sh "gofractally/psibase-builder-ubuntu-2204")
echo "BASE_IMAGE=ghcr.io/gofractally/psibase-builder-ubuntu-2204:${latest_tag}" >> $GITHUB_OUTPUT
fi
- name: Set TOOL_CONFIG_IMAGE
id: tool_cfg_img
env:
NEW_TOOLS: ${{ inputs.new_tools }}
IS_PR: ${{ github.event_name == 'pull_request' }}
run: |
if [[ "$NEW_TOOLS" == "true" && "$IS_PR" == "true" ]]; then
echo "Skipping PR build on arm64"
elif [[ "$NEW_TOOLS" == "true" ]]; then
echo "TOOL_CONFIG_IMAGE=ghcr.io/gofractally/https-tool-config:${{ github.sha }}" >> $GITHUB_OUTPUT
else
latest_tag=$(./.github/scripts/latest-tag.sh "gofractally/https-tool-config")
echo "TOOL_CONFIG_IMAGE=ghcr.io/gofractally/https-tool-config:${latest_tag}" >> $GITHUB_OUTPUT
fi
- name: Build & publish
if: ${{ github.event_name != 'pull_request' }}
uses: docker/build-push-action@v5
with:
context: .
push: true
file: docker/psibase-contributor.Dockerfile
build-args: |
BASE_IMAGE=${{ steps.base_img.outputs.BASE_IMAGE }}
TOOL_CONFIG_IMAGE=${{ steps.tool_cfg_img.outputs.TOOL_CONFIG_IMAGE }}
tags: "ghcr.io/${{ github.repository_owner }}/psibase-contributor:${{ github.sha }}-${{ matrix.platform_short }}"
platforms: ${{ matrix.platform }}
provenance: false
outputs: type=image,annotation-index.org.opencontainers.image.description=Psibase development environment
merge:
name: merge multi-platform images
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
needs: psibase-contributor
needs: [psibase-contributor, psibase-contributor-arm64]
steps:
- name: Config docker buildx
uses: docker/setup-buildx-action@v3
Expand Down

0 comments on commit 8b7be6f

Please sign in to comment.