Skip to content

Commit 2c6eda5

Browse files
committed
Use .env files to map Redis versions to images
1 parent ce213e5 commit 2c6eda5

File tree

9 files changed

+60
-44
lines changed

9 files changed

+60
-44
lines changed

.github/actions/run-tests/action.yml

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name: 'Run NRedisStack tests'
22
description: 'Runs NRedisStack tests against different Redis versions and configurations'
3-
inputs:
3+
inputs:
44
dotnet-version:
55
description: 'SDK version'
66
required: true
77
redis-version:
8-
description: 'Redis version to test against'
8+
description: 'Redis version to test against (MAJOR.MINOR format, e.g., "7.4", "8.0")'
99
required: true
1010
verify-nuget-package:
1111
description: 'Verify Nuget package'
@@ -36,45 +36,26 @@ runs:
3636
- name: Setup Environment variables and run Redis
3737
env:
3838
REDIS_VERSION: ${{ inputs.redis-version }}
39-
REDIS_IMAGE: "redis:${{ inputs.redis-version }}"
40-
CLIENT_LIBS_TEST_IMAGE: "redislabs/client-libs-test:${{ inputs.redis-version }}"
4139
run: |
4240
set -e
43-
41+
4442
echo "::group::Setup Environment variables and run Redis"
4543
dotnet_major_minor_version=$(echo "${{ inputs.dotnet-version }}" | grep -oP '^\d+\.\d+')
4644
echo "CLR_VERSION=net${dotnet_major_minor_version}" >> $GITHUB_ENV
4745
48-
redis_major_version=$(echo "$REDIS_VERSION" | grep -oP '^\d+')
49-
echo "REDIS_MAJOR_VERSION=${redis_major_version}" >> $GITHUB_ENV
50-
51-
if (( redis_major_version < 8 )); then
52-
echo "Using redis-stack for module tests"
53-
54-
# Mapping of redis version to stack version
55-
declare -A redis_stack_version_mapping=(
56-
["7.4.1"]="rs-7.4.0-v5"
57-
["7.2.6"]="rs-7.2.0-v17"
58-
["6.2.16"]="rs-6.2.6-v17"
59-
)
60-
61-
if [[ -v redis_stack_version_mapping[$REDIS_VERSION] ]]; then
62-
export CLIENT_LIBS_TEST_IMAGE="redislabs/client-libs-test:${redis_stack_version_mapping[$REDIS_VERSION]}"
63-
else
64-
echo "Version not found in the mapping."
65-
exit 1
66-
fi
67-
68-
if (( redis_major_version < 7 )); then
69-
export REDIS_EXTRA_ARGS="--tls-auth-clients optional --save ''"
70-
fi
71-
72-
docker compose --profile all -f tests/dockers/docker-compose.yml up -d --build
46+
# Load environment variables from version-specific file
47+
ENV_FILE="tests/dockers/.env.v${REDIS_VERSION}"
48+
if [[ -f "$ENV_FILE" ]]; then
49+
echo "Loading environment from $ENV_FILE"
50+
set -a
51+
source "$ENV_FILE"
52+
set +a
7353
else
74-
echo "Using redis CE for module tests"
75-
export CLIENT_LIBS_TEST_IMAGE="redislabs/client-libs-test:$REDIS_VERSION"
76-
docker compose --profile all -f tests/dockers/docker-compose.yml up -d --build
54+
echo "Environment file not found: $ENV_FILE"
55+
exit 1
7756
fi
57+
58+
docker compose --profile all -f tests/dockers/docker-compose.yml up -d --build
7859
echo "::endgroup::"
7960
shell: bash
8061

.github/workflows/integration.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,8 @@ concurrency:
1717

1818
env:
1919
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
20-
CURRENT_REDIS_VERSION: '8.2.3'
2120

2221
jobs:
23-
redis_version:
24-
runs-on: ubuntu-latest
25-
outputs:
26-
CURRENT: ${{ env.CURRENT_REDIS_VERSION }}
27-
steps:
28-
- name: Compute outputs
29-
run: |
30-
echo "CURRENT=${{ env.CURRENT_REDIS_VERSION }}" >> $GITHUB_OUTPUT
31-
3222
tests:
3323
runs-on: ubuntu-latest
3424
timeout-minutes: 60
@@ -37,7 +27,7 @@ jobs:
3727
max-parallel: 15
3828
fail-fast: false
3929
matrix:
40-
redis-version: [ '8.4.0', '${{ needs.redis_version.outputs.CURRENT }}', '7.4.1', '7.2.6', '6.2.16']
30+
redis-version: [ '8.6', '8.4', '8.2', '7.4', '7.2', '6.2']
4131
dotnet-version: ['8.0', '9.0']
4232
env:
4333
ACTIONS_ALLOW_UNSECURE_COMMANDS: true

tests/dockers/.env.v6.2

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Environment variables for Redis 6.2.x
2+
# Used by the run-tests GitHub Action
3+
4+
# Redis Stack image version for module tests
5+
CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:rs-6.2.6-v20
6+
7+
# Additional Redis arguments for this version
8+
REDIS_EXTRA_ARGS=--tls-auth-clients optional --save ''
9+

tests/dockers/.env.v7.2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Environment variables for Redis 7.2.x
2+
# Used by the run-tests GitHub Action
3+
4+
# Redis Stack image version for module tests
5+
CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:rs-7.2.0-v20
6+

tests/dockers/.env.v7.4

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Environment variables for Redis 7.4.x
2+
# Used by the run-tests GitHub Action
3+
4+
# Redis Stack image version for module tests
5+
CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:rs-7.4.0-v8
6+

tests/dockers/.env.v8.0

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Environment variables for Redis 8.0.x
2+
# Used by the run-tests GitHub Action
3+
4+
# Redis CE image version (Redis 8+ includes modules natively)
5+
CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:8.0.5
6+

tests/dockers/.env.v8.2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Environment variables for Redis 8.2.x
2+
# Used by the run-tests GitHub Action
3+
4+
# Redis CE image version (Redis 8+ includes modules natively)
5+
CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:8.2.3
6+

tests/dockers/.env.v8.4

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Environment variables for Redis 8.4.x
2+
# Used by the run-tests GitHub Action
3+
4+
# Redis CE image version (Redis 8+ includes modules natively)
5+
CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:8.4.0
6+

tests/dockers/.env.v8.6

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Environment variables for Redis 8.6
2+
# Used by the run-tests GitHub Action
3+
4+
# Redis CE image version (Redis 8+ includes modules natively)
5+
CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:custom-21183968220-debian-amd64
6+

0 commit comments

Comments
 (0)