Skip to content

Commit

Permalink
Refactor for new params
Browse files Browse the repository at this point in the history
  • Loading branch information
JackPGreen committed Nov 8, 2024
1 parent 4b1efdd commit deaf540
Showing 1 changed file with 34 additions and 20 deletions.
54 changes: 34 additions & 20 deletions .github/workflows/test_published_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,49 @@ on:
EXPECTED_HZ_VERSION:
description: A fully-qualified version, e.g. `5.4.1`
required: true
# TODO LIST
DISTRIBUTION_TYPE:
required: true
description: The type of distribution - `oss` or `ee`
# TODO
description: The type of distribution - `oss` or `ee` - supplied as a comma-separated list (e.g. `oss`, `ee`)
DEFAULT_JAVA_VERSION:
required: true
description: The expected Java major version (e.g. `21`, `8`) used in the
description: The expected Java major version (e.g. `21`, `8`) used by default in the image
OTHER_JDKS:
required: true
description: The other Java variant images to test (e.g. `5-jdk21`) - supplied as a comma-separated list of major Java versions (e.g. `8, 11, 17`)


env:
CONTAINER_NAME: my-container

jobs:
setup-matrix:
runs-on: ubuntu-latest
outputs:
distribution-type-matrix: ${{ steps.set-matrix.outputs.distribution-type-matrix }}
jdk-image-variants-matrix: ${{ steps.set-matrix.outputs.jdk-image-variants-matrix }}
steps:
- name: Parse input into matrix
id: set-matrix
run: |
// https://unix.stackexchange.com/a/719752
matrix=$(echo '"${{ inputs.DISTRIBUTION_TYPE }}"' | jq --compact-output 'split(",")' )
echo "distribution-type-matrix=$matrix" >> $GITHUB_ENV
# Add an "empty" option for base image
matrix=$(echo '"${{ inputs.OTHER_JDKS }}"' | jq --compact-output 'split(",") + [""]'
echo "jdk-image-variants-matrix=$matrix" >> $GITHUB_ENV
test:
runs-on: ubuntu-latest
needs: setup-matrix
strategy:
fail-fast: false
matrix:
variant:
- ''
- 'slim'
# Deliberately doesn't use "get-supported-jdks.yaml"
# To help test
# But also because that doesn't feature the "default" case
jdk:
- ''
- jdk17
- jdk21
distribution_type: ${{ fromJson(needs.setup-matrix.outputs.distribution-type-matrix) }}
jdk-image-variant: ${{ fromJson(needs.setup-matrix.outputs.jdk-image-variants-matrix) }}

steps:
- name: Checkout Code
Expand Down Expand Up @@ -71,15 +84,15 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Login to NLC Repository
if: inputs.DISTRIBUTION_TYPE == 'ee'
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: inputs.DISTRIBUTION_TYPE == 'ee'
if: matrix.distribution_type == 'ee'
uses: docker/login-action@v3
with:
registry: registry.connect.redhat.com
Expand All @@ -99,23 +112,24 @@ jobs:
local image_name=$2
# TODO Add java version
.github/scripts/simple-smoke-test.sh "${organization}/${image_name}":$(IFS=- ; echo "${tag_elements[*]}") "${CONTAINER_NAME}" ${{ inputs.DISTRIBUTION_TYPE }} ${expected_hz_version}
expected_jdk_version=${${{ matrix.jdk-image-variant }}:-${{ inputs.DEFAULT_JAVA_VERSION }}}
.github/scripts/simple-smoke-test.sh "${organization}/${image_name}":$(IFS=- ; echo "${tag_elements[*]}") "${CONTAINER_NAME}" ${{ matrix.distribution_type }} "${expected_hz_version}"
}
case "${{ inputs.DISTRIBUTION_TYPE }}" in
case "${{ matrix.distribution_type }}" in
"oss")
image_name="hazelcast"
;;
"ee")
image_name="hazelcast-enterprise"
;;
*)
echoerr "Unrecognized distribution type ${{ inputs.DISTRIBUTION_TYPE }}"
echoerr "Unrecognized distribution type ${{ matrix.distribution_type }}"
exit 1
;;
esac
if [[ "${{ inputs.DISTRIBUTION_TYPE }}" == "ee" ]]; then
if [[ "${{ matrix.distribution_type }}" == "ee" ]]; then
export HZ_LICENSEKEY=${{ secrets.HZ_ENTERPRISE_LICENSE }}
export HZ_INSTANCETRACKING_FILENAME=instance-tracking.txt
fi
Expand All @@ -127,16 +141,16 @@ jobs:
tag_elements+=("${{ matrix.variant }}")
fi
if [[ -n "${{ matrix.jdk }}" ]]; then
tag_elements+=("${{ matrix.jdk }}")
if [[ -n "${{ matrix.jdk-image-variant }}" ]]; then
tag_elements+=("jdk${{ matrix.jdk-image-variant }}")
fi
echo "Testing Docker registry"
simple-smoke-test hazelcast "${image_name}"
# Check additional EE repos
# Only populated for default variant, not "slim"
if [[ "${{ inputs.DISTRIBUTION_TYPE }}" == "ee" && -z "${{ matrix.variant }}" ]]; then
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
Expand Down

0 comments on commit deaf540

Please sign in to comment.