Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Utilize native arm64 linux runners #784

Merged
merged 20 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 40 additions & 18 deletions .github/workflows/build-image-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,25 @@ env:

jobs:
build:
permissions:
# for MaxymVlasov/dive-action to write comments to PRs
pull-requests: write

strategy:
matrix:
os: [ubuntu-latest]
arch: [amd64, arm64]
arch:
- amd64
- arm64
include:
- os-name: Ubuntu x64
os: ubuntu-latest
arch: amd64

- os-name: Ubuntu ARM
os: ubuntu-24.04-arm
arch: arm64

name: ${{ matrix.os-name }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand All @@ -37,21 +51,17 @@ jobs:
tools/*.sh
- name: Set IMAGE environment variable
if: steps.changed-files-specific.outputs.any_changed == 'true'
# Lowercase the org/repo name to allow for workflow to run in forks,
# which owners have uppercase letters in username
run: >-
echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY@L}:${{ env.IMAGE_TAG }}"
>> $GITHUB_ENV
- name: Set up QEMU
if: matrix.os != 'ubuntu-latest' || matrix.arch != 'amd64'
# yamllint disable-line rule:line-length
uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a # v3.3.0
with:
platforms: arm64
- name: Set up Docker Buildx
# yamllint disable-line rule:line-length
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
if: steps.changed-files-specific.outputs.any_changed == 'true'

- name: Build if Dockerfile changed
if: steps.changed-files-specific.outputs.any_changed == 'true'
Expand All @@ -61,9 +71,6 @@ jobs:
context: .
build-args: |
INSTALL_ALL=true
# yamllint disable-line rule:line-length
platforms: >- # Only one allowed here, see https://github.com/docker/buildx/issues/59#issuecomment-1433097926
linux/${{ matrix.arch }}
push: false
load: true
tags: ${{ env.IMAGE }}
Expand All @@ -72,18 +79,34 @@ jobs:
secrets: |
"github_token=${{ secrets.GITHUB_TOKEN }}"
- name: Setup Container Structure Tests
if: steps.changed-files-specific.outputs.any_changed == 'true'
env:
# yamllint disable-line rule:line-length
# renovate: datasource=github-releases depName=container-structure-test lookupName=GoogleContainerTools/container-structure-test
CST_VERSION: 1.19.3
CST_REPO: github.com/GoogleContainerTools/container-structure-test
run: >-
curl -L "https://${{ env.CST_REPO }}/releases/download/v${{
env.CST_VERSION }}/container-structure-test-linux-${{ matrix.arch }}"
> container-structure-test
&& chmod +x container-structure-test
&& mkdir -p $HOME/bin/
&& mv container-structure-test $HOME/bin/
&& echo $HOME/bin/ >> $GITHUB_PATH
- name: Run structure tests
if: steps.changed-files-specific.outputs.any_changed == 'true'
# yamllint disable-line rule:line-length
uses: plexsystems/container-structure-test-action@c0a028aa96e8e82ae35be556040340cbb3e280ca # v0.3.0
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also has issues with MacOS, which blocks #636, so I replaced it with binary, as I don't want to write my own GHA from scratch for this

with:
image: ${{ env.IMAGE }}
config: .github/.container-structure-test-config.yaml
run: >-
container-structure-test test
--config ${{ github.workspace
}}/.github/.container-structure-test-config.yaml
--image ${{ env.IMAGE }}
- name: Dive - check image for waste files
if: steps.changed-files-specific.outputs.any_changed == 'true'
# yamllint disable-line rule:line-length
uses: MaxymVlasov/dive-action@379af3fc636888ada5899c997e8b52db6ad45023 # v1.0.1
uses: MaxymVlasov/dive-action@b6a02b38f0f309e8817199658eab090d4f0f93ce # v1.1.0
Copy link
Collaborator Author

@MaxymVlasov MaxymVlasov Jan 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol, I spent whole day on it 🤪
3 releases, 1 for external collaborator PRs, 1 to polish and make-up-to date f*ng node_modules/ GHA on TypeScript, and 1 to actually add ARM support (hopefully there is a fork of dive itself which added docker ARM builds)

with:
image: ${{ env.IMAGE }}
config-file: ${{ github.workspace }}/.github/.dive-ci.yaml
Expand All @@ -95,7 +118,6 @@ jobs:
if: >-
steps.changed-files-specific.outputs.any_changed == 'true'
&& matrix.os == 'ubuntu-latest'
&& matrix.arch == 'amd64'
# yamllint disable-line rule:line-length
uses: docker/build-push-action@67a2d409c0a876cbe6b11854e3e25193efe4e62d # v6.12.0
with:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up QEMU
# yamllint disable-line rule:line-length
uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a # v3.3.0
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double-checked - it works without it

- name: Set up Docker Buildx
# yamllint disable-line rule:line-length
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
Expand Down
Loading