Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .github/.env.base
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,14 @@ REDIS_HOST=localhost # Redis host (localhost for GitHub Action
REDIS_PORT=6379 # Redis port (standard: 6379)

# Redis Health Check Configuration
REDIS_TRUST_SERVICE_HEALTH=true # Trust GitHub Actions service container health checks (skip redis-cli verification)
REDIS_HEALTH_CHECK_RETRIES=10 # Number of health check retries
REDIS_HEALTH_CHECK_INTERVAL=10 # Health check interval in seconds
REDIS_HEALTH_CHECK_TIMEOUT=5 # Health check timeout in seconds

# Redis Cache Configuration
REDIS_CACHE_FORCE_PULL=false # Force pull Redis images even when cached (true/false)

# ================================================================================================
# 🔧 TOOL VERSIONS
# ================================================================================================
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/cache-redis-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ runs:
fi

# ————————————————————————————————————————————————————————————————
# Save cache using actions/cache
# Save cache using actions/cache (only if cache wasn't already hit)
# ————————————————————————————————————————————————————————————————
- name: 🗄️ Save Redis image cache
if: contains(inputs.cache-mode, 'save') && steps.save-redis-image.outputs.image-saved == 'true'
if: contains(inputs.cache-mode, 'save') && steps.save-redis-image.outputs.image-saved == 'true' && steps.restore-redis-image.outputs.cache-hit != 'true'
uses: actions/cache/save@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: ${{ steps.cache-config.outputs.cache-path }}
Expand Down
20 changes: 20 additions & 0 deletions .github/actions/configure-redis/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ outputs:
redis-health-timeout:
description: "Redis health check timeout in seconds"
value: ${{ steps.redis-config.outputs.redis-health-timeout }}
redis-cache-force-pull:
description: "Whether to force pull Redis images even when cached (true/false)"
value: ${{ steps.redis-config.outputs.redis-cache-force-pull }}
redis-trust-service-health:
description: "Trust GitHub Actions service container health checks (skip redis-cli verification)"
value: ${{ steps.redis-config.outputs.redis-trust-service-health }}
redis-service-mode:
description: "Redis service mode (auto, always, never)"
value: ${{ steps.redis-config.outputs.redis-service-mode }}

runs:
using: "composite"
Expand Down Expand Up @@ -88,6 +97,8 @@ runs:
REDIS_HEALTH_RETRIES=$(echo "$ENV_JSON" | jq -r '.REDIS_HEALTH_CHECK_RETRIES // "10"')
REDIS_HEALTH_INTERVAL=$(echo "$ENV_JSON" | jq -r '.REDIS_HEALTH_CHECK_INTERVAL // "10"')
REDIS_HEALTH_TIMEOUT=$(echo "$ENV_JSON" | jq -r '.REDIS_HEALTH_CHECK_TIMEOUT // "5"')
REDIS_CACHE_FORCE_PULL=$(echo "$ENV_JSON" | jq -r '.REDIS_CACHE_FORCE_PULL // "false"')
REDIS_TRUST_SERVICE_HEALTH=$(echo "$ENV_JSON" | jq -r '.REDIS_TRUST_SERVICE_HEALTH // "true"')

echo "📋 Initial Redis Configuration:"
echo " • ENABLE_REDIS_SERVICE: $REDIS_ENABLED"
Expand All @@ -98,6 +109,8 @@ runs:
echo " • REDIS_HEALTH_CHECK_RETRIES: $REDIS_HEALTH_RETRIES"
echo " • REDIS_HEALTH_CHECK_INTERVAL: $REDIS_HEALTH_INTERVAL"
echo " • REDIS_HEALTH_CHECK_TIMEOUT: $REDIS_HEALTH_TIMEOUT"
echo " • REDIS_CACHE_FORCE_PULL: $REDIS_CACHE_FORCE_PULL"
echo " • REDIS_TRUST_SERVICE_HEALTH: $REDIS_TRUST_SERVICE_HEALTH"
echo ""

# Initialize detection tracking
Expand Down Expand Up @@ -180,12 +193,16 @@ runs:
echo "redis-health-retries=$REDIS_HEALTH_RETRIES" >> $GITHUB_OUTPUT
echo "redis-health-interval=$REDIS_HEALTH_INTERVAL" >> $GITHUB_OUTPUT
echo "redis-health-timeout=$REDIS_HEALTH_TIMEOUT" >> $GITHUB_OUTPUT
echo "redis-cache-force-pull=$REDIS_CACHE_FORCE_PULL" >> $GITHUB_OUTPUT
echo "redis-trust-service-health=$REDIS_TRUST_SERVICE_HEALTH" >> $GITHUB_OUTPUT
echo "redis-service-mode=$REDIS_MODE" >> $GITHUB_OUTPUT

