Skip to content
Draft
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
175 changes: 175 additions & 0 deletions .github/actions/run-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# Note: this action is used as a part of redis oss release and test automation in
# redis-developer/redis-oss-release-automation repo
name: 'Run Lettuce Tests'
description: 'Run Lettuce tests in a containerized environment'

inputs:
redis_version:
description: 'Redis version to test against'
required: false
client_libs_test_image_tag:
description: 'Custom client libs test image tag to use instead of redis_version'
required: false
default: ''
client_libs_test_image:
description: 'Custom client libs test image name to use'
required: false
default: ''
java_version:
description: 'Java version to use'
required: false
default: '8'
java_distribution:
description: 'Java distribution to use'
required: false
default: 'temurin'
codecov_token:
description: 'Codecov token for uploading coverage'
required: false
default: ''
# repository and ref are required for correct checkout when using action
# externally (e.g.: in redis-developer/redis-oss-release-automation)
repository:
description: 'Git repository to checkout'
required: false
default: ''
ref:
description: 'Git ref to checkout'
required: false
default: ''
redis_env_work_dir:
description: 'Redis env work directory'
required: false
default: ''
redis_env_conf_dir:
description: 'Redis env conf directory'
required: false
default: ''

runs:
using: 'composite'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}

- name: Validate inputs and prepare environment
shell: bash
id: args
env:
REDIS_VERSION: ${{ inputs.redis_version }}
CLIENT_LIBS_TEST_IMAGE: ${{ inputs.client_libs_test_image }}
CLIENT_LIBS_TEST_IMAGE_TAG: ${{ inputs.client_libs_test_image_tag }}
REDIS_ENV_WORK_DIR: ${{ inputs.redis_env_work_dir }}
REDIS_ENV_CONF_DIR: ${{ inputs.redis_env_conf_dir }}
REDIS_VERSION_LABEL: ${{ inputs.client_libs_test_image_tag || inputs.redis_version }}
run: |
echo "::group::Validate inputs"
make_args=()

if [ -n "$CLIENT_LIBS_TEST_IMAGE" ]; then
make_args+=(CLIENT_LIBS_TEST_IMAGE="$CLIENT_LIBS_TEST_IMAGE")
fi

if [ -n "$CLIENT_LIBS_TEST_IMAGE_TAG" ]; then
make_args+=(CLIENT_LIBS_TEST_IMAGE_TAG="$CLIENT_LIBS_TEST_IMAGE_TAG")
elif [ -n "$REDIS_VERSION" ]; then
make_args+=(version="$REDIS_VERSION")
else
echo "Error: redis_version or client_libs_test_image_tag input is required"
exit 1
fi

echo "make_args=${make_args[*]}" | tee -a ${GITHUB_OUTPUT}
echo "redis_version_label=$REDIS_VERSION_LABEL" | tee -a ${GITHUB_OUTPUT}
echo "::endgroup::"

echo "::group::Prepare environment paths"
if [ -z "$REDIS_ENV_CONF_DIR" ]; then
REDIS_ENV_CONF_DIR=$(readlink -f "${{ github.action_path }}/../../../src/test/resources/docker-env")
fi
echo "redis_env_conf_dir=$REDIS_ENV_CONF_DIR" | tee -a ${GITHUB_OUTPUT}

if [ -n "$REDIS_ENV_WORK_DIR" ]; then
echo "redis_env_work_dir=$REDIS_ENV_WORK_DIR" | tee -a ${GITHUB_OUTPUT}
else
REDIS_ENV_WORK_DIR=$(mktemp -du)
echo "redis_env_work_dir=$REDIS_ENV_WORK_DIR" | tee -a ${GITHUB_OUTPUT}
fi
echo "::endgroup::"

- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.java_version }}
distribution: ${{ inputs.java_distribution }}
cache: 'maven'

- name: Setup Maven
uses: s4u/setup-maven-action@v1.19.0
with:
# we already checked out the code and
# checkout without params breaks external usage of the run-tests action
checkout-enabled: false
java-version: ${{ inputs.java_version }}

- name: Set up Docker Compose environment
shell: bash
run: |
echo "::group::Create work directory"
mkdir -m 777 $REDIS_ENV_WORK_DIR
echo "Work directory: $REDIS_ENV_WORK_DIR"
echo "::endgroup::"

