Skip to content

Commit

Permalink
parametrize archs but skip cross builds
Browse files Browse the repository at this point in the history
  • Loading branch information
akostadinov committed Nov 8, 2023
1 parent 5c3d888 commit b1b5209
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 18 deletions.
43 changes: 28 additions & 15 deletions .github/workflows/container-image-buildah.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
name: Container Image
name: Container Image Reusable Workflow

on:
workflow_dispatch: {}
workflow_call: {}
schedule:
# every Wednesday morning
- cron: 7 7 * * 3
push:
branches: [ main ]
pull_request:
types: [opened, reopened, synchronize]
workflow_call:
inputs:
platforms:
description: comma-separated list of platforms to build for, e.g. linux/amd64,linux/s390x,linux/ppc64le
default: linux/amd64
type: string
custom_tag:
description: optional custom tag on remote repo you want image to be tagged with
required: false
default: ''
type: string

concurrency:
group: ci-container-build-${{ github.ref }}-1
Expand Down Expand Up @@ -49,7 +51,9 @@ jobs:
tags: |
type=schedule
type=raw,value=latest,enable=${{ github.ref_name == 'main' }}
${{ github.ref_name == 'main' && 'type=raw,value=nightly' || 'type=ref,event=branch' }}
type=raw,value=nightly,enable=${{ github.ref_name == 'main' }}
type=ref,event=branch,enable=${{ github.ref_name != 'main' && inputs.custom_tag == '' }}
${{ inputs.custom_tag }}
type=ref,event=tag
type=ref,event=pr
Expand All @@ -61,7 +65,7 @@ jobs:
uses: redhat-actions/buildah-build@v2
with:
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/s390x,linux/ppc64le
platforms: ${{ inputs.platforms }}
labels: ${{ steps.meta.outputs.labels }}
layers: false
oci: true
Expand Down Expand Up @@ -89,11 +93,20 @@ jobs:
# 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
for arch in amd64 s390x ppc64le; do
podman run -d --pod-id-file=podid --name=searchd -u 14:0 ${{ steps.build-image.outputs.image-with-tag }}-linux$arch
arch_tags='""'
if [ $( sed -E -e 's#[^/]##g' <<< ${{ inputs.platforms }} ) != "/" ]; then
# if we are here, user has selected more than one build platform
arch_tags=$( tr ',' ' ' <<< ${{ inputs.platforms | tr -d '/' }} )
# removed slashes to produce "linuxamd64 linuxs390x linuxppc64le"
fi
for tag in $arch_tags; do
# if arch is non-empty, then prepend "-" to it
podman run -d --pod-id-file=podid --name=searchd -u 14:0 ${{ steps.build-image.outputs.image-with-tag }}${tag+-$tag}
sleep 3
podman logs searchd
podman run --pod-id-file=podid --rm --entrypoint "/bin/env" mysql:5.7 -- mysql -h 127.0.0.1 -P 9306 -e "SELECT * FROM account limit 1;"
podman run --pod-id-file=podid --rm --entrypoint "/bin/env" mysql:8 -- mysql -h 127.0.0.1 -P 9306 -e "SELECT * FROM account limit 1;"
podman rm -f searchd
done
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/container-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Container Image

on:
schedule:
# every Wednesday morning
- cron: 7 7 * * 3
push:
branches: [ main ]
pull_request:
types: [opened, reopened, synchronize]
workflow_dispatch:
inputs:
platforms:
description: "comma-separated list of platforms to build for, downstream supported are linux/amd64,linux/s390x,linux/ppc64le; note: clang is broken on s390x (RHEL-15874), also cross-builds take more than 6 hours so we don't do them"
default: linux/amd64
custom_tag:
description: a custom tag on remote repo you want image to be tagged with
default: scratch

jobs:
call-build:
uses: ./.github/workflows/container-image-buildah.yml
with:
platforms: ${{ inputs.platforms == '' && 'linux/amd64' || inputs.platforms }}
custom_tag: ${{ inputs.custom_tag }}
5 changes: 2 additions & 3 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ ENV SEARCHD_REF=6.2.12 \
WORKDIR $BUILD_PATH

SHELL ["/bin/bash", "-x", "-o", "pipefail", "-c"]
# clang is broken on s390x (RHEL-15874), to use gcc remove CC and CXX variables,
# also replace llvm-toolset with make automake gcc gcc-c++ kernel-devel
# hadolint ignore=DL3003,DL3032,SC2046
RUN yum install -y --setopt=skip_missing_names_on_install=False,tsflags=nodocs llvm-toolset mysql cmake boost-devel openssl-devel zlib-devel bison flex systemd-units rpm-build git && \
git clone --depth=1 --branch=$SEARCHD_REF $SEARCHD_REPO . && \
sed -i -e 's/Boost_USE_STATIC_LIBS ON/Boost_USE_STATIC_LIBS OFF/' src/CMakeLists.txt && \
mkdir build && cd build && \
clang-16 --version && clang++-16 --version && \
cmake $BUILD_FLAGS .. && \
cmake --build . --target package --config RelWithDebInfo

# /tmp/manticore_uselessly_long_path_to_prevent_rpm_build_issues/build/manticore-tools-debuginfo-6.2.12_230823.4553471-1.el9.x86_64.rpm and other RPMs

FROM quay.io/centos/centos:stream9-minimal

LABEL org.opencontainers.image.authors="https://issues.redhat.com/browse/THREESCALE" \
Expand Down

0 comments on commit b1b5209

Please sign in to comment.