diff --git a/.github/workflows/contributor.yml b/.github/workflows/contributor.yml index 5f7839f..40d1f8f 100644 --- a/.github/workflows/contributor.yml +++ b/.github/workflows/contributor.yml @@ -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: @@ -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