echo "::group::Start Redis containers"
make start ${{ steps.args.outputs.make_args }}
echo "::endgroup::"
env:
REDIS_ENV_CONF_DIR: ${{ steps.args.outputs.redis_env_conf_dir }}
REDIS_ENV_WORK_DIR: ${{ steps.args.outputs.redis_env_work_dir }}

- name: Maven offline
shell: bash
run: |
echo "::group::Download Maven dependencies"
mvn -q dependency:go-offline
echo "::endgroup::"
continue-on-error: true

- name: Run tests
shell: bash
run: |
echo "::group::Run test suite"
export TEST_WORK_FOLDER=$REDIS_ENV_WORK_DIR
make test-coverage
echo "::endgroup::"
env:
REDIS_ENV_WORK_DIR: ${{ steps.args.outputs.redis_env_work_dir }}
JVM_OPTS: -Xmx3200m
TERM: dumb

- name: Tear down Docker Compose environment
if: always()
shell: bash
run: |
echo "::group::Stop Redis containers"
make stop
echo "::endgroup::"
continue-on-error: true

- name: Upload coverage reports to Codecov
if: inputs.codecov_token != ''
uses: codecov/codecov-action@v4
with:
token: ${{ inputs.codecov_token }}

- name: Upload test failure reports to Codecov
if: always() && inputs.codecov_token != ''
uses: codecov/test-results-action@v1
with:
fail_ci_if_error: false
files: ./target/surefire-reports/TEST*,./target/failsafe-reports/TEST*
verbose: ${{ runner.debug }}
token: ${{ inputs.codecov_token }}
74 changes: 28 additions & 46 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: Continuous Integration
run-name: "Continuous Integration${{ github.event.inputs.client_libs_test_image_tag != '' && format(' using image: {0}', github.event.inputs.client_libs_test_image_tag) || '' }}"

on:
push:
paths-ignore:
Expand All @@ -17,10 +19,16 @@ on:
schedule:
- cron: '0 1 * * *' # nightly build
workflow_dispatch:
inputs:
client_libs_test_image_tag:
description: 'Custom client libs test image tag to use instead of redis_version'
required: false
default: ''

jobs:
build:
name: Build and Test
if: github.event.inputs.client_libs_test_image_tag == ''
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -32,54 +40,28 @@ jobs:
- "8.0"
- "7.4"
- "7.2"
env:
REDIS_ENV_WORK_DIR: ${{ github.workspace }}/work

steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Set Java up in the runner
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
cache: 'maven'
- name: Setup Maven
uses: s4u/setup-maven-action@v1.8.0
with:
java-version: 8
- name: Install missing dependencies to container
run: |
sudo apt update
- name: Set up Docker Compose environment
run: |
mkdir -m 777 $REDIS_ENV_WORK_DIR
make start version=${{ matrix.redis_version }}
- name: Maven offline
run: |
mvn -q dependency:go-offline
continue-on-error: true
- name: Run tests
run: |
export TEST_WORK_FOLDER=$REDIS_ENV_WORK_DIR
echo $TEST_WORK_FOLDER
ls -la $TEST_WORK_FOLDER
make test-coverage
env:
JVM_OPTS: -Xmx3200m
TERM: dumb
- name: Tear down Docker Compose environment
run: |
docker compose $COMPOSE_ENV_FILES -f src/test/resources/docker-env/docker-compose.yml down
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4

- uses: ./.github/actions/run-tests
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test failure reports to Codecov
uses: codecov/test-results-action@v1
if: always() # always upload test results to include test failures
redis_version: ${{ matrix.redis_version }}
codecov_token: ${{ secrets.CODECOV_TOKEN }}
redis_env_work_dir: ${{ github.workspace }}/work
redis_env_conf_dir: ${{ github.workspace }}/src/test/resources/docker-env

