RHEL build test

This commit is contained in:
Alexey Pustovalov 2024-02-15 20:44:57 +09:00
parent 6b1997f92b
commit 2de2679f03

View File

@ -49,6 +49,8 @@ env:
PFLT_ARTIFACTS: "/tmp/artifacts" PFLT_ARTIFACTS: "/tmp/artifacts"
IMAGE_DIR: "/tmp/images" IMAGE_DIR: "/tmp/images"
RHEL_BUILD: "true"
jobs: jobs:
init_build: init_build:
name: Initialize build name: Initialize build
@ -118,7 +120,7 @@ jobs:
env: env:
MATRIX_FILE: ${{ env.MATRIX_FILE }} MATRIX_FILE: ${{ env.MATRIX_FILE }}
run: | run: |
component_list=$(jq -r '.components |map_values(select(.rhel == true)) | keys | @json' "$MATRIX_FILE") component_list=$(jq -r '.components | map_values(select(.rhel == true)) | keys | @json' "$MATRIX_FILE")
echo "::group::Zabbix Component List" echo "::group::Zabbix Component List"
echo "$component_list" echo "$component_list"
@ -146,7 +148,7 @@ jobs:
result=true result=true
fi fi
echo "::group::Branch data" echo "::group::Branch metadata"
echo "is_default_branch - $result" echo "is_default_branch - $result"
echo "current_branch - $github_ref" echo "current_branch - $github_ref"
echo "secret_prefix=RHEL_${github_ref//.}" echo "secret_prefix=RHEL_${github_ref//.}"
@ -158,8 +160,6 @@ jobs:
echo "secret_prefix=RHEL_${github_ref//.}" >> $GITHUB_OUTPUT echo "secret_prefix=RHEL_${github_ref//.}" >> $GITHUB_OUTPUT
echo "sha_short=$sha_short" >> $GITHUB_OUTPUT echo "sha_short=$sha_short" >> $GITHUB_OUTPUT
build_base: build_base:
timeout-minutes: 30 timeout-minutes: 30
name: Build ${{ matrix.build }} base (${{ matrix.arch }}) name: Build ${{ matrix.build }} base (${{ matrix.arch }})
@ -201,7 +201,7 @@ jobs:
tags: | tags: |
type=sha,suffix=-${{ steps.lc.outputs.arch }} type=sha,suffix=-${{ steps.lc.outputs.arch }}
- name: Build Zabbix Build Base - name: Build image
id: build_image id: build_image
uses: redhat-actions/buildah-build@b4dc19b4ba891854660ab1f88a097d45aa158f76 # v2.12 uses: redhat-actions/buildah-build@b4dc19b4ba891854660ab1f88a097d45aa158f76 # v2.12
with: with:
@ -239,7 +239,7 @@ jobs:
echo "image_tag_id=${TAG_ID}" >> $GITHUB_OUTPUT echo "image_tag_id=${TAG_ID}" >> $GITHUB_OUTPUT
echo "image_tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT echo "image_tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT
- name: Cache image digest - name: Cache image metadata
uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with: with:
path: | path: |
@ -262,21 +262,20 @@ jobs:
- name: Post build image - name: Post build image
if: ${{ success() || failure() }} if: ${{ success() || failure() }}
env: env:
IMAGE_TAG: ${{ steps.image_metadata.outputs.image_tag }} GITHUB_WORKSPACE: ${{ github.workspace }}
GITHUB_WORKSPACE: ${{ github.workspace }}
run: | run: |
echo "::group::Result" echo "::group::Result"
rm -rf "$GITHUB_WORKSPACE/iidfile" rm -rf "$GITHUB_WORKSPACE/iidfile"
echo "podman rmi -i -f \"${IMAGE_TAG}\"" echo "Removing working containers"
buildah rm -a 2>/dev/null || true
podman rmi -i -f "${IMAGE_TAG}" || true echo "Removing container data in storage not controlled by podman"
buildah rm -a || true podman system prune --external 2>/dev/null
podman system prune --external echo "Removing all unused container data with volumes"
podman system prune -a --volumes -f podman system prune -a --volumes -f 2>/dev/null
echo "Reseting podman storage to default state"
podman system reset -f 2>/dev/null || true podman system reset -f 2>/dev/null || true
#rm -rf /home/podman/.local/share/containers/
echo "::endgroup::" echo "::endgroup::"
@ -306,7 +305,7 @@ jobs:
run: | run: |
echo "arch=${ARCH,,}" >> $GITHUB_OUTPUT echo "arch=${ARCH,,}" >> $GITHUB_OUTPUT
- name: Download SHA256 tag of ${{ env.BASE_BUILD_NAME }}:${{ matrix.arch }} - name: Download metadata of ${{ env.BASE_BUILD_NAME }}:${{ matrix.arch }}
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with: with:
path: | path: |
@ -337,7 +336,7 @@ jobs:
echo "::group::SHA256 tag" echo "::group::SHA256 tag"
DIGEST=$(podman inspect "${BASE_TAG_ID}" --format '{{ .Digest }}') DIGEST=$(podman inspect "${BASE_TAG_ID}" --format '{{ .Digest }}')
BASE_BUILD_IMAGE="${IMAGES_PREFIX}${BASE_IMAGE}@${DIGEST}" BASE_BUILD_IMAGE="${IMAGES_PREFIX}${BASE_IMAGE}@${DIGEST}"
echo "digest=${BASE_BUILD_IMAGE}" echo "base_build_image=${BASE_BUILD_IMAGE}"
echo "::endgroup::" echo "::endgroup::"
echo "base_build_image=${BASE_BUILD_IMAGE}" >> $GITHUB_OUTPUT echo "base_build_image=${BASE_BUILD_IMAGE}" >> $GITHUB_OUTPUT
@ -350,7 +349,7 @@ jobs:
tags: | tags: |
type=sha,suffix=-${{ steps.lc.outputs.arch }} type=sha,suffix=-${{ steps.lc.outputs.arch }}
- name: Build Zabbix Build Base - name: Build image
id: build_image id: build_image
uses: redhat-actions/buildah-build@b4dc19b4ba891854660ab1f88a097d45aa158f76 # v2.12 uses: redhat-actions/buildah-build@b4dc19b4ba891854660ab1f88a097d45aa158f76 # v2.12
with: with:
@ -411,21 +410,20 @@ jobs:
- name: Post build image - name: Post build image
if: ${{ success() || failure() }} if: ${{ success() || failure() }}
env: env:
IMAGE_TAG: ${{ steps.image_metadata.outputs.image_tag }} GITHUB_WORKSPACE: ${{ github.workspace }}
GITHUB_WORKSPACE: ${{ github.workspace }}
run: | run: |
echo "::group::Result" echo "::group::Result"
rm -rf "$GITHUB_WORKSPACE/iidfile" rm -rf "$GITHUB_WORKSPACE/iidfile"
echo "podman rmi -i -f \"${IMAGE_TAG}\"" echo "Removing working containers"
buildah rm -a 2>/dev/null || true
podman rmi -i -f "${IMAGE_TAG}" || true echo "Removing container data in storage not controlled by podman"
buildah rm -a || true podman system prune --external 2>/dev/null
podman system prune --external echo "Removing all unused container data with volumes"
podman system prune -a --volumes -f podman system prune -a --volumes -f 2>/dev/null
echo "Reseting podman storage to default state"
podman system reset -f 2>/dev/null || true podman system reset -f 2>/dev/null || true
#rm -rf /home/podman/.local/share/containers/
echo "::endgroup::" echo "::endgroup::"
@ -455,6 +453,7 @@ jobs:
run: | run: |
MATRIX_BUILD=${MATRIX_BUILD^^} MATRIX_BUILD=${MATRIX_BUILD^^}
MATRIX_BUILD=${MATRIX_BUILD//-/_} MATRIX_BUILD=${MATRIX_BUILD//-/_}
echo "::group::Result" echo "::group::Result"
echo "matrix_build=${MATRIX_BUILD}" echo "matrix_build=${MATRIX_BUILD}"
echo "::endgroup::" echo "::endgroup::"
@ -475,7 +474,7 @@ jobs:
echo "build_base=${BUILD_BASE}" >> $GITHUB_OUTPUT echo "build_base=${BUILD_BASE}" >> $GITHUB_OUTPUT
- name: Download SHA256 tag of ${{ steps.build_base_image.outputs.build_base }}:${{ matrix.arch }} - name: Download metadata of ${{ steps.build_base_image.outputs.build_base }}:${{ matrix.arch }}
if: ${{ matrix.build != 'snmptraps' }} if: ${{ matrix.build != 'snmptraps' }}
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with: with:
@ -546,7 +545,7 @@ jobs:
${{ env.DOCKERFILES_DIRECTORY }}/${{ matrix.build }}/rhel/Dockerfile ${{ env.DOCKERFILES_DIRECTORY }}/${{ matrix.build }}/rhel/Dockerfile
build-args: BUILD_BASE_IMAGE=${{ steps.base_build.outputs.base_build_image }} build-args: BUILD_BASE_IMAGE=${{ steps.base_build.outputs.base_build_image }}
- name: Log in to Quay.io - name: Log in to ${{ env.REGISTRY }}
uses: redhat-actions/podman-login@9184318aae1ee5034fbfbacc0388acf12669171f # v1.6 uses: redhat-actions/podman-login@9184318aae1ee5034fbfbacc0388acf12669171f # v1.6
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }} if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
with: with:
@ -562,7 +561,7 @@ jobs:
with: with:
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
- name: Preflight - name: Preflight certification
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }} if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
env: env:
PFLT_DOCKERCONFIG: /tmp/.docker_${{ matrix.build }}_${{ matrix.arch }}_${{ needs.init_build.outputs.sha_short }} PFLT_DOCKERCONFIG: /tmp/.docker_${{ matrix.build }}_${{ matrix.arch }}_${{ needs.init_build.outputs.sha_short }}
@ -595,15 +594,15 @@ jobs:
podman rmi -i -f "$PREFLIGHT_IMAGE" podman rmi -i -f "$PREFLIGHT_IMAGE"
echo "::endgroup::" echo "::endgroup::"
- name: Push to RedHat certification procedure (2nd) - name: Push to RedHat certification procedure (all tags)
id: push_to_registry_all_tags id: push_to_registry_all_tags
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }} if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
uses: redhat-actions/push-to-registry@9986a6552bc4571882a4a67e016b17361412b4df # v2.7.1 uses: redhat-actions/push-to-registry@9986a6552bc4571882a4a67e016b17361412b4df # v2.7.1
with: with:
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
- name: Post Preflight - name: Post Preflight certification
if: ${{ success() || failure() }} if: ${{ env.AUTO_PUSH_IMAGES == 'true' && (success() || failure()) }}
env: env:
PREFLIGHT_IMAGE: ${{ env.PREFLIGHT_IMAGE }} PREFLIGHT_IMAGE: ${{ env.PREFLIGHT_IMAGE }}
PFLT_ARTIFACTS: ${{ env.PFLT_ARTIFACTS }} PFLT_ARTIFACTS: ${{ env.PFLT_ARTIFACTS }}
@ -615,26 +614,21 @@ jobs:
- name: Post build image - name: Post build image
if: ${{ success() || failure() }} if: ${{ success() || failure() }}
env:
IMAGE_TAG: ${{ steps.image_metadata.outputs.image_tag }}
run: | run: |
echo "::group::Result" echo "::group::Result"
echo "podman rmi -i -f \"${IMAGE_TAG}\"" echo "Removing working containers"
buildah rm -a 2>/dev/null || true
podman rmi -i -f "${IMAGE_TAG}" || true echo "Removing container data in storage not controlled by podman"
echo "buildah rm -a" podman system prune --external 2>/dev/null
buildah rm -a || true echo "Removing all unused container data with volumes"
echo "podman system prune --external" podman system prune -a --volumes -f 2>/dev/null
podman system prune --external echo "Reseting podman storage to default state"
echo "podman system prune -a --volumes -f"
podman system prune -a --volumes -f
echo "podman system reset"
podman system reset -f 2>/dev/null || true podman system reset -f 2>/dev/null || true
echo "::endgroup::" echo "::endgroup::"
clean_artifacts: clear_artifacts:
timeout-minutes: 90 timeout-minutes: 90
needs: [ "build_images", "init_build"] needs: [ "build_images", "init_build"]
name: Clear ${{ matrix.build }} image cache (${{ matrix.arch }}) name: Clear ${{ matrix.build }} image cache (${{ matrix.arch }})
@ -644,10 +638,10 @@ jobs:
build: ${{ fromJson(needs.init_build.outputs.database) }} build: ${{ fromJson(needs.init_build.outputs.database) }}
arch: ${{ fromJson(needs.init_build.outputs.platforms) }} arch: ${{ fromJson(needs.init_build.outputs.platforms) }}
runs-on: [self-hosted, linux, "${{ matrix.arch }}"] runs-on: [self-hosted, linux, "${{ matrix.arch }}"]
if: ${{ always() && needs.build_base_database.result == 'success' }} if: ${{ needs.build_base_database.result == 'success' }}
permissions: {} permissions: {}
steps: steps:
- name: Download SHA256 tag of ${{ matrix.build }}:${{ matrix.arch }} - name: Download metadata of ${{ matrix.build }}:${{ matrix.arch }}
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with: with:
path: | path: |
@ -657,27 +651,31 @@ jobs:
- name: Remove ${{ matrix.build }}:${{ matrix.arch }} cache - name: Remove ${{ matrix.build }}:${{ matrix.arch }} cache
env: env:
MATRIX_ARCH: ${{ matrix.arch }} CACHE_FILE_NAME: ${{ matrix.build }}_${{ matrix.arch }}
BASE_IMAGE: ${{ matrix.build }}
IMAGE_DIR: ${{ env.IMAGE_DIR }} IMAGE_DIR: ${{ env.IMAGE_DIR }}
run: | run: |
BASE_TAG=$(cat "${BASE_IMAGE}_${MATRIX_ARCH}_tag_id") echo "::group::Result"
BASE_TAG=$(cat "${CACHE_FILE_NAME}_tag_id")
echo "Removing ${IMAGE_DIR}/${BASE_TAG}"
rm -rf "${IMAGE_DIR}/${BASE_TAG}" rm -rf "${IMAGE_DIR}/${BASE_TAG}"
- name: Download SHA256 tag of ${{ env.BASE_BUILD_NAME }}:${{ matrix.arch }} echo "::endgroup::"
- name: Download metadata of ${{ env.BASE_BUILD_NAME }}:${{ matrix.arch }}
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with: with:
path: ${{ env.BASE_BUILD_NAME }}_${{ matrix.arch }}_tag_id path: |
${{ env.BASE_BUILD_NAME }}_${{ matrix.arch }}_tag_id
${{ env.BASE_BUILD_NAME }}_${{ matrix.arch }}_tag
key: ${{ env.BASE_BUILD_NAME }}-${{ matrix.arch }}-${{ github.run_id }} key: ${{ env.BASE_BUILD_NAME }}-${{ matrix.arch }}-${{ github.run_id }}
- name: Remove ${{ env.BASE_BUILD_NAME }}:${{ matrix.arch }} cache - name: Remove ${{ env.BASE_BUILD_NAME }}:${{ matrix.arch }} cache
env: env:
MATRIX_ARCH: ${{ matrix.arch }} CACHE_FILE_NAME: ${{ env.BASE_BUILD_NAME }}_${{ matrix.arch }}
BASE_IMAGE: ${{ env.BASE_BUILD_NAME }}
IMAGE_DIR: ${{ env.IMAGE_DIR }} IMAGE_DIR: ${{ env.IMAGE_DIR }}
run: | run: |
BASE_TAG=$(cat "${BASE_IMAGE}_${MATRIX_ARCH}_tag_id") echo "::group::Result"
BASE_TAG=$(cat "${CACHE_FILE_NAME}_tag_id")
echo "Removing ${IMAGE_DIR}/${BASE_TAG}"
rm -rf "${IMAGE_DIR}/${BASE_TAG}" rm -rf "${IMAGE_DIR}/${BASE_TAG}"
echo "::endgroup::"