Skip to content

Commit

Permalink
Merge pull request #220 from akostadinov/master
Browse files Browse the repository at this point in the history
multi-platform tested container build
  • Loading branch information
vi committed Apr 3, 2024
2 parents 4c03976 + 87e7b99 commit ae187f5
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 5 deletions.
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# see https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:

# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: friday

# Maintain dependencies for Bundler
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
day: wednesday
64 changes: 59 additions & 5 deletions .github/workflows/container-image-buildah.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
name: Container Image

on:
workflow_dispatch: {}
workflow_call: {}
workflow_dispatch:
inputs:
platforms:
description: "comma-separated list of platforms to build for, e.g. linux/amd64,linux/s390x,linux/ppc64le,linux/riscv64 (leave empty for defaults)"
default: ''
custom_tag:
description: optional custom tag on remote repo you want image to be tagged with
default: scratch
workflow_call:
inputs:
platforms:
required: false
default: ''
type: string
custom_tag:
required: false
default: ''
type: string
schedule:
# every Wednesday morning
- cron: 7 7 * * 3
Expand Down Expand Up @@ -33,11 +49,19 @@ jobs:
buildah:
runs-on: ubuntu-latest
steps:
- name: Sanitize Platforms
id: platforms
run: |
platforms="${{ inputs.platforms == '' && 'linux/amd64,linux/arm64' || inputs.platforms }}"
archs="$( sed -e 's#linux/##g' <<< $platforms )"
echo "platforms=$platforms" >> $GITHUB_OUTPUT
echo "archs=$archs" >> $GITHUB_OUTPUT
# Allow multi-target builds
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
platforms: ${{ steps.platforms.outputs.archs }}
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
Expand All @@ -57,7 +81,9 @@ jobs:
tags: |
type=schedule
type=raw,value=latest,enable=${{ github.ref_name == 'master' }}
${{ github.ref_name == 'master' && 'type=raw,value=nightly' || 'type=ref,event=branch' }}
${{ github.ref_name == 'master' && 'type=raw,value=nightly' }}
type=ref,event=branch,enable=${{ github.ref_name != 'master' && inputs.custom_tag == '' }}
${{ inputs.custom_tag }}
type=ref,event=tag
type=ref,event=pr
Expand All @@ -69,7 +95,7 @@ jobs:
uses: redhat-actions/buildah-build@v2
with:
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64
platforms: ${{ steps.platforms.outputs.platforms }}
labels: ${{ steps.meta.outputs.labels }}
layers: false
oci: true
Expand All @@ -89,6 +115,34 @@ jobs:
- name: Check images created
run: buildah images

- name: Smoke test the images
run: |
set -ex
# accessing a mapped port from a container did not work so lets
# create a pod where both - server and client have same localhost
podman pod create > podid
platforms="${{ steps.platforms.outputs.platforms }}"
test_tag () {
podman run -d --pod-id-file=podid --name=listener -u 14:0 "${{ steps.build-image.outputs.image-with-tag }}$1" -s 0.0.0.0:1234
sleep 3
podman logs listener
podman run --pod-id-file=podid --rm -i "${{ steps.build-image.outputs.image-with-tag }}$1" ws://127.0.0.1:1234/ <<< "Test Message $1"
echo Expecting "\"Test Message $1\"" in listener log..
podman logs listener | tee /dev/stderr | grep -q "Test Message $1"
podman rm -f listener
}
if [ x$( sed -E -e 's#[^/]##g' <<< $platforms ) != "x/" ]; then
# if we are here, user has selected more than one build platform
arch_tags=$( tr ',' ' ' <<< $platforms | tr -d '/' )
# removed slashes to produce "linuxamd64 linuxs390x linuxppc64le"
for tag in $arch_tags; do test_tag -$tag; done
else
# if we are here, user has selected a single build platform
test_tag
fi
- name: Push To Container Registry
id: push-to-container-registry
uses: redhat-actions/push-to-registry@v2
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Netcat, curl and socat for [WebSockets](https://en.wikipedia.org/wiki/WebSocket).

[![Gitter](https://badges.gitter.im/websocat.svg)](https://gitter.im/websocat/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge)
[![image-build](https://github.com/vi/websocat/actions/workflows/container-image-buildah.yml/badge.svg)](https://github.com/vi/websocat/pkgs/container/websocat)

## Examples

Expand Down

0 comments on commit ae187f5

Please sign in to comment.