Build EE RHEL image #648
Workflow file for this run
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
name: Build EE RHEL image | |
on: | |
push: | |
branches: | |
- "!*" | |
tags: | |
- "v4.*" | |
- "v5.*" | |
workflow_dispatch: | |
inputs: | |
HZ_VERSION: | |
description: 'Version of Hazelcast to build the image for, e.g. 5.1.1, 5.0.1, 4.2.3' | |
required: true | |
RELEASE_VERSION: | |
description: 'Version of the docker image e.g. 5.1.1, 5.1.1-1, defaults to HZ_VERSION' | |
required: false | |
jobs: | |
jdks: | |
uses: ./.github/workflows/get-supported-jdks.yaml | |
build: | |
defaults: | |
run: | |
shell: bash | |
env: | |
REQUIRED_HZ_MAJOR_VERSION: 5 | |
SCAN_REGISTRY: "quay.io" | |
TIMEOUT_IN_MINS: 60 | |
HZ_ENTERPRISE_LICENSE: ${{ secrets.HZ_ENTERPRISE_LICENSE }} | |
OCP_LOGIN_USERNAME: ${{ secrets.OCP_LOGIN_USERNAME }} | |
OCP_LOGIN_PASSWORD: ${{ secrets.OCP_LOGIN_PASSWORD }} | |
OCP_CLUSTER_URL: ${{ secrets.OCP_CLUSTER_URL }} | |
RHEL_API_KEY: ${{ secrets.RHEL_API_KEY }} | |
HZ_VERSION: ${{ github.event.inputs.HZ_VERSION }} | |
RELEASE_VERSION: ${{ github.event.inputs.RELEASE_VERSION }} | |
PROJECT_NAME: test-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.jdk }} | |
runs-on: ubuntu-latest | |
needs: jdks | |
strategy: | |
fail-fast: false | |
matrix: | |
jdk: ${{ fromJSON(needs.jdks.outputs.jdks) }} | |
steps: | |
- name: Set HZ version as environment variable | |
run: | | |
if [ -z "${{ env.HZ_VERSION }}" ]; then | |
HZ_VERSION=${GITHUB_REF:11} | |
else | |
HZ_VERSION=${{ env.HZ_VERSION }} | |
fi | |
echo "HZ_VERSION=${HZ_VERSION}" >> $GITHUB_ENV | |
- name: Set Release version as environment variable | |
run: | | |
if [ -z "${{ env.RELEASE_VERSION }}" ]; then | |
RELEASE_VERSION=${HZ_VERSION} | |
else | |
RELEASE_VERSION=${{ env.RELEASE_VERSION }} | |
fi | |
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV | |
- name: Check HZ major version | |
run: | | |
HZ_MAJOR_VERSION=$(echo "${HZ_VERSION:0:1}") | |
if [[ "$HZ_MAJOR_VERSION" != "$REQUIRED_HZ_MAJOR_VERSION" ]]; then | |
echo "Major version must be ${REQUIRED_HZ_MAJOR_VERSION} but detected: ${HZ_MAJOR_VERSION}" | |
exit 1 | |
fi | |
echo "HZ_MAJOR_VERSION=${HZ_MAJOR_VERSION}" >> $GITHUB_ENV | |
- name: Set scan registry secrets | |
run: | | |
echo "SCAN_REGISTRY_USER=${{ secrets[format('SCAN_REGISTRY_USER_V{0}', env.REQUIRED_HZ_MAJOR_VERSION)] }}" >> $GITHUB_ENV | |
echo "SCAN_REGISTRY_PASSWORD=${{ secrets[format('SCAN_REGISTRY_PASSWORD_V{0}', env.REQUIRED_HZ_MAJOR_VERSION)] }}" >> $GITHUB_ENV | |
echo "RHEL_PROJECT_ID=${{ secrets[format('RHEL_PROJECT_ID_V{0}', env.REQUIRED_HZ_MAJOR_VERSION)] }}" >> $GITHUB_ENV | |
- name: Checkout to Management Center Openshift | |
uses: actions/checkout@v3 | |
with: | |
repository: hazelcast/management-center-openshift | |
path: management-center-openshift | |
fetch-depth: 0 | |
- name: Set Management Center Version to be used in the tests | |
working-directory: management-center-openshift | |
run: | | |
FILTERED_TAGS=$(git tag --list "v${HZ_MAJOR_VERSION}*" | grep -E -v '.*(BETA|-).*' ) | |
LATEST_TAG=$(echo -en "${FILTERED_TAGS}" | sort | tail -n 1) | |
echo $LATEST_TAG | |
echo "HZ_MC_VERSION=${LATEST_TAG:1}" >> $GITHUB_ENV | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set RHEL image as environment variable | |
run: | | |
SCAN_REPOSITORY=${SCAN_REGISTRY}/redhat-isv-containers/${RHEL_PROJECT_ID} | |
echo "SCAN_REPOSITORY=${SCAN_REPOSITORY}" >> $GITHUB_ENV | |
echo "RHEL_IMAGE=${SCAN_REPOSITORY}:${RELEASE_VERSION}-jdk${{ matrix.jdk }}" >> $GITHUB_ENV | |
- name: Set up QEMU | |
uses: docker/[email protected] | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
version: v0.5.1 | |
- name: Log in to Red Hat Scan Registry | |
run: | | |
docker login ${SCAN_REGISTRY} -u ${SCAN_REGISTRY_USER} -p ${SCAN_REGISTRY_PASSWORD} | |
- name: Build the Hazelcast Enterprise image | |
run: | | |
. .github/scripts/get-tags-to-push.sh | |
. .github/scripts/docker.functions.sh | |
DOCKER_DIR=hazelcast-enterprise | |
IMAGE_NAME=${SCAN_REPOSITORY} | |
DEFAULT_JDK="$(get_default_jdk $DOCKER_DIR)" | |
TAGS_TO_PUSH=$(get_tags_to_push ${{ env.RELEASE_VERSION }} "${{ matrix.suffix }}" "${{ matrix.jdk }}" "$DEFAULT_JDK") | |
echo "TAGS_TO_PUSH=$TAGS_TO_PUSH" | |
TAGS_ARG="" | |
for tag in ${TAGS_TO_PUSH[@]} | |
do | |
TAGS_ARG="${TAGS_ARG} --tag ${IMAGE_NAME}:${tag}" | |
done | |
PLATFORMS="linux/amd64" | |
docker buildx build --push \ | |
--build-arg HZ_VERSION=${{ env.HZ_VERSION }} \ | |
--build-arg JDK_VERSION=${{ matrix.jdk }} \ | |
${TAGS_ARG} \ | |
--platform=${PLATFORMS} $DOCKER_DIR | |
- name: Install preflight tool | |
run: | | |
PREFLIGHT_VERSION=$(curl -s https://api.github.com/repos/redhat-openshift-ecosystem/openshift-preflight/releases/latest | grep 'tag_name' | cut -d\" -f4) | |
wget https://github.com/redhat-openshift-ecosystem/openshift-preflight/releases/download/${PREFLIGHT_VERSION}/preflight-linux-amd64 | |
chmod +x preflight-linux-amd64 | |
- name: Run preflight scan | |
run: | | |
./preflight-linux-amd64 check container ${RHEL_IMAGE} \ | |
--submit --pyxis-api-token=${RHEL_API_KEY} \ | |
--certification-project-id=${RHEL_PROJECT_ID} \ | |
--docker-config ~/.docker/config.json | |
- name: Wait for Scan to Complete | |
run: | | |
VERSION=${RELEASE_VERSION}-jdk${{ matrix.jdk }} | |
source .github/scripts/publish-rhel.sh | |
wait_for_container_scan "$RHEL_PROJECT_ID" "$VERSION" "$RHEL_API_KEY" "$TIMEOUT_IN_MINS" | |
- name: Deploy Hazelcast Cluster | |
run: | | |
WORKDIR=$(pwd)/.github/scripts | |
.github/scripts/smoke-test.sh \ | |
"$WORKDIR" \ | |
"$PROJECT_NAME" \ | |
"$OCP_LOGIN_USERNAME" \ | |
"$OCP_LOGIN_PASSWORD" \ | |
"$OCP_CLUSTER_URL" \ | |
"$SCAN_REGISTRY_USER" \ | |
"$SCAN_REGISTRY_PASSWORD" \ | |
"$SCAN_REPOSITORY" \ | |
"$RELEASE_VERSION" \ | |
"$CLUSTER_SIZE" \ | |
"$HZ_ENTERPRISE_LICENSE" \ | |
"$HZ_MC_VERSION" \ | |
"$SCAN_REGISTRY" | |
env: | |
CLUSTER_SIZE: 3 | |
- name: Validate Cluster Size | |
run: | | |
NAME=hazelcast-enterprise | |
source .github/scripts/cluster-verification.sh | |
wait_for_last_member_initialization $CLUSTER_SIZE | |
verify_cluster_size $CLUSTER_SIZE | |
echo "Waiting for ${PROJECT_NAME}-${NAME}-mancenter-0 pod to be ready" | |
oc wait --for=condition=Ready --timeout=120s pod ${PROJECT_NAME}-${NAME}-mancenter-0 | |
verify_management_center $CLUSTER_SIZE | |
env: | |
CLUSTER_SIZE: 3 | |
- name: Get OpenShift events | |
if: ${{ always() }} | |
run: | | |
kubectl get events -n ${PROJECT_NAME} > openshift-events-jdk${{ matrix.jdk }}.log | |
- name: Store OpenShift events as artifact | |
if: ${{ always() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: openshift-events-jdk${{ matrix.jdk }}.log | |
path: openshift-events-jdk${{ matrix.jdk }}.log | |
- name: Clean up After Test | |
if: always() | |
run: | | |
.github/scripts/clean-up.sh $PROJECT_NAME | |
- name: Publish the Hazelcast Enterprise image | |
run: | | |
VERSION=${RELEASE_VERSION}-jdk${{ matrix.jdk }} | |
source .github/scripts/publish-rhel.sh | |
publish_the_image "$RHEL_PROJECT_ID" "$VERSION" "$RHEL_API_KEY" | |
wait_for_container_publish "$RHEL_PROJECT_ID" "$VERSION" "$RHEL_API_KEY" "$TIMEOUT_IN_MINS" | |
sync_tags "$RHEL_PROJECT_ID" "$VERSION" "$RHEL_API_KEY" | |
- name: Slack notification | |
uses: ./.github/actions/slack-notification | |
if: failure() | |
with: | |
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK }} |