# Final configuration summary
echo ""
echo "🎯 Final Redis Configuration:"
if [[ "$REDIS_ENABLED" == "true" ]]; then
echo "✅ Redis service enabled:"
echo " • Service Mode: $REDIS_MODE"
echo " • Detection Method: $DETECTION_METHOD"
echo " • Auto-detected: $AUTO_DETECTED"
echo " • Version: $REDIS_VERSION"
Expand All @@ -194,8 +211,11 @@ runs:
echo " • Health Check Retries: $REDIS_HEALTH_RETRIES"
echo " • Health Check Interval: ${REDIS_HEALTH_INTERVAL}s"
echo " • Health Check Timeout: ${REDIS_HEALTH_TIMEOUT}s"
echo " • Cache Force Pull: $REDIS_CACHE_FORCE_PULL"
echo " • Trust Service Health: $REDIS_TRUST_SERVICE_HEALTH"
else
echo "❌ Redis service disabled:"
echo " • Service Mode: $REDIS_MODE"
echo " • Detection Method: $DETECTION_METHOD"
echo " • Auto-detected: $AUTO_DETECTED"
fi
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup-magex/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ runs:
with:
path: |
~/.cache/magex-bin
key: ${{ inputs.runner-os }}-magex-${{ inputs.magex-version }}-v2
key: ${{ inputs.runner-os }}-magex-${{ inputs.magex-version }}

# ————————————————————————————————————————————————————————————————
# Make cached magex usable by copying to GOPATH/bin and adding to PATH
Expand Down
187 changes: 114 additions & 73 deletions .github/actions/setup-redis-service/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ inputs:
description: "Whether to use cached Redis image (true/false)"
required: false
default: "true"
matrix-os:
description: "Matrix OS for consistent cache key generation (e.g., ubuntu-24.04)"
required: false
default: "ubuntu-24.04"
trust-service-health:
description: "Trust GitHub Actions service container health checks (skip redis-cli verification)"
required: false
default: "true"

outputs:
redis-available:
Expand Down Expand Up @@ -103,7 +111,7 @@ runs:
uses: ./.github/actions/cache-redis-image
with:
redis-version: ${{ inputs.redis-version }}
runner-os: ${{ runner.os }}
runner-os: ${{ inputs.matrix-os }}
cache-mode: "restore"

# ————————————————————————————————————————————————————————————————
Expand All @@ -118,8 +126,7 @@ runs:
echo "📋 Redis Configuration:"
echo " • Host: ${{ inputs.redis-host }}"
echo " • Port: ${{ inputs.redis-port }}"
echo " • Max Retries: ${{ inputs.max-retries }}"
echo " • Retry Interval: ${{ inputs.retry-interval }}s"
echo " • Trust Service Health: ${{ inputs.trust-service-health }}"
echo ""

# Track connection timing
Expand All @@ -130,88 +137,120 @@ runs:
REDIS_VERSION="unknown"
INSTALLATION_METHOD="unknown"

# Install redis-cli if not available
if ! command -v redis-cli &> /dev/null; then
echo "📦 Installing redis-cli..."
if [[ "$RUNNER_OS" == "Linux" ]]; then
if sudo apt-get update && sudo apt-get install -y redis-tools; then
echo "✅ redis-cli installed successfully on Linux"
INSTALLATION_METHOD="installed"
else
echo "❌ Failed to install redis-cli on Linux"
# Check if we should trust service container health checks
TRUST_SERVICE_HEALTH="${{ inputs.trust-service-health }}"
TRUST_SERVICE_HEALTH=$(echo "$TRUST_SERVICE_HEALTH" | xargs) # Trim whitespace
if [[ "$TRUST_SERVICE_HEALTH" == "true" ]]; then
echo "✅ Trusting GitHub Actions service container health checks"
echo "🔗 Skipping redis-cli installation and verification"

# Assume Redis is available since service container health checks passed
REDIS_AVAILABLE="true"
REDIS_VERSION="service-container"
INSTALLATION_METHOD="trusted-service"

# Set Redis connection environment variables for tests/benchmarks
echo "REDIS_ADDR=${{ inputs.redis-host }}:${{ inputs.redis-port }}" >> $GITHUB_ENV
echo "REDIS_HOST=${{ inputs.redis-host }}" >> $GITHUB_ENV
echo "REDIS_PORT=${{ inputs.redis-port }}" >> $GITHUB_ENV
echo "REDIS_URL=redis://${{ inputs.redis-host }}:${{ inputs.redis-port }}" >> $GITHUB_ENV

