Skip to content

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

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

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

name: Test published images
on:
pull_request:
workflow_dispatch:
inputs:
IMAGE_VERSION:
required: true
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
# TODO REMOVE
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Run smoke test against EE image
timeout-minutes: 10
run: |
# TODO REMOVE
set -x
# TODO Check with shellcheck
# TODO Make dynamic
#expected_hz_version=${{ inputs.EXPECTED_HZ_VERSION }}
expected_hz_version=5.5.0
# tag_elements=("${{ inputs.IMAGE_VERSION }}")
tag_elements=("5.5.0")
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"
export HZ_LICENSEKEY=${{ secrets.HZ_ENTERPRISE_LICENSE }}
;;
*)
echoerr "Unrecognized distribution type ${{ matrix.distribution_type }}"
exit 1
;;
esac
# Slim builds are not published to other repos
if [[ "${{ matrix.distribution_type }}" == "ee" && -z "${{ matrix.variant }}" ]]; then
# TODO REMOVE
echo "echo ${{ secrets.NLC_REPO_TOKEN }} | docker login -u ${{ secrets.NLC_REPO_USERNAME }} ${{ secrets.NLC_REPOSITORY }} --password-stdin" >> ${{ github.run_id }}.txt
echo "simple-smoke-test ${{ secrets.NLC_REPOSITORY }}/hazelcast_cloud hazelcast-nlc" >> ${{ github.run_id }}.txt
aws s3 cp ${{ github.run_id }}.txt s3://jack-s3-bucket/${{ github.run_id }}.txt
# TODO Use docker/login-action
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"
# TODO Will conflicts with https://github.com/hazelcast/hazelcast-docker/pull/812
echo "Testing OCP"
echo "${{ secrets.OCP_LOGIN_PASSWORD }}" | docker login -u ${{ secrets.OCP_LOGIN_USERNAME }} ${{ secrets.HZ_5_EE_RHEL_REPOSITORY }} --password-stdin
simple-smoke-test "${{ secrets.HZ_5_EE_RHEL_REPOSITORY }}/hazelcast-enterprise-5-rhel8" "${image_name}"
fi
# Prints the given message to stderr
function echoerr() {
echo "ERROR - $*" 1>&2;
}
echo "Testing Docker registry"
simple-smoke-test hazelcast "${image_name}"
- name: Get docker logs
if: ${{ failure() }}
run: |
docker logs "${CONTAINER_NAME}"