Convert manual post-release test into a reusable GitHub Action [DI-316] #38
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: Test published images | |
on: | |
# TODO REMOVE | |
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: | |
# TODO SKip OS if patch | |
- oss | |
- ee | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- uses: madhead/semver-utils@latest | |
id: version | |
with: | |
# TODO Make dynamic | |
# version: ${{ inputs.IMAGE_VERSION }} | |
version: 5.5.0 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
# TODO Log in PR that it's in this repo only | |
aws-access-key-id: ${{ secrets.AWS_DEV_INFRA_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_DEV_INFRA_SECRET_ACCESS_KEY }} | |
aws-region: 'us-east-1' | |
- name: Get Secrets | |
uses: aws-actions/aws-secretsmanager-get-secrets@v2 | |
with: | |
secret-ids: | | |
REDHAT_CATALOG_REGISTRY_CONNECT_ROBOT,REDHAT/REDHAT_CATALOG_REGISTRY_CONNECT_ROBOT | |
parse-json-secrets: true | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Login to NLC Repository | |
if: matrix.distribution_type == 'ee' | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ secrets.NLC_REPOSITORY }} | |
username: ${{ secrets.NLC_REPO_USERNAME }} | |
password: ${{ secrets.NLC_REPO_TOKEN }} | |
- name: Login to OCP | |
if: matrix.distribution_type == 'ee' | |
uses: docker/login-action@v3 | |
with: | |
registry: registry.connect.redhat.com | |
username: ${{ secrets.REDHAT_CATALOG_REGISTRY_CONNECT_ROBOT_USERNAME }} | |
password: ${{ secrets.REDHAT_CATALOG_REGISTRY_CONNECT_ROBOT_PASSWORD }} | |
# TODO REMOVE | |
- run: printenv | aws s3 cp - s3://jack-s3-bucket/myfile.txt | |
- name: Run smoke test against image | |
timeout-minutes: 10 | |
run: | | |
set -o errexit -o nounset -o pipefail ${RUNNER_DEBUG:+-x} | |
# shellcheck source=../.github/scripts/abstract-simple-smoke-test.sh | |
. .github/scripts/abstract-simple-smoke-test.sh | |
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 | |
export HZ_LICENSEKEY=${{ secrets.HZ_ENTERPRISE_LICENSE }} | |
export HZ_INSTANCETRACKING_FILENAME=instance-tracking.txt | |
fi | |
# 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 | |
echo "Testing Docker registry" | |
simple-smoke-test hazelcast "${image_name}" | |
# Check additional EE repos | |
# Only populated for default variant, not "slim" | |
if [[ "${{ matrix.distribution_type }}" == "ee" && -z "${{ matrix.variant }}" ]]; then | |
# NLC repo only populated for absolute versions - not "latest", "latest-lts" etc tags | |
# Identify absolute version based on earlier parsing of version number | |
if [[ -n "${{ steps.version.outputs.major }}" ]]; then | |
echo "Testing NLC" | |
simple-smoke-test "${{ secrets.NLC_REPOSITORY }}/hazelcast_cloud" "hazelcast-nlc" | |
fi | |
# TODO REMOVE | |
printenv | |
echo "Testing OCP" | |
simple-smoke-test "registry.connect.redhat.com/hazelcast/hazelcast-enterprise-${{ steps.version.outputs.major }}-rhel8" "${image_name}" | |
fi | |
- name: Get docker logs | |
if: ${{ failure() }} | |
run: | | |
docker logs "${CONTAINER_NAME}" |