Skip to content

Commit

Permalink
ci: Utilize native arm64 linux runners (#784)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxymVlasov authored Jan 27, 2025
1 parent 980a129 commit c1154d6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 21 deletions.
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
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
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
- name: Set up Docker Buildx
# yamllint disable-line rule:line-length
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
Expand Down

0 comments on commit c1154d6

Please sign in to comment.