echo "✅ Redis environment variables configured:"
echo " • REDIS_ADDR=${{ inputs.redis-host }}:${{ inputs.redis-port }}"
echo " • REDIS_HOST=${{ inputs.redis-host }}"
echo " • REDIS_PORT=${{ inputs.redis-port }}"
echo " • REDIS_URL=redis://${{ inputs.redis-host }}:${{ inputs.redis-port }}"

else
echo "🔧 Performing full Redis verification with redis-cli..."
echo "📋 Retry Configuration:"
echo " • Max Retries: ${{ inputs.max-retries }}"
echo " • Retry Interval: ${{ inputs.retry-interval }}s"
echo ""

# Install redis-cli if not available
if ! command -v redis-cli &> /dev/null; then
echo "📦 Installing redis-cli..."
if [[ "$RUNNER_OS" == "Linux" ]]; then
if sudo apt-get update && sudo apt-get install -y redis-tools; then
echo "✅ redis-cli installed successfully on Linux"
INSTALLATION_METHOD="installed"
else
echo "❌ Failed to install redis-cli on Linux"
INSTALLATION_METHOD="unavailable"
fi
elif [[ "$RUNNER_OS" == "macOS" ]]; then
if brew install redis; then
echo "✅ redis-cli installed successfully on macOS"
INSTALLATION_METHOD="installed"
else
echo "❌ Failed to install redis-cli on macOS"
INSTALLATION_METHOD="unavailable"
fi
elif [[ "$RUNNER_OS" == "Windows" ]]; then
echo "⚠️ Redis CLI not available on Windows runner - skipping verification"
INSTALLATION_METHOD="unavailable"
fi
elif [[ "$RUNNER_OS" == "macOS" ]]; then
if brew install redis; then
echo "✅ redis-cli installed successfully on macOS"
INSTALLATION_METHOD="installed"
echo "redis-available=false" >> $GITHUB_OUTPUT
echo "redis-version=n/a" >> $GITHUB_OUTPUT
echo "connection-time=0" >> $GITHUB_OUTPUT
echo "installation-method=$INSTALLATION_METHOD" >> $GITHUB_OUTPUT
exit 0
else
echo "❌ Failed to install redis-cli on macOS"
echo "❌ Unsupported runner OS: $RUNNER_OS"
INSTALLATION_METHOD="unavailable"
fi
elif [[ "$RUNNER_OS" == "Windows" ]]; then
echo "⚠️ Redis CLI not available on Windows runner - skipping verification"
INSTALLATION_METHOD="unavailable"
echo "redis-available=false" >> $GITHUB_OUTPUT
echo "redis-version=n/a" >> $GITHUB_OUTPUT
echo "connection-time=0" >> $GITHUB_OUTPUT
echo "installation-method=$INSTALLATION_METHOD" >> $GITHUB_OUTPUT
exit 0
else
echo "❌ Unsupported runner OS: $RUNNER_OS"
INSTALLATION_METHOD="unavailable"
echo "✅ redis-cli already available"
INSTALLATION_METHOD="pre-existing"
fi
else
echo "✅ redis-cli already available"
INSTALLATION_METHOD="pre-existing"
fi

# Only proceed with verification if redis-cli is available
if command -v redis-cli &> /dev/null; then
echo "🔗 Testing Redis connection..."
# Only proceed with verification if redis-cli is available
if command -v redis-cli &> /dev/null; then
echo "🔗 Testing Redis connection..."

# Test Redis connection with retries
MAX_RETRIES=${{ inputs.max-retries }}
RETRY_INTERVAL=${{ inputs.retry-interval }}
RETRY_COUNT=0

# Test Redis connection with retries
MAX_RETRIES=${{ inputs.max-retries }}
RETRY_INTERVAL=${{ inputs.retry-interval }}
RETRY_COUNT=0
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
if redis-cli -h ${{ inputs.redis-host }} -p ${{ inputs.redis-port }} ping > /dev/null 2>&1; then
echo "✅ Redis is responding to PING"
REDIS_AVAILABLE="true"
break
fi
RETRY_COUNT=$((RETRY_COUNT + 1))
echo "⏳ Waiting for Redis... (attempt $RETRY_COUNT/$MAX_RETRIES)"
sleep $RETRY_INTERVAL
done

while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
if redis-cli -h ${{ inputs.redis-host }} -p ${{ inputs.redis-port }} ping > /dev/null 2>&1; then
echo "✅ Redis is responding to PING"
REDIS_AVAILABLE="true"
break
if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
echo "❌ Redis failed to respond after $MAX_RETRIES attempts"
REDIS_AVAILABLE="false"
fi
RETRY_COUNT=$((RETRY_COUNT + 1))
echo "⏳ Waiting for Redis... (attempt $RETRY_COUNT/$MAX_RETRIES)"
sleep $RETRY_INTERVAL
done