build_using_custom_image:
name: Build and Test using custom image
if: github.event.inputs.client_libs_test_image_tag != ''
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- uses: ./.github/actions/run-tests
with:
fail_ci_if_error: false
files: ./target/surefire-reports/TEST*,./target/failsafe-reports/TEST*
verbose: ${{ runner.debug }}
token: ${{ secrets.CODECOV_TOKEN }}
client_libs_test_image_tag: ${{ github.event.inputs.client_libs_test_image_tag }}
codecov_token: ${{ secrets.CODECOV_TOKEN }}
redis_env_work_dir: ${{ github.workspace }}/work
redis_env_conf_dir: ${{ github.workspace }}/src/test/resources/docker-env
19 changes: 13 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ PROFILE ?= ci
SUPPORTED_TEST_ENV_VERSIONS := 8.6 8.4 8.2 8.0 7.4 7.2
DEFAULT_TEST_ENV_VERSION := 8.6
REDIS_ENV_WORK_DIR := $(or ${REDIS_ENV_WORK_DIR},$(ROOT_DIR)/work)
MVN_SOCKET_ARGS := -Ddomainsocket="$(REDIS_ENV_WORK_DIR)/socket-6482" -Dsentineldomainsocket="$(REDIS_ENV_WORK_DIR)/socket-26379"

start:
@if [ -z "$(version)" ]; then \
Expand All @@ -13,12 +14,18 @@ start:
version="$(DEFAULT_TEST_ENV_VERSION)"; \
fi; \
fi; \
if ! echo "$(SUPPORTED_TEST_ENV_VERSIONS)" | grep -qw "$$version"; then \
if [ -n "$$CLIENT_LIBS_TEST_IMAGE_TAG" ]; then \
display_version="image tag $$CLIENT_LIBS_TEST_IMAGE_TAG"; \
echo "Using $$display_version"; \
version=""; \
elif ! echo "$(SUPPORTED_TEST_ENV_VERSIONS)" | grep -qw "$$version"; then \
echo "Error: Invalid version '$$version'. Supported versions are: $(SUPPORTED_TEST_ENV_VERSIONS)."; \
exit 1; \
else \
display_version="version $$version"; \
fi; \
echo "Version: $(version)"; \
default_env_file="src/test/resources/docker-env/.env"; \
default_env_file="src/test/resources/docker-env/.env"; \
custom_env_file="src/test/resources/docker-env/.env.v$$version"; \
env_files="--env-file $$default_env_file"; \
if [ -f "$$custom_env_file" ]; then \
Expand All @@ -27,15 +34,15 @@ start:
echo "Environment work directory: $(REDIS_ENV_WORK_DIR)"; \
rm -rf "$(REDIS_ENV_WORK_DIR)"; \
mkdir -p "$(REDIS_ENV_WORK_DIR)"; \
docker compose $$env_files -f src/test/resources/docker-env/docker-compose.yml --parallel 1 up -d; \
echo "Started test environment with Redis version $$version."
docker compose $$env_files -f src/test/resources/docker-env/docker-compose.yml --parallel 1 up -d --wait --quiet-pull; \
echo "Started test environment with Redis $$display_version.";


test:
mvn -DskipITs=false clean compile verify -P$(PROFILE)
mvn -DskipITs=false $(MVN_SOCKET_ARGS) clean compile verify -P$(PROFILE)

test-coverage:
mvn -DskipITs=false clean compile verify jacoco:report -P$(PROFILE)
mvn -DskipITs=false $(MVN_SOCKET_ARGS) clean compile verify jacoco:report -P$(PROFILE)

stop:
docker compose --env-file src/test/resources/docker-env/.env -f src/test/resources/docker-env/docker-compose.yml down; \
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/docker-env/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
x-client-libs-image: &client-libs-image
image: "redislabs/client-libs-test:${REDIS_VERSION:-8.6.0}"
image: "${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test}:${CLIENT_LIBS_TEST_IMAGE_TAG:-${REDIS_VERSION:-8.6.0}}"
x-client-libs-stack-image: &client-libs-stack-image
image: "redislabs/client-libs-test:${REDIS_STACK_VERSION:-8.6.0}"
image: "${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test}:${CLIENT_LIBS_TEST_IMAGE_TAG:-${REDIS_STACK_VERSION:-${REDIS_VERSION:-8.6.0}}}"

services:
# Test infrastructure used for simulating network issues to test multi-db client failover
Expand Down
Loading