Skip to content

Commit e08d4a1

Browse files
committed
DI-528
1 parent 4d5f9e6 commit e08d4a1

File tree

6 files changed

+112
-0
lines changed

6 files changed

+112
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Test get-supported-platforms action
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@v5
12+
13+
- name: Run get-supported-platforms OS JDK11
14+
id: platform_os_jdk11
15+
uses: ./get-supported-platforms
16+
with:
17+
dockerfile: ./get-supported-platforms/test-data/hazelcast-oss/Dockerfile
18+
jdk: 11
19+
20+
- name: Run get-supported-platforms EE JDK11
21+
id: platform_ee_jdk11
22+
uses: ./get-supported-platforms
23+
with:
24+
dockerfile: ./get-supported-platforms/test-data/hazelcast-enterprise/Dockerfile
25+
jdk: 11
26+
27+
- name: Run get-supported-platforms OS JDK11
28+
id: platform_os_jdk21
29+
uses: ./get-supported-platforms
30+
with:
31+
dockerfile: ./get-supported-platforms/test-data/hazelcast-oss/Dockerfile
32+
jdk: 21
33+
34+
- name: Run get-supported-platforms EE JDK11
35+
id: platform_ee_jdk21
36+
uses: ./get-supported-platforms
37+
with:
38+
dockerfile: ./get-supported-platforms/test-data/hazelcast-enterprise/Dockerfile
39+
jdk: 21
40+
41+
- name: Test
42+
run: |
43+
set -o errexit -o nounset -o pipefail ${RUNNER_DEBUG:+-x}
44+
source /dev/stdin <<< "$(curl --silent https://raw.githubusercontent.com/hazelcast/assert.sh/main/assert.sh)"
45+
46+
TESTS_RESULT=0
47+
48+
assert_equals() {
49+
local expected=$1
50+
local actual=$2
51+
local msg="Should be equal to ${expected}"
52+
assert_eq "$expected" "$actual" "$msg" && log_success "$msg" || TESTS_RESULT=$?
53+
}
54+
55+
assert_equals "linux/arm64,linux/amd64,linux/s390x,linux/ppc64le" "${{ steps.platform_os_jdk11.outputs.platforms }}"
56+
assert_equals "linux/arm64,linux/amd64,linux/s390x,linux/ppc64le" "${{ steps.platform_ee_jdk11.outputs.platforms }}"
57+
assert_equals "linux/arm64,linux/amd64,linux/s390x" "${{ steps.platform_os_jdk21.outputs.platforms }}"
58+
assert_equals "linux/arm64,linux/amd64,linux/s390x,linux/ppc64le" "${{ steps.platform_ee_jdk21.outputs.platforms }}"
59+
60+
assert_eq 0 "$TESTS_RESULT" "All tests should pass"

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
test-get-supported-jdks:
2626
uses: ./.github/workflows/test-get-supported-jdks.yml
2727

28+
test-get-supported-platforms:
29+
uses: ./.github/workflows/test-get-supported-platforms.yml
30+
2831
test-resolve-editions:
2932
uses: ./.github/workflows/test-resolve-editions.yml
3033

@@ -40,6 +43,7 @@ jobs:
4043
- test-download-hz-dist
4144
- test-get-hz-versions
4245
- test-get-supported-jdks
46+
- test-get-supported-platforms
4347
- test-resolve-editions
4448
- test-slack-notification
4549
if: always()

get-supported-platforms/action.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Get supported platforms
2+
inputs:
3+
dockerfile:
4+
required: true
5+
jdk:
6+
required: true
7+
outputs:
8+
platforms:
9+
value: ${{ steps.get-supported.outputs.platforms }}
10+
runs:
11+
using: "composite"
12+
steps:
13+
- shell: bash
14+
id: get-supported
15+
run: |
16+
. ${GITHUB_ACTION_PATH}/../.github/scripts/logging.functions.sh
17+
. ${GITHUB_ACTION_PATH}/../check-base-images/check-base-images.functions.sh
18+
. ${GITHUB_ACTION_PATH}/docker.functions.sh
19+
20+
base_image_name=$(get_base_image_name ${{ inputs.dockerfile }})
21+
22+
case "${base_image_name}" in
23+
*"alpine"*)
24+
echo "platforms=$(get_alpine_supported_platforms ${{ inputs.jdk }})" >> ${GITHUB_OUTPUT}
25+
;;
26+
*"ubi"*)
27+
echo "platforms=$(get_ubi_supported_platforms ${{ inputs.jdk }})" >> ${GITHUB_OUTPUT}
28+
;;
29+
*)
30+
echoerr "Unsupported platform behaviour for ${base_image_name}" ; return 1
31+
;;
32+
esac
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function get_alpine_supported_platforms() {
2+
local JDK=$1
3+
local PLATFORMS="linux/arm64,linux/amd64,linux/s390x"
4+
#already fixed on alpine:edge, probably will be released in alpine:3.20
5+
if [[ "${JDK}" -lt 17 ]]; then
6+
PLATFORMS="${PLATFORMS},linux/ppc64le"
7+
fi
8+
echo "${PLATFORMS}"
9+
}
10+
11+
function get_ubi_supported_platforms() {
12+
local JDK=$1
13+
echo "linux/arm64,linux/amd64,linux/s390x,linux/ppc64le"
14+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM redhat/ubi9-minimal:9.6
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM alpine:3

0 commit comments

Comments
 (0)