Skip to content

Commit

Permalink
Change to running swiftlint in docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
norio-nomura committed Jul 9, 2024
1 parent 48fb005 commit 6f9a0fb
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inputs:
USE_CONTAINERD:
description: use containerd as docker image store
required: false
default: 'false'
default: 'true'
runs:
using: "composite"
steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ runs:
TARGET_FLAG=${TARGET_RELEASE:+-t $TARGET_RELEASE}
VERSION_REQUIREMENT=${VERSION:+=$VERSION}
sudo apt-get update && sudo apt-get $TARGET_FLAG install -y qemu-user-static$VERSION_REQUIREMENT
sudo systemctl restart systemd-binfmt
shell: bash
140 changes: 80 additions & 60 deletions .github/workflows/docker-image-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,82 +8,96 @@ on:
- '.github/actions/*/action.yml'
- '.github/workflows/docker-image-ci.yml'
- 'Dockerfile'
- '**.swift'
pull_request:
paths:
- '.github/actions/*/action.yml'
- '.github/workflows/docker-image-ci.yml'
- '**.swift'

defaults:
run:
shell: bash

env:
NUMBER_OF_TRIES: 5

jobs:
use-qemu-user-static:
runs-on: ubuntu-${{ matrix.ubuntu_version }}
qemu-user-static-ubuntu:
name: qemu-user-static (ubuntu-${{ matrix.version }})
runs-on: ubuntu-${{ matrix.version }}
strategy:
fail-fast: false
matrix:
ubuntu_version:
version:
- '20.04'
- '22.04' # latest
- '24.04'

- '24.04'
steps:
- uses: actions/checkout@v4

- name: install qemu-user-static
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- run: sudo apt-get update && sudo apt-get install -y qemu-user-static
- name: print qemu-user-static version
run: |
echo "::notice title=${{ github.job }}:${{ matrix.version }}::qemu-user-static:$(dpkg-query --show --showformat='${Version}' qemu-user-static)"
- uses: ./.github/actions/configure-docker-containerd-image-store
with:
USE_CONTAINERD: true

- name: build arm64 architecture
uses: docker/build-push-action@v5
with:
load: true
platforms: linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max