if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
echo "❌ Redis failed to respond after $MAX_RETRIES attempts"
REDIS_AVAILABLE="false"
fi
# Get Redis version and additional info if connected
if [ "$REDIS_AVAILABLE" = "true" ]; then
echo "📊 Gathering Redis information..."
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")
echo "✅ Redis Version: $REDIS_VERSION"

# Set Redis connection environment variables for tests/benchmarks
echo "REDIS_ADDR=${{ inputs.redis-host }}:${{ inputs.redis-port }}" >> $GITHUB_ENV
echo "REDIS_HOST=${{ inputs.redis-host }}" >> $GITHUB_ENV
echo "REDIS_PORT=${{ inputs.redis-port }}" >> $GITHUB_ENV
echo "REDIS_URL=redis://${{ inputs.redis-host }}:${{ inputs.redis-port }}" >> $GITHUB_ENV

# Get Redis version and additional info if connected
if [ "$REDIS_AVAILABLE" = "true" ]; then
echo "📊 Gathering Redis information..."
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")
echo "✅ Redis Version: $REDIS_VERSION"

# Set Redis connection environment variables for tests/benchmarks
echo "REDIS_ADDR=${{ inputs.redis-host }}:${{ inputs.redis-port }}" >> $GITHUB_ENV
echo "REDIS_HOST=${{ inputs.redis-host }}" >> $GITHUB_ENV
echo "REDIS_PORT=${{ inputs.redis-port }}" >> $GITHUB_ENV
echo "REDIS_URL=redis://${{ inputs.redis-host }}:${{ inputs.redis-port }}" >> $GITHUB_ENV

echo "✅ Redis environment variables configured:"
echo " • REDIS_ADDR=${{ inputs.redis-host }}:${{ inputs.redis-port }}"
echo " • REDIS_HOST=${{ inputs.redis-host }}"
echo " • REDIS_PORT=${{ inputs.redis-port }}"
echo " • REDIS_URL=redis://${{ inputs.redis-host }}:${{ inputs.redis-port }}"
echo "✅ Redis environment variables configured:"
echo " • REDIS_ADDR=${{ inputs.redis-host }}:${{ inputs.redis-port }}"
echo " • REDIS_HOST=${{ inputs.redis-host }}"
echo " • REDIS_PORT=${{ inputs.redis-port }}"
echo " • REDIS_URL=redis://${{ inputs.redis-host }}:${{ inputs.redis-port }}"
fi
else
echo "❌ redis-cli not available - cannot verify Redis connection"
REDIS_AVAILABLE="false"
fi
else
echo "❌ redis-cli not available - cannot verify Redis connection"
REDIS_AVAILABLE="false"
fi

# Calculate connection time
Expand All @@ -236,7 +275,9 @@ runs:
echo " • Cache Hit: $CACHE_HIT"
echo " • Cache Operation Time: ${CACHE_TIME}s"
echo " • Image Size: ${IMAGE_SIZE}MB"
if [[ "$CACHE_HIT" == "true" ]]; then
if [[ "${{ inputs.trust-service-health }}" == "true" ]]; then
echo "🚀 Redis service trusted via GitHub Actions health checks - ultra-fast startup!"
elif [[ "$CACHE_HIT" == "true" ]]; then
echo "🚀 Redis image restored from cache - faster startup achieved!"
else
echo "📥 Redis image pulled from Docker Hub - consider cache warming"
Expand Down
6 changes: 5 additions & 1 deletion .github/actions/warm-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ inputs:
description: "Comma-separated list of Redis versions to warm"
required: false
default: "7-alpine"
redis-cache-force-pull:
description: "Whether to force pull Redis images even when cached"
required: false
default: "false"

runs:
using: "composite"
Expand Down Expand Up @@ -109,7 +113,7 @@ runs:
with:
redis-versions: ${{ inputs.redis-versions }}
runner-os: ${{ inputs.matrix-os }}
force-pull: "true"
force-pull: ${{ inputs.redis-cache-force-pull }}

# ————————————————————————————————————————————————————————————————
# Ensure go.sum exists and download modules
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/fortress-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ on:
required: false
type: string
default: "5"
redis-trust-service-health:
description: "Trust GitHub Actions service container health checks"
required: false
type: string
default: "true"
secrets:
github-token:
description: "GitHub token for API access"
Expand Down Expand Up @@ -154,6 +159,7 @@ jobs:
redis-host: ${{ inputs.redis-host }}
redis-port: ${{ inputs.redis-port }}
use-cache: "true"
trust-service-health: ${{ inputs.redis-trust-service-health }}

# ————————————————————————————————————————————————————————————————
# Start benchmark timer
Expand Down
Loading