Skip to content

Commit

Permalink
New comparison scfript
Browse files Browse the repository at this point in the history
  • Loading branch information
barshaul committed Jun 27, 2024
1 parent c1c5a63 commit 28fe427
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/compare-versions/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: 'Compare Versions'
description: 'Compares two versions to determine if version1 is greater than or equal to version2'
inputs:
version1:
description: 'The first version to compare'
required: true
version2:
description: 'The second version to compare'
required: true
outputs:
result:
description: 'True if version1 is greater than or equal to version2, false otherwise'
runs:
using: 'composite'
steps:
- run: |
# Function to normalize the version string to "x.y.z" format
normalize_version() {
local version=$1
# Remove any prefix like "redis-"
version=$(echo "$version" | sed 's/^redis-//')
# Append ".0" if it's in "x.y" format
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
version="$version.0"
fi
echo "$version"
}
# Function to compare two versions
compare_versions() {
local v1=$(normalize_version "$1")
local v2=$(normalize_version "$2")
# Split the versions into parts
IFS='.' read -r -a v1_parts <<< "$v1"
IFS='.' read -r -a v2_parts <<< "$v2"
for i in {0..2}; do
if [[ ${v1_parts[$i]} -gt ${v2_parts[$i]} ]]; then
echo "true"
return
elif [[ ${v1_parts[$i]} -lt ${v2_parts[$i]} ]]; then
echo "false"
return
fi
done
echo "true"
}
result=$(compare_versions "${{ inputs.version1 }}" "${{ inputs.version2 }}")
echo "::set-output name=result::$result"
shell: bash
17 changes: 14 additions & 3 deletions .github/workflows/install-valkey/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ inputs:

env:
CARGO_TERM_COLOR: always
VALKEY_MIN_VERSION: "7.2.5"

runs:
using: "composite"
Expand Down Expand Up @@ -61,13 +62,23 @@ runs:
VALKEY_RELEASE=true
else
VALKEY_RELEASE=false
fi
echo "is_valkey_release=$VALKEY_RELEASE" >> $GITHUB_OUTPUT
- name: Check if the current version is a Valkey release
id: is_valkey_release
uses: ./.github/actions/compare-versions
with:
version1: ${{ inputs.engine-version }}
version2: ${{ env.VALKEY_MIN_VERSION }}

- name: Display comparison result
shell: bash
run: |
echo "Comparison result: ${{ steps.is_valkey_release.outputs.result }}"
- name: Verify Valkey installation and symlinks
shell: bash
run: |
IS_VALKEY=${{ steps.version_calc.outputs.is_valkey_release}}
IS_VALKEY=${{ steps.is_valkey_release.outputs.result }}
EXPECTED_VERSION=`echo ${{ inputs.engine-version }} | sed -e "s/^redis-//"`
REDIS_SERVER_VER=$(redis-server -v)
if [[ $IS_VALKEY == "true" ]]; then
Expand Down

0 comments on commit 28fe427

Please sign in to comment.