@@ -54,6 +54,14 @@ inputs:
5454 description : " Whether to use cached Redis image (true/false)"
5555 required : false
5656 default : " true"
57+ matrix-os :
58+ description : " Matrix OS for consistent cache key generation (e.g., ubuntu-24.04)"
59+ required : false
60+ default : " ubuntu-24.04"
61+ trust-service-health :
62+ description : " Trust GitHub Actions service container health checks (skip redis-cli verification)"
63+ required : false
64+ default : " true"
5765
5866outputs :
5967 redis-available :
@@ -103,7 +111,7 @@ runs:
103111 uses : ./.github/actions/cache-redis-image
104112 with :
105113 redis-version : ${{ inputs.redis-version }}
106- runner-os : ${{ runner. os }}
114+ runner-os : ${{ inputs.matrix- os }}
107115 cache-mode : " restore"
108116
109117 # ————————————————————————————————————————————————————————————————
@@ -118,8 +126,7 @@ runs:
118126 echo "📋 Redis Configuration:"
119127 echo " • Host: ${{ inputs.redis-host }}"
120128 echo " • Port: ${{ inputs.redis-port }}"
121- echo " • Max Retries: ${{ inputs.max-retries }}"
122- echo " • Retry Interval: ${{ inputs.retry-interval }}s"
129+ echo " • Trust Service Health: ${{ inputs.trust-service-health }}"
123130 echo ""
124131
125132 # Track connection timing
@@ -130,88 +137,120 @@ runs:
130137 REDIS_VERSION="unknown"
131138 INSTALLATION_METHOD="unknown"
132139
133- # Install redis-cli if not available
134- if ! command -v redis-cli &> /dev/null; then
135- echo "📦 Installing redis-cli..."
136- if [[ "$RUNNER_OS" == "Linux" ]]; then
137- if sudo apt-get update && sudo apt-get install -y redis-tools; then
138- echo "✅ redis-cli installed successfully on Linux"
139- INSTALLATION_METHOD="installed"
140- else
141- echo "❌ Failed to install redis-cli on Linux"
140+ # Check if we should trust service container health checks
141+ TRUST_SERVICE_HEALTH="${{ inputs.trust-service-health }}"
142+ TRUST_SERVICE_HEALTH=$(echo "$TRUST_SERVICE_HEALTH" | xargs) # Trim whitespace
143+ if [[ "$TRUST_SERVICE_HEALTH" == "true" ]]; then
144+ echo "✅ Trusting GitHub Actions service container health checks"
145+ echo "🔗 Skipping redis-cli installation and verification"
146+
147+ # Assume Redis is available since service container health checks passed
148+ REDIS_AVAILABLE="true"
149+ REDIS_VERSION="service-container"
150+ INSTALLATION_METHOD="trusted-service"
151+
152+ # Set Redis connection environment variables for tests/benchmarks
153+ echo "REDIS_ADDR=${{ inputs.redis-host }}:${{ inputs.redis-port }}" >> $GITHUB_ENV
154+ echo "REDIS_HOST=${{ inputs.redis-host }}" >> $GITHUB_ENV
155+ echo "REDIS_PORT=${{ inputs.redis-port }}" >> $GITHUB_ENV
156+ echo "REDIS_URL=redis://${{ inputs.redis-host }}:${{ inputs.redis-port }}" >> $GITHUB_ENV
157+
158+ echo "✅ Redis environment variables configured:"
159+ echo " • REDIS_ADDR=${{ inputs.redis-host }}:${{ inputs.redis-port }}"
160+ echo " • REDIS_HOST=${{ inputs.redis-host }}"
161+ echo " • REDIS_PORT=${{ inputs.redis-port }}"
162+ echo " • REDIS_URL=redis://${{ inputs.redis-host }}:${{ inputs.redis-port }}"
163+
164+ else
165+ echo "🔧 Performing full Redis verification with redis-cli..."
166+ echo "📋 Retry Configuration:"
167+ echo " • Max Retries: ${{ inputs.max-retries }}"
168+ echo " • Retry Interval: ${{ inputs.retry-interval }}s"
169+ echo ""
170+
171+ # Install redis-cli if not available
172+ if ! command -v redis-cli &> /dev/null; then
173+ echo "📦 Installing redis-cli..."
174+ if [[ "$RUNNER_OS" == "Linux" ]]; then
175+ if sudo apt-get update && sudo apt-get install -y redis-tools; then
176+ echo "✅ redis-cli installed successfully on Linux"
177+ INSTALLATION_METHOD="installed"
178+ else
179+ echo "❌ Failed to install redis-cli on Linux"
180+ INSTALLATION_METHOD="unavailable"
181+ fi
182+ elif [[ "$RUNNER_OS" == "macOS" ]]; then
183+ if brew install redis; then
184+ echo "✅ redis-cli installed successfully on macOS"
185+ INSTALLATION_METHOD="installed"
186+ else
187+ echo "❌ Failed to install redis-cli on macOS"
188+ INSTALLATION_METHOD="unavailable"
189+ fi
190+ elif [[ "$RUNNER_OS" == "Windows" ]]; then
191+ echo "⚠️ Redis CLI not available on Windows runner - skipping verification"
142192 INSTALLATION_METHOD="unavailable"
143- fi
144- elif [[ "$RUNNER_OS" == "macOS" ]]; then
145- if brew install redis; then
146- echo "✅ redis-cli installed successfully on macOS"
147- INSTALLATION_METHOD="installed"
193+ echo "redis-available=false" >> $GITHUB_OUTPUT
194+ echo "redis-version=n/a" >> $GITHUB_OUTPUT
195+ echo "connection-time=0" >> $GITHUB_OUTPUT
196+ echo "installation-method=$INSTALLATION_METHOD" >> $GITHUB_OUTPUT
197+ exit 0
148198 else
149- echo "❌ Failed to install redis-cli on macOS "
199+ echo "❌ Unsupported runner OS: $RUNNER_OS "
150200 INSTALLATION_METHOD="unavailable"
151201 fi
152- elif [[ "$RUNNER_OS" == "Windows" ]]; then
153- echo "⚠️ Redis CLI not available on Windows runner - skipping verification"
154- INSTALLATION_METHOD="unavailable"
155- echo "redis-available=false" >> $GITHUB_OUTPUT
156- echo "redis-version=n/a" >> $GITHUB_OUTPUT
157- echo "connection-time=0" >> $GITHUB_OUTPUT
158- echo "installation-method=$INSTALLATION_METHOD" >> $GITHUB_OUTPUT
159- exit 0
160202 else
161- echo "❌ Unsupported runner OS: $RUNNER_OS "
162- INSTALLATION_METHOD="unavailable "
203+ echo "✅ redis-cli already available "
204+ INSTALLATION_METHOD="pre-existing "
163205 fi
164- else
165- echo "✅ redis-cli already available"
166- INSTALLATION_METHOD="pre-existing"
167- fi
168206
169- # Only proceed with verification if redis-cli is available
170- if command -v redis-cli &> /dev/null; then
171- echo "🔗 Testing Redis connection..."
207+ # Only proceed with verification if redis-cli is available
208+ if command -v redis-cli &> /dev/null; then
209+ echo "🔗 Testing Redis connection..."
210+
211+ # Test Redis connection with retries
212+ MAX_RETRIES=${{ inputs.max-retries }}
213+ RETRY_INTERVAL=${{ inputs.retry-interval }}
214+ RETRY_COUNT=0
172215
173- # Test Redis connection with retries
174- MAX_RETRIES=${{ inputs.max-retries }}
175- RETRY_INTERVAL=${{ inputs.retry-interval }}
176- RETRY_COUNT=0
216+ while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
217+ if redis-cli -h ${{ inputs.redis-host }} -p ${{ inputs.redis-port }} ping > /dev/null 2>&1; then
218+ echo "✅ Redis is responding to PING"
219+ REDIS_AVAILABLE="true"
220+ break
221+ fi
222+ RETRY_COUNT=$((RETRY_COUNT + 1))
223+ echo "⏳ Waiting for Redis... (attempt $RETRY_COUNT/$MAX_RETRIES)"
224+ sleep $RETRY_INTERVAL
225+ done
177226
178- while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
179- if redis-cli -h ${{ inputs.redis-host }} -p ${{ inputs.redis-port }} ping > /dev/null 2>&1; then
180- echo "✅ Redis is responding to PING"
181- REDIS_AVAILABLE="true"
182- break
227+ if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
228+ echo "❌ Redis failed to respond after $MAX_RETRIES attempts"
229+ REDIS_AVAILABLE="false"
183230 fi
184- RETRY_COUNT=$((RETRY_COUNT + 1))
185- echo "⏳ Waiting for Redis... (attempt $RETRY_COUNT/$MAX_RETRIES)"
186- sleep $RETRY_INTERVAL
187- done
188231
189- if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
190- echo "❌ Redis failed to respond after $MAX_RETRIES attempts"
191- REDIS_AVAILABLE="false"
192- fi
232+ # Get Redis version and additional info if connected
233+ if [ "$REDIS_AVAILABLE" = "true" ]; then
234+ echo "📊 Gathering Redis information..."
235+ REDIS_VERSION=$(redis-cli -h ${{ inputs.redis-host }} -p ${{ inputs.redis-port }} INFO server 2>/dev/null | grep "redis_version:" | cut -d: -f2 | tr -d '\r\n' || echo "unknown")
236+ echo "✅ Redis Version: $REDIS_VERSION"
237+
238+ # Set Redis connection environment variables for tests/benchmarks
239+ echo "REDIS_ADDR=${{ inputs.redis-host }}:${{ inputs.redis-port }}" >> $GITHUB_ENV
240+ echo "REDIS_HOST=${{ inputs.redis-host }}" >> $GITHUB_ENV
241+ echo "REDIS_PORT=${{ inputs.redis-port }}" >> $GITHUB_ENV
242+ echo "REDIS_URL=redis://${{ inputs.redis-host }}:${{ inputs.redis-port }}" >> $GITHUB_ENV
193243
194- # Get Redis version and additional info if connected
195- if [ "$REDIS_AVAILABLE" = "true" ]; then
196- echo "📊 Gathering Redis information..."
197- REDIS_VERSION=$(redis-cli -h ${{ inputs.redis-host }} -p ${{ inputs.redis-port }} INFO server 2>/dev/null | grep "redis_version:" | cut -d: -f2 | tr -d '\r\n' || echo "unknown")
198- echo "✅ Redis Version: $REDIS_VERSION"
199-
200- # Set Redis connection environment variables for tests/benchmarks
201- echo "REDIS_ADDR=${{ inputs.redis-host }}:${{ inputs.redis-port }}" >> $GITHUB_ENV
202- echo "REDIS_HOST=${{ inputs.redis-host }}" >> $GITHUB_ENV
203- echo "REDIS_PORT=${{ inputs.redis-port }}" >> $GITHUB_ENV
204- echo "REDIS_URL=redis://${{ inputs.redis-host }}:${{ inputs.redis-port }}" >> $GITHUB_ENV
205-
206- echo "✅ Redis environment variables configured:"
207- echo " • REDIS_ADDR=${{ inputs.redis-host }}:${{ inputs.redis-port }}"
208- echo " • REDIS_HOST=${{ inputs.redis-host }}"
209- echo " • REDIS_PORT=${{ inputs.redis-port }}"
210- echo " • REDIS_URL=redis://${{ inputs.redis-host }}:${{ inputs.redis-port }}"
244+ echo "✅ Redis environment variables configured:"
245+ echo " • REDIS_ADDR=${{ inputs.redis-host }}:${{ inputs.redis-port }}"
246+ echo " • REDIS_HOST=${{ inputs.redis-host }}"
247+ echo " • REDIS_PORT=${{ inputs.redis-port }}"
248+ echo " • REDIS_URL=redis://${{ inputs.redis-host }}:${{ inputs.redis-port }}"
249+ fi
250+ else
251+ echo "❌ redis-cli not available - cannot verify Redis connection"
252+ REDIS_AVAILABLE="false"
211253 fi
212- else
213- echo "❌ redis-cli not available - cannot verify Redis connection"
214- REDIS_AVAILABLE="false"
215254 fi
216255
217256 # Calculate connection time
@@ -236,7 +275,9 @@ runs:
236275 echo " • Cache Hit: $CACHE_HIT"
237276 echo " • Cache Operation Time: ${CACHE_TIME}s"
238277 echo " • Image Size: ${IMAGE_SIZE}MB"
239- if [[ "$CACHE_HIT" == "true" ]]; then
278+ if [[ "${{ inputs.trust-service-health }}" == "true" ]]; then
279+ echo "🚀 Redis service trusted via GitHub Actions health checks - ultra-fast startup!"
280+ elif [[ "$CACHE_HIT" == "true" ]]; then
240281 echo "🚀 Redis image restored from cache - faster startup achieved!"
241282 else
242283 echo "📥 Redis image pulled from Docker Hub - consider cache warming"
0 commit comments