From b1b5209db2e4e3d4f155598c1805c3a881c71c6b Mon Sep 17 00:00:00 2001 From: "Aleksandar N. Kostadinov" Date: Tue, 7 Nov 2023 22:19:07 +0200 Subject: [PATCH] parametrize archs but skip cross builds --- .github/workflows/container-image-buildah.yml | 43 ++++++++++++------- .github/workflows/container-image.yml | 25 +++++++++++ Containerfile | 5 +-- 3 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/container-image.yml diff --git a/.github/workflows/container-image-buildah.yml b/.github/workflows/container-image-buildah.yml index fd4d0af..34ea642 100644 --- a/.github/workflows/container-image-buildah.yml +++ b/.github/workflows/container-image-buildah.yml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/container-image.yml b/.github/workflows/container-image.yml new file mode 100644 index 0000000..f4becb6 --- /dev/null +++ b/.github/workflows/container-image.yml @@ -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 }} diff --git a/Containerfile b/Containerfile index d7f03d7..7abebf9 100644 --- a/Containerfile +++ b/Containerfile @@ -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" \