Skip to content

Commit 49d6326

Browse files
authored
Run tests using custom images, new composite action: run-tests (#3052)
* run-tests composite action for ubuntu tests, allow custom image runs * Allow using custom image in CI workflow dispatch * Return checkout to be able to run the action * Updgrade dorny/test-reporter to v3
1 parent 244ee3f commit 49d6326

4 files changed

Lines changed: 105 additions & 28 deletions

File tree

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: 'Run StackExchange.Redis tests'
2+
description: 'Runs StackExchange.Redis tests using docker compose'
3+
4+
inputs:
5+
client-libs-test-image-tag:
6+
description: 'Tag of the client libs test image to use'
7+
required: false
8+
default: ''
9+
client-libs-test-image:
10+
description: 'Custom client libs test image name to use'
11+
required: false
12+
default: 'redislabs/client-libs-test'
13+
repository:
14+
description: 'Git repository to checkout'
15+
required: false
16+
default: ''
17+
ref:
18+
description: 'Git ref to checkout'
19+
required: false
20+
default: ''
21+
22+
runs:
23+
using: 'composite'
24+
steps:
25+
- uses: actions/checkout@v6
26+
with:
27+
repository: ${{ inputs.repository }}
28+
ref: ${{ inputs.ref }}
29+
fetch-depth: 0
30+
31+
- name: Start Redis Services (docker-compose)
32+
shell: bash
33+
working-directory: ./tests/RedisConfigs
34+
env:
35+
INPUT_CLIENT_LIBS_TEST_IMAGE_TAG: ${{ inputs.client-libs-test-image-tag }}
36+
INPUT_CLIENT_LIBS_TEST_IMAGE: ${{ inputs.client-libs-test-image }}
37+
run: |
38+
set -e
39+
40+
if [ -n "$INPUT_CLIENT_LIBS_TEST_IMAGE_TAG" ]; then
41+
if [ -z "$INPUT_CLIENT_LIBS_TEST_IMAGE" ]; then
42+
echo "Error: client-libs-test-image is required when client-libs-test-image-tag is set"
43+
exit 1
44+
fi
45+
export CLIENT_LIBS_TEST_IMAGE="$INPUT_CLIENT_LIBS_TEST_IMAGE:$INPUT_CLIENT_LIBS_TEST_IMAGE_TAG"
46+
echo "CLIENT_LIBS_TEST_IMAGE=${CLIENT_LIBS_TEST_IMAGE}" >> "$GITHUB_ENV"
47+
echo "Using custom client libs test image: ${CLIENT_LIBS_TEST_IMAGE}"
48+
fi
49+
50+
docker compose -f docker-compose.yml up -d --quiet-pull --wait
51+
52+
- name: Install .NET SDK
53+
uses: actions/setup-dotnet@v5
54+
with:
55+
dotnet-version: |
56+
6.0.x
57+
8.0.x
58+
10.0.x
59+
60+
- name: .NET Build
61+
shell: bash
62+
run: dotnet build Build.csproj -c Release /p:CI=true
63+
64+
- name: StackExchange.Redis.Tests
65+
shell: bash
66+
run: >-
67+
dotnet test tests/StackExchange.Redis.Tests/StackExchange.Redis.Tests.csproj
68+
-c Release
69+
--logger trx
70+
--logger "GitHubActions;summary-include-passed=false;summary-include-skipped=false"
71+
--results-directory ./test-results/
72+
/p:CI=true
73+
74+
- uses: dorny/test-reporter@v3
75+
continue-on-error: true
76+
if: success() || failure()
77+
with:
78+
name: Test Results - Ubuntu
79+
path: 'test-results/*.trx'
80+
reporter: dotnet-trx
81+
82+
- name: .NET Lib Pack
83+
shell: bash
84+
run: >-
85+
dotnet pack src/StackExchange.Redis/StackExchange.Redis.csproj
86+
--no-build
87+
-c Release
88+
/p:Packing=true
89+
/p:PackageOutputPath=%CD%\.nupkgs
90+
/p:CI=true

.github/workflows/CI.yml

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: CI
2+
run-name: "CI${{ github.event.inputs.client-libs-test-image-tag != '' && format(' using image: {0}', github.event.inputs.client-libs-test-image-tag) || '' }}"
23

34
on:
45
pull_request:
@@ -8,7 +9,11 @@ on:
89
- '**'
910
- '!/docs/*' # Don't run workflow when files are only in the /docs directory
1011
workflow_dispatch:
11-
12+
inputs:
13+
client-libs-test-image-tag:
14+
description: 'Tag of the client libs test image to use'
15+
required: false
16+
default: ''
1217
jobs:
1318
main:
1419
name: StackExchange.Redis (Ubuntu)
@@ -17,36 +22,15 @@ jobs:
1722
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: "1" # Enable color output, even though the console output is redirected in Actions
1823
TERM: xterm # Enable color output in GitHub Actions
1924
steps:
20-
- name: Checkout code
21-
uses: actions/checkout@v4
22-
with:
23-
fetch-depth: 0 # Fetch the full history
24-
- name: Start Redis Services (docker-compose)
25-
working-directory: ./tests/RedisConfigs
26-
run: docker compose -f docker-compose.yml up -d --wait
27-
- name: Install .NET SDK
28-
uses: actions/setup-dotnet@v4
25+
- uses: actions/checkout@v6
26+
- name: Run tests
27+
uses: ./.github/actions/run-tests
2928
with:
30-
dotnet-version: |
31-
6.0.x
32-
8.0.x
33-
10.0.x
34-
- name: .NET Build
35-
run: dotnet build Build.csproj -c Release /p:CI=true
36-
- name: StackExchange.Redis.Tests
37-
run: dotnet test tests/StackExchange.Redis.Tests/StackExchange.Redis.Tests.csproj -c Release --logger trx --logger "GitHubActions;summary-include-passed=false;summary-include-skipped=false" --results-directory ./test-results/ /p:CI=true
38-
- uses: dorny/test-reporter@v1
39-
continue-on-error: true
40-
if: success() || failure()
41-
with:
42-
name: Test Results - Ubuntu
43-
path: 'test-results/*.trx'
44-
reporter: dotnet-trx
45-
- name: .NET Lib Pack
46-
run: dotnet pack src/StackExchange.Redis/StackExchange.Redis.csproj --no-build -c Release /p:Packing=true /p:PackageOutputPath=%CD%\.nupkgs /p:CI=true
29+
client-libs-test-image-tag: "${{ github.event.inputs.client-libs-test-image-tag }}"
4730

4831
windows:
4932
name: StackExchange.Redis (Windows Server 2022)
33+
if: github.event.inputs.client-libs-test-image-tag == ''
5034
runs-on: windows-2022
5135
env:
5236
NUGET_CERT_REVOCATION_MODE: offline # Disabling signing because of massive perf hit, see https://github.com/NuGet/Home/issues/11548

tests/RedisConfigs/.docker/Redis/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM redislabs/client-libs-test:unstable-23321515778-debian
1+
ARG CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:unstable-23321515778-debian
2+
FROM ${CLIENT_LIBS_TEST_IMAGE}
23

34
COPY --from=configs ./Basic /data/Basic/
45
COPY --from=configs ./Failover /data/Failover/

tests/RedisConfigs/docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ services:
44
redis:
55
build:
66
context: .docker/Redis
7+
args:
8+
CLIENT_LIBS_TEST_IMAGE: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:unstable-23321515778-debian}
79
additional_contexts:
810
configs: .
911
platform: linux

0 commit comments

Comments
 (0)