-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 48fb005
Showing
9 changed files
with
339 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
.github/actions/configure-docker-containerd-image-store/action.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: 'configure docker containerd image store' | ||
description: 'configure docker containerd image store' | ||
inputs: | ||
USE_CONTAINERD: | ||
description: use containerd as docker image store | ||
required: false | ||
default: 'false' | ||
runs: | ||
using: "composite" | ||
steps: | ||
- run: | | ||
# enable containerd image store | ||
ENABLE_CONTAINERD_IMAGE_STORE=${{ inputs.USE_CONTAINERD }} | ||
[ "$ENABLE_CONTAINERD_IMAGE_STORE" != 'false' ] \ | ||
&& ENABLE_CONTAINERD_IMAGE_STORE=true \ | ||
|| ENABLE_CONTAINERD_IMAGE_STORE=false | ||
# detect current configuration | ||
config=/etc/docker/daemon.json | ||
current=$((sudo cat "$config" 2>/dev/null || echo "{}")|jq '.features."containerd-snapshotter" // false') | ||
# update configuration if necessary | ||
[ "$current" = "$ENABLE_CONTAINERD_IMAGE_STORE" ] && exit 0 | ||
jq_expression='.features."containerd-snapshotter" = '$ENABLE_CONTAINERD_IMAGE_STORE | ||
tmpfile=$(mktemp) && (sudo cat "$config" 2>/dev/null || echo "{}") | jq "$jq_expression" > "$tmpfile" | ||
mkdir -p $(dirname "$config") && (cat "$tmpfile" | sudo tee "$config") && rm "$tmpfile" | ||
# restart docker | ||
sudo systemctl restart docker || sudo journalctl -xeu docker.service | ||
echo --- | ||
docker info | ||
echo --- | ||
docker image ls | ||
echo --- | ||
sudo systemctl status docker | ||
shell: bash |
44 changes: 44 additions & 0 deletions
44
.github/actions/install_qemu_user_static_from_debian/action.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: 'install qemu-user-static from debian' | ||
description: 'install qemu-user-static from debian' | ||
inputs: | ||
VERSION: | ||
description: version of qemu-user-static | ||
required: false | ||
TARGET_RELEASE: | ||
default: bookworm | ||
description: target release specifying to apt-get install | ||
required: false | ||
runs: | ||
using: "composite" | ||
steps: | ||
- id: process | ||
run: | | ||
TARGET_RELEASE=${{ inputs.TARGET_RELEASE }} | ||
VERSION=${{ inputs.VERSION }} | ||
# install debian-archive-keyring | ||
keyring=/etc/apt/keyrings/debian-archive-keyring.gpg | ||
[ -f $keyring ] || curl https://ftp-master.debian.org/keys/archive-key-11.asc -o - | sudo gpg --dearmor -o $keyring | ||
# add debian sources | ||
debian_sources=/etc/apt/sources.list.d/debian-$TARGET_RELEASE.sources | ||
[ -f "$debian_sources" ] || sudo tee $debian_sources <<EOF | ||
Types: deb | ||
URIs: http://deb.debian.org/debian | ||
Suites: $TARGET_RELEASE | ||
Components: main | ||
Signed-By: $keyring | ||
EOF | ||
# pin debian sources | ||
debian_pin=/etc/apt/preferences.d/debian-$TARGET_RELEASE-pin | ||
[ -f "$debian_pin" ] || sudo tee $debian_pin <<EOF | ||
Package: * | ||
Pin: release n=$TARGET_RELEASE | ||
Pin-Priority: 100 | ||
EOF | ||
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 | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
name: Docker Image CI | ||
|
||
on: | ||
create: | ||
push: | ||
branches: [master] | ||
paths: | ||
- '.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' | ||
|
||
jobs: | ||
use-qemu-user-static: | ||
runs-on: ubuntu-${{ matrix.ubuntu_version }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
ubuntu_version: | ||
- '20.04' | ||
- '22.04' # latest | ||
- '24.04' | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- run: sudo apt-get update && sudo apt-get install -y 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 }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
target_release: | ||
- '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 | ||
with: | ||
TARGET_RELEASE: ${{ matrix.target_release }} | ||
|
||
- 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-tonistiigi_binfmt: | ||
name: tonistiigi/binfmt:${{ matrix.tag }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
tag: | ||
- latest | ||
- qemu-v5.0.1 | ||
- qemu-v5.1.0 | ||
- qemu-v5.2.0 | ||
- qemu-v6.0.0 | ||
- qemu-v6.1.0 | ||
- qemu-v6.2.0 | ||
- qemu-v7.0.0 # latest | ||
- qemu-v8.0.4 | ||
- qemu-v8.1.4 | ||
- qemu-v8.1.5 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: docker/setup-qemu-action@v3 | ||
with: | ||
image: tonistiigi/binfmt:${{ matrix.tag }} | ||
platforms: linux/arm64 | ||
|
||
- 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-multiarch_qemu-user-static: | ||
name: multiarch/qemu-user-static:${{ matrix.tag }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
tag: | ||
- latest | ||
- 3.1.1-2 | ||
- 4.0.0-5 | ||
- 4.1.1-1 | ||
- 4.2.0-7 | ||
- 5.0.0-5 | ||
- 5.1.0-8 | ||
- 5.2.0-2 | ||
- 6.1.0-8 | ||
- 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 | ||
|
||
- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/configuration/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# 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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Norio Nomura | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"originHash" : "b9c47443daa3387adc9a9861ff912dd4f4dd9e850890e71c076288cde75316e7", | ||
"pins" : [ | ||
{ | ||
"identity" : "swift-argument-parser", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-argument-parser.git", | ||
"state" : { | ||
"revision" : "0fbc8848e389af3bb55c182bc19ca9d5dc2f255b", | ||
"version" : "1.4.0" | ||
} | ||
} | ||
], | ||
"version" : 3 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// swift-tools-version: 5.10 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "hello-world", | ||
products: [ | ||
.executable(name: "hello-world", targets: ["hello-world"]), | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.1"), | ||
], | ||
targets: [ | ||
// Targets are the basic building blocks of a package, defining a module or a test suite. | ||
// Targets can depend on other targets in this package and products from dependencies. | ||
.executableTarget( | ||
name: "hello-world", | ||
dependencies: [ | ||
.product(name: "ArgumentParser", package: "swift-argument-parser"), | ||
] | ||
), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import ArgumentParser | ||
|
||
@main | ||
struct Main: ParsableCommand { | ||
static var configuration = CommandConfiguration( | ||
commandName: "hello-world", | ||
abstract: "A 'Hello, world!' program written in Swift.", | ||
version: "1.0.0", | ||
subcommands: [SayHello.self], | ||
defaultSubcommand: SayHello.self | ||
) | ||
} | ||
|
||
extension Main { | ||
struct SayHello: ParsableCommand { | ||
static var configuration = CommandConfiguration( | ||
commandName: "say-hello", | ||
abstract: "Prints 'Hello, world!' to the console." | ||
) | ||
|
||
func run() { | ||
print("Hello, world!") | ||
} | ||
} | ||
} |