use-qemu-user-static-from_debian:
name: qemu-user-static from debian ${{ matrix.target_release }}
- name: try to build docker image
run: |
docker pull --platform linux/arm64 norionomura/swiftlint:experimental-multi-arch
for i in $(seq 1 ${{ env.NUMBER_OF_TRIES }}); do
timeout --preserve-status --kill-after=60 240 docker buildx build --load --no-cache --platform linux/arm64 . && continue
echo "::error title=${{ github.job }} failed::on iteration:$i"
exit 1
done
qemu-user-static-debian:
name: qemu-user-static (debian ${{ matrix.version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target_release:
version:
- 'buster' # 1:3.1+dfsg-8+deb10u12
- 'bullseye' # 1:5.2+dfsg-11+deb11u3
- 'bullseye-backports' # 1:7.2+dfsg-7+deb12u2~bpo11+1
- 'bookworm' # 1:7.2+dfsg-7+deb12u6
- 'bookworm-backports' # 1:8.2.1+ds-1~bpo12+1
- 'trixie' # 1:8.2.4+ds-1
- 'sid' # 1:9.0.1+ds-1

steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/install_qemu_user_static_from_debian
- name: install qemu-user-static from debian
uses: ./.github/actions/install_qemu_user_static_from_debian
with:
TARGET_RELEASE: ${{ matrix.target_release }}
TARGET_RELEASE: ${{ matrix.version }}

- name: print qemu-user-static version
run: |
echo "::notice title=${{ github.job }}:${{ matrix.version }}::qemu-user-static:$(dpkg-query --show --showformat='${Version}' qemu-user-static)"
- uses: ./.github/actions/configure-docker-containerd-image-store
with:
USE_CONTAINERD: true

- name: build arm64 architecture
uses: docker/build-push-action@v5
with:
load: true
platforms: linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
- name: try to build docker image
run: |
docker pull --platform linux/arm64 norionomura/swiftlint:experimental-multi-arch
for i in $(seq 1 ${{ env.NUMBER_OF_TRIES }}); do
timeout --preserve-status --kill-after=60 240 docker buildx build --load --no-cache --platform linux/arm64 . && continue
echo "::error title=${{ github.job }} failed::on iteration:$i"
exit 1
done
use-tonistiigi_binfmt:
name: tonistiigi/binfmt:${{ matrix.tag }}
name: tonistiigi/binfmt:${{ matrix.version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tag:
version:
- latest
- qemu-v5.0.1
- qemu-v5.1.0
Expand All @@ -95,34 +109,37 @@ jobs:
- qemu-v8.0.4
- qemu-v8.1.4
- qemu-v8.1.5

steps:
- uses: actions/checkout@v4

- uses: docker/setup-qemu-action@v3
- name: install qemu-user-static
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:${{ matrix.tag }}
image: tonistiigi/binfmt:${{ matrix.version }}
platforms: linux/arm64

- name: print qemu-user-static version
run: |
echo "::notice title=${{ github.job }}:${{ matrix.version }}::qemu-user-static:${{ matrix.version }}"
- uses: ./.github/actions/configure-docker-containerd-image-store
with:
USE_CONTAINERD: true

- name: build arm64 architecture
uses: docker/build-push-action@v5
with:
load: true
platforms: linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
- name: try to build docker image
run: |
docker pull --platform linux/arm64 norionomura/swiftlint:experimental-multi-arch
for i in $(seq 1 ${{ env.NUMBER_OF_TRIES }}); do
timeout --preserve-status --kill-after=60 240 docker buildx build --load --no-cache --platform linux/arm64 . && continue
echo "::error title=${{ github.job }} failed::on iteration:$i"
exit 1
done
use-multiarch_qemu-user-static:
name: multiarch/qemu-user-static:${{ matrix.tag }}
name: multiarch/qemu-user-static:${{ matrix.version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tag:
version:
- latest
- 3.1.1-2
- 4.0.0-5
Expand All @@ -135,20 +152,23 @@ jobs:
- 7.0.0-7
- 7.1.0-2
- 7.2.0-1 # latest

steps:
- uses: actions/checkout@v4

- run: docker run --rm --privileged multiarch/qemu-user-static:${{ matrix.tag }} --reset -p yes
- name: install qemu-user-static
run: docker run --rm --privileged multiarch/qemu-user-static:${{ matrix.version }} --reset -p yes

- name: print qemu-user-static version
run: |
echo "::notice title=${{ github.job }}:${{ matrix.version }}::qemu-user-static:${{ matrix.version }}"
- uses: ./.github/actions/configure-docker-containerd-image-store
with:
USE_CONTAINERD: true

- name: build arm64 architecture
uses: docker/build-push-action@v5
with:
load: true
platforms: linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
- name: try to build docker image
run: |
docker pull --platform linux/arm64 norionomura/swiftlint:experimental-multi-arch
for i in $(seq 1 ${{ env.NUMBER_OF_TRIES }}); do
timeout --preserve-status --kill-after=60 240 docker buildx build --load --no-cache --platform linux/arm64 . && continue
echo "::error title=${{ github.job }} failed::on iteration:$i"
exit 1
done
17 changes: 7 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# syntax=docker/dockerfile:1

FROM swift:5.10
WORKDIR /app
COPY Sources /app/Sources
COPY Package.* /app
ARG TARGETPLATFORM
RUN --mount=type=cache,target=/app/.build,sharing=locked,id=${TARGETPLATFORM} \
swift build -c release --product hello-world && \
install $(swift build -c release --show-bin-path)/hello-world /usr/local/bin
RUN hello-world
CMD ["hello-world"]
FROM norionomura/swiftlint:experimental-multi-arch
# remove stub script
RUN test ! -x /usr/local/bin/swiftlint || rm /usr/local/bin/swiftlint

SHELL ["/bin/bash", "-eux", "-o", "pipefail", "-c"]
RUN ["timeout", "--preserve-status", "--kill-after=60", "120", "swiftlint", "version"]
RUN echo "_ = 0" | timeout --preserve-status --kill-after=60 120 swiftlint --use-stdin
15 changes: 0 additions & 15 deletions Package.resolved

This file was deleted.

24 changes: 0 additions & 24 deletions Package.swift

This file was deleted.

25 changes: 0 additions & 25 deletions Sources/main.swift

This file was deleted.

0 comments on commit 6f9a0fb

Please sign in to comment.