Skip to content

Reuse PR build workflows across branches #956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 25 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a3bd5ab
Reuse PR build workflows across branches
ldziedziul May 8, 2025
6a7a041
Reuse pushing tag workflow across branches
ldziedziul May 12, 2025
8652f5b
Flatten reusable workflows
ldziedziul May 12, 2025
b535b99
Add get-supported-jdks action
ldziedziul May 13, 2025
0e54ee0
Use get-supported-jdks action
ldziedziul May 13, 2025
6152ba8
Migrate tag_image_push_rhel.yml to reusable workflow
ldziedziul May 13, 2025
c6b333d
Add missing inputs
ldziedziul May 22, 2025
6194341
[WIP] Test script only when merging to master branch
ldziedziul May 23, 2025
3378db0
Extract get HZ versions to composite action
ldziedziul May 23, 2025
d9e70ec
Extract getting dist zip url to composite actions
ldziedziul May 24, 2025
5ebcfd8
Add docker info composite action
ldziedziul May 24, 2025
a098eae
Add simple smoke test composite action
ldziedziul May 24, 2025
52da94a
Add platform info composite action
ldziedziul May 24, 2025
2b98e5d
Do not share secrets between jobs
ldziedziul May 24, 2025
7ea7a0a
Add build-info composite action
ldziedziul May 24, 2025
7d5d809
Migrate _reusable_tag_image_push.yml to composite actions
ldziedziul May 24, 2025
55e4e91
Add get tags to push composite action
ldziedziul May 26, 2025
4f4d96c
Avoid using local actions in _reusable_tag_image_push.yml
ldziedziul May 26, 2025
79517eb
Improve steps names in _reusable_tag_image_push.yml
ldziedziul May 26, 2025
d3ac789
Use local logging.functions.sh in the composite action
ldziedziul May 26, 2025
837742e
Create publish-rhel-image composite action
ldziedziul May 26, 2025
a453d6c
Avoid using local actions in _reusable_tag_image_push_rhel.yml.yml
ldziedziul May 26, 2025
74b485f
Add comment for workflows being used only from master branch
ldziedziul May 30, 2025
57ec904
Migrate ee-nlc-snapshot-push.yml to reusable workflow
ldziedziul May 30, 2025
8f3cab3
Enable rest api for tests
ldziedziul May 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/actions/build-info/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Get build Info
description: Get build Info

inputs:
RELEASE_TYPE:
description: Type of the release (e.g., "ALL", "OSS", "EE")
required: true

outputs:
SHOULD_BUILD_OSS:
description: Indicates if OSS should be built
value: ${{ steps.build_info.outputs.SHOULD_BUILD_OSS }}
SHOULD_BUILD_EE:
description: Indicates if EE should be built
value: ${{ steps.build_info.outputs.SHOULD_BUILD_EE }}

runs:
using: "composite"
steps:
- name: Setup OSS variables
id: build_info
shell: bash
run: |
. ${{ github.action_path }}/build.functions.sh
echo "SHOULD_BUILD_OSS=$(should_build_oss "${{ inputs.RELEASE_TYPE }}")" >> $GITHUB_OUTPUT
echo "SHOULD_BUILD_EE=$(should_build_ee "${{ inputs.RELEASE_TYPE }}")" >> $GITHUB_OUTPUT
4 changes: 2 additions & 2 deletions .github/actions/check-redhat-service-status/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ runs:
- name: Check RedHat status
shell: bash
run: |
# shellcheck source=../.github/scripts/logging.functions.sh
. .github/scripts/logging.functions.sh
# shellcheck source=logging.functions.sh
. ${{ github.action_path }}/logging.functions.sh

# https://status.redhat.com/api
STATUS=$(curl --silent https://status.redhat.com/api/v2/status.json)
Expand Down
22 changes: 22 additions & 0 deletions .github/actions/docker-info/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Get Docker Info
description: Get Docker Info

inputs:
DOCKER_PATH:
description: Directory where Dockerfile is located
required: true

outputs:
DEFAULT_JDK:
description: Default JDK from the Dockerfile
value: ${{ steps.get_default_jdk.outputs.DEFAULT_JDK }}

runs:
using: "composite"
steps:
- name: Setup OSS variables
id: get_default_jdk
shell: bash
run: |
. ${{ github.action_path }}/docker.functions.sh
echo "DEFAULT_JDK=$(get_default_jdk ${{ inputs.DOCKER_PATH }})" >> $GITHUB_OUTPUT
4 changes: 4 additions & 0 deletions .github/actions/docker-info/docker.functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function get_default_jdk() {
local DIR=$1
awk -F= '/^ARG JDK_VERSION=/{print $2}' "$DIR/Dockerfile" | tr -d '"'
}
26 changes: 26 additions & 0 deletions .github/actions/get-hz-ee-dist-url/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Get HZ EE dist URL

inputs:
HZ_VERSION:
description: Hazelcast version
required: true
VARIANT:
description: Variant of the build ( "" or "slim"), defaults to ""
default: ""

outputs:
HAZELCAST_EE_ZIP_URL:
description: Hazelcast EE zip dist url
value: ${{ steps.get_url.outputs.HAZELCAST_EE_ZIP_URL }}


runs:
using: "composite"
steps:
- name: Get dist ZIP URL
id: get_url
shell: bash
run: |
. ${{ github.action_path }}/ee-build.functions.sh
echo "HAZELCAST_EE_ZIP_URL=$(get_hz_dist_zip "${{ inputs.VARIANT }}" "${{ inputs.HZ_VERSION }}")" >> $GITHUB_OUTPUT

35 changes: 35 additions & 0 deletions .github/actions/get-hz-oss-dist-url/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Get HZ OSS dist URL

inputs:
HZ_VERSION:
description: Hazelcast version
required: true
VARIANT:
description: Variant of the build ( "" or "slim"), defaults to ""
default: ""
HZ_SNAPSHOT_INTERNAL_USERNAME:
description: Internal username for OSS snapshot builds
required: false
HZ_SNAPSHOT_INTERNAL_PASSWORD:
description: Internal password for OSS snapshot builds
required: false

outputs:
HAZELCAST_OSS_ZIP_URL:
description: Hazelcast OSS zip dist url
value: ${{ steps.get_url.outputs.HAZELCAST_OSS_ZIP_URL }}


runs:
using: "composite"
steps:
- name: Get dist ZIP URL
id: get_url
shell: bash
env:
HZ_SNAPSHOT_INTERNAL_USERNAME: ${{ inputs.HZ_SNAPSHOT_INTERNAL_USERNAME }}
HZ_SNAPSHOT_INTERNAL_PASSWORD: ${{ inputs.HZ_SNAPSHOT_INTERNAL_PASSWORD }}
run: |
. ${{ github.action_path }}/oss-build.functions.sh
echo "HAZELCAST_OSS_ZIP_URL=$(get_hz_dist_zip "${{ inputs.VARIANT }}" "${{ inputs.HZ_VERSION }}")" >> $GITHUB_OUTPUT

34 changes: 34 additions & 0 deletions .github/actions/get-hz-versions/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Setup Hazelcast Versions
description: Sets up OSS and EE Hazelcast version variables.

outputs:
HZ_VERSION_OSS:
description: Hazelcast OSS version
value: ${{ steps.get_oss_vars.outputs.HZ_VERSION_OSS }}
LAST_RELEASED_HZ_VERSION_OSS:
description: Last released Hazelcast OSS version
value: ${{ steps.get_oss_vars.outputs.LAST_RELEASED_HZ_VERSION_OSS }}
HZ_VERSION_EE:
description: Hazelcast EE version
value: ${{ steps.get_ee_vars.outputs.HZ_VERSION_EE }}

runs:
using: "composite"
steps:
- name: Setup OSS variables
id: get_oss_vars
shell: bash
run: |
HZ_VERSION_OSS=$(awk -F '=' '/^ARG HZ_VERSION=/ {print $2}' hazelcast-oss/Dockerfile)
echo "HZ_VERSION_OSS=$HZ_VERSION_OSS" >> $GITHUB_OUTPUT

source hazelcast-oss/maven.functions.sh
LAST_RELEASED_HZ_VERSION_OSS="$(get_latest_version com.hazelcast hazelcast-distribution https://repo1.maven.org/maven2)"
echo "LAST_RELEASED_HZ_VERSION_OSS=$LAST_RELEASED_HZ_VERSION_OSS" >> $GITHUB_OUTPUT

- name: Setup EE variables
id: get_ee_vars
shell: bash
run: |
HZ_VERSION_EE=$(awk -F '=' '/^ARG HZ_VERSION=/ {print $2}' hazelcast-enterprise/Dockerfile)
echo "HZ_VERSION_EE=$HZ_VERSION_EE" >> $GITHUB_OUTPUT
23 changes: 23 additions & 0 deletions .github/actions/get-supported-jdks/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Get supported JDKs
description: Get supported JDKs
inputs:
HZ_VERSION:
description: HZ Version
required: true
outputs:
jdks:
value: ${{ steps.get-supported-jdks.outputs.jdks }}
description: Returns supported JDKs
runs:
using: "composite"
steps:
- shell: bash
id: get-supported-jdks
run: |
. ${{ github.action_path }}/version.functions.sh
HZ_VERSION="${{ inputs.HZ_VERSION }}"
if version_less_than "$HZ_VERSION" "5.4.0"; then
echo "jdks=['11', '17']" >> $GITHUB_OUTPUT
else
echo "jdks=['17', '21']" >> $GITHUB_OUTPUT
fi
66 changes: 66 additions & 0 deletions .github/actions/get-supported-jdks/version.functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
function get_supported_versions() {
local MINIMAL_VERSION=$1
git tag | sort -V | grep '^v' | cut -c2- | sed -n "/^${MINIMAL_VERSION}.*\$/,\$p" | grep -v BETA | grep -v DEVEL
}

function get_minor_versions() {
local MINIMAL_VERSION=$1
get_supported_versions "$MINIMAL_VERSION" | cut -d'-' -f1 | cut -d'.' -f1,2 | uniq
}

function get_latest_patch_version() {
local MINOR_VERSION=$(echo "$1" | cut -d'-' -f1 | cut -d'.' -f1,2)
get_supported_versions "" | grep "^$MINOR_VERSION" | tail -n 1
}

function get_latest_patch_versions() {
local MINIMAL_VERSION=$1
MINOR_VERSIONS=$(get_minor_versions "$MINIMAL_VERSION")
LATEST_PATCH_VERSIONS=()
for minor in ${MINOR_VERSIONS}
do
LATEST_PATCH_VERSIONS+=($(get_latest_patch_version "$minor"))
done
echo "${LATEST_PATCH_VERSIONS[@]}"
}

function version_less_or_equal() {
[ "$1" = "$(echo -e "$1\n$2" | sort -V | head -n1)" ]
}

function version_less_than() {
[ "$1" != "$2" ] && version_less_or_equal "$1" "$2"
}

function get_tags_descending() {
git tag -l "v*" | sort -V -r | grep -v '-'
}

function file_exists_in_tag() {
local file=$1
local tag=$2
if [ "$#" -ne 2 ]; then
echo "Error: Incorrect number of arguments. Usage: ${FUNCNAME[0]} <file> <tag>"
exit 1
fi
# subshell to wrap directory change
(
set -e
cd -- "$(git rev-parse --show-toplevel)"
git ls-tree -r "$tag" --name-only | grep "^$file$" | grep -q "^$file$"
)
}

function get_last_version_with_file() {
local file=$1
if [ "$#" -ne 1 ]; then
echo "Error: Incorrect number of arguments. Usage: ${FUNCNAME[0]} <file>"
exit 1
fi
for tag in $(get_tags_descending); do
if file_exists_in_tag "$file" "$tag"; then
echo "$tag" | cut -c2-
return
fi
done
}
97 changes: 97 additions & 0 deletions .github/actions/get-supported-jdks/version.functions_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env bash

SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"

# Source the latest version of assert.sh unit testing library and include in current shell
assert_script_content=$(curl --silent https://raw.githubusercontent.com/hazelcast/assert.sh/main/assert.sh)
# shellcheck source=/dev/null
. <(echo "${assert_script_content}")
. "$SCRIPT_DIR"/version.functions.sh

TESTS_RESULT=0

function assert_minor_versions_contain {
local MINIMAL_SUPPORTED_VERSION=$1
local EXPECTED_VERSION=$2
local ACTUAL_MINOR_VERSIONS=$(get_minor_versions "$MINIMAL_SUPPORTED_VERSION")
local MSG="Minor versions starting from $MINIMAL_SUPPORTED_VERSION should contain $EXPECTED_VERSION "
assert_contain "$ACTUAL_MINOR_VERSIONS" "$EXPECTED_VERSION" "$MSG" && log_success "$MSG" || TESTS_RESULT=$?
}

function assert_minor_versions_not_contain {
local MINIMAL_SUPPORTED_VERSION=$1
local EXPECTED_VERSION=$2
local ACTUAL_MINOR_VERSIONS=$(get_minor_versions "$MINIMAL_SUPPORTED_VERSION")
local MSG="Minor versions starting from $MINIMAL_SUPPORTED_VERSION should NOT contain $EXPECTED_VERSION"
assert_not_contain "$ACTUAL_MINOR_VERSIONS" "$EXPECTED_VERSION" "$MSG" && log_success "$MSG" || TESTS_RESULT=$?
}

function assert_latest_patch_version {
local MINOR_VERSION=$1
local EXPECTED_VERSION=$2
local ACTUAL_VERSION=$(get_latest_patch_version "$MINOR_VERSION")
local MSG="Latest patch version of $MINOR_VERSION should be $EXPECTED_VERSION"
assert_eq "$ACTUAL_VERSION" "$EXPECTED_VERSION" "$MSG" && log_success "$MSG" || TESTS_RESULT=$?
}


function assert_latest_patch_versions_contain {
local MINIMAL_SUPPORTED_VERSION=$1
local EXPECTED_VERSION=$2
local ACTUAL_LATEST_PATCH_VERSIONS=$(get_latest_patch_versions "$MINIMAL_SUPPORTED_VERSION")
local MSG="Latest patch versions starting from $MINIMAL_SUPPORTED_VERSION should contain $EXPECTED_VERSION"
assert_contain "$ACTUAL_LATEST_PATCH_VERSIONS" "$EXPECTED_VERSION" "$MSG" && log_success "$MSG" || TESTS_RESULT=$?
}

function assert_latest_patch_versions_not_contain {
local MINIMAL_SUPPORTED_VERSION=$1
local EXPECTED_VERSION=$2
local ACTUAL_LATEST_PATCH_VERSIONS=$(get_latest_patch_versions "$MINIMAL_SUPPORTED_VERSION")
local MSG="Latest patch versions starting from $MINIMAL_SUPPORTED_VERSION should NOT contain $EXPECTED_VERSION"
assert_not_contain "$ACTUAL_LATEST_PATCH_VERSIONS" "$EXPECTED_VERSION" "$MSG" && log_success "$MSG" || TESTS_RESULT=$?
}

function assert_get_last_version_with_file {
local FILE=$1
local EXPECTED_LAST_VERSION=$2
local ACTUAL_LAST_VERSION=$(get_last_version_with_file "$FILE")
assert_eq "$ACTUAL_LAST_VERSION" "$EXPECTED_LAST_VERSION" "Last version of $FILE should be ${EXPECTED_LAST_VERSION:-<none>} " || TESTS_RESULT=$?
}

log_header "Tests for get_latest_patch_version"
assert_latest_patch_version "4.2.1" "4.2.8"
assert_latest_patch_version "4.2" "4.2.8"
assert_latest_patch_version "4.2" "4.2.8"
assert_latest_patch_version "4.0" "4.0.6"
assert_latest_patch_version "4.1-BETA-1" "4.1.10"
assert_latest_patch_version "4.1" "4.1.10"
assert_latest_patch_version "3.9" "3.9.4"

log_header "Tests for get_minor_versions"
assert_minor_versions_contain "3.12" "3.12"
assert_minor_versions_contain "4.2" "4.2"
assert_minor_versions_contain "4.2" "5.0"
assert_minor_versions_contain "4.2" "5.1"
assert_minor_versions_contain "4.2" "5.2"
assert_minor_versions_not_contain "4.2" "4.1"
assert_minor_versions_not_contain "4.2" "4.0"
assert_minor_versions_not_contain "4.2" "3.9"

log_header "Tests for get_latest_patch_versions"
assert_latest_patch_versions_contain "3.9" "3.9.4"
assert_latest_patch_versions_contain "3.12" "3.12.12-1"
assert_latest_patch_versions_contain "4.0.1" "4.0.6"
assert_latest_patch_versions_contain "4.0-BETA-2" "4.0.6"
assert_latest_patch_versions_contain "4.1" "4.1.10"
assert_latest_patch_versions_not_contain "3.12" "3.12.11"
assert_latest_patch_versions_not_contain "4.2" "3.9.4"
assert_latest_patch_versions_not_contain "4.2" "4.1.10"
LATEST_5_4_DEVEL="$(git tag | sort -V | grep 'v5.4.0-DEVEL-' | tail -n 1 | cut -c2-)"
assert_latest_patch_versions_not_contain "5.3" "$LATEST_5_4_DEVEL"

log_header "Tests for get_last_version_with_file"
assert_get_last_version_with_file ".github/containerscan/allowedlist.yaml" "5.3.1" # it was removed in 5.3.2
assert_get_last_version_with_file ".github/actions/install-xmllint/action.yml" "5.4.1" # it was removed in 5.4.2
assert_get_last_version_with_file "dummy-non-existing-file" ""

assert_eq 0 "$TESTS_RESULT" "All tests should pass"
36 changes: 36 additions & 0 deletions .github/actions/get-tags-to-push/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Get tags to push

inputs:
HZ_VERSION:
description: Hazelcast version
required: true
SUFFIX:
description: Suffix for the tags (e.g., "-slim"), defaults to ""
default: ""
CURRENT_JDK:
description: Current JDK version (e.g., "21")
required: true
DEFAULT_JDK:
description: Default JDK version (e.g., "17")
required: true
IS_LATEST_LTS:
description: Whether the current JDK is the latest LTS version (true/false)
required: true

outputs:
TAGS_TO_PUSH:
description: Tags to push to the registry
value: ${{ steps.get_tags.outputs.TAGS_TO_PUSH }}

runs:
using: "composite"
steps:
- name: Get tags to push
id: get_tags
shell: bash
run: |
. ${{ github.action_path }}/get-tags-to-push.sh
TAGS_TO_PUSH=$(get_tags_to_push "${{ inputs.HZ_VERSION }}" "${{ inputs.SUFFIX }}" "${{ inputs.CURRENT_JDK }}" "${{ inputs.DEFAULT_JDK }}" "${{ inputs.IS_LATEST_LTS }}")
echo "TAGS_TO_PUSH=${TAGS_TO_PUSH}" >> $GITHUB_OUTPUT


Loading