Skip to content

Convert manual post-release test into a reusable GitHub Action [DI-316] #30

Convert manual post-release test into a reusable GitHub Action [DI-316]

Convert manual post-release test into a reusable GitHub Action [DI-316] #30

name: Test published images
on:
pull_request:
workflow_dispatch:
inputs:
IMAGE_VERSION:
required: true
description: A version, `latest` etc
EXPECTED_HZ_VERSION:
required: true
env:
CONTAINER_NAME: my-container
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
variant:
- ''
- 'slim'
jdk:
- ''
- jdk17
- jdk21
distribution_type:
- oss
- ee
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Login to Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- uses: madhead/semver-utils@latest
id: version
with:
# TODO Make dynamic
# version: ${{ inputs.IMAGE_VERSION }}
version: 5.5.2
- name: Run smoke test against EE image
timeout-minutes: 10
run: |
# shellcheck source=../.github/scripts/abstract-simple-smoke-test.sh
. .github/scripts/abstract-simple-smoke-test.sh
# TODO Make dynamic
#expected_hz_version=${{ inputs.EXPECTED_HZ_VERSION }}
expected_hz_version=5.5.2
# tag_elements=("${{ inputs.IMAGE_VERSION }}")
tag_elements=("5.5.2")
if [[ -n "${{ matrix.variant }}" ]]; then
tag_elements+=("${{ matrix.variant }}")
fi
if [[ -n "${{ matrix.jdk }}" ]]; then
tag_elements+=("${{ matrix.jdk }}")
fi
function simple-smoke-test() {
local organization=$1
local image_name=$2
.github/scripts/simple-smoke-test.sh "${organization}/${image_name}":$(IFS=- ; echo "${tag_elements[*]}") "${CONTAINER_NAME}" ${{ matrix.distribution_type }} ${expected_hz_version}
}
case "${{ matrix.distribution_type }}" in
"oss")
image_name="hazelcast"
;;
"ee")
image_name="hazelcast-enterprise"
;;
*)
echoerr "Unrecognized distribution type ${{ matrix.distribution_type }}"
exit 1
;;
esac
if [[ "${{ matrix.distribution_type }}" == "ee" ]]; then
# Check additional EE repos
export HZ_LICENSEKEY=${{ secrets.HZ_ENTERPRISE_LICENSE }}
export HZ_INSTANCETRACKING_FILENAME=instance-tracking.txt
# Additional repos are only populated for default variant, not "slim"
if [[ -z "${{ matrix.variant }}" ]]; then
# NLC repo only populated for absolute versions - not latest etc (tested based on earlier parsing)
if [[ -n "${{ steps.version.outputs.major }}" ]]; then
echo "Testing NLC"
echo "${{ secrets.NLC_REPO_TOKEN }}" | docker login -u "${{ secrets.NLC_REPO_USERNAME }}" "${{ secrets.NLC_REPOSITORY }}" --password-stdin
simple-smoke-test "${{ secrets.NLC_REPOSITORY }}/hazelcast_cloud" "hazelcast-nlc"
fi
# TODO Will conflicts with https://github.com/hazelcast/hazelcast-docker/pull/812
# echo "Testing OCP"
# TODO Disabled as these are the wrong credentials
# Should use credentials from https://jenkins.hazelcast.com/manage/credentials/store/system/domain/_/credential/redhat-hazelcast-release-engineering-robot/update somehow
# echo "${{ secrets.OCP_LOGIN_PASSWORD }}" | docker login -u ${{ secrets.OCP_LOGIN_USERNAME }} registry.connect.redhat.com --password-stdin
# simple-smoke-test "registry.connect.redhat.com/hazelcast/hazelcast-enterprise-${{ steps.version.outputs.major }}-rhel8" "${image_name}"
fi
fi
echo "Testing Docker registry"
simple-smoke-test hazelcast "${image_name}"
- name: Get docker logs
if: ${{ failure() }}
run: |
docker logs "${CONTAINER_NAME}"