Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
123 lines (113 loc) · 4.35 KB
/
Copy pathaction.yml
File metadata and controls
123 lines (113 loc) · 4.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: 'Run NRedisStack tests'
description: 'Runs NRedisStack tests against different Redis versions and configurations'
inputs:
dotnet-version:
description: 'SDK version'
required: true
redis-version:
description: 'Redis version to test against (MAJOR.MINOR format, e.g., "7.4", "8.0")'
required: true
verify-nuget-package:
description: 'Verify Nuget package'
required: false
default: 'false'
REDIS_CA_PEM:
description: 'Redis CA PEM'
required: true
REDIS_USER_CRT:
description: 'Redis User CRT'
required: true
REDIS_USER_PRIVATE_KEY:
description: 'Redis User Private Key'
required: true
runs:
using: "composite"
steps:
- uses: actions/checkout@v4
- name: Install .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
9.0.x
${{inputs.dotnet-version}}
dotnet-quality: 'ga'
- name: Setup Environment variables and run Redis
env:
REDIS_VERSION: ${{ inputs.redis-version }}
run: |
set -e
echo "::group::Setup Environment variables and run Redis"
dotnet_major_minor_version=$(echo "${{ inputs.dotnet-version }}" | grep -oP '^\d+\.\d+')
echo "CLR_VERSION=net${dotnet_major_minor_version}" >> $GITHUB_ENV
# Load environment variables from version-specific file
ENV_FILE="tests/dockers/.env.v${REDIS_VERSION}"
if [[ -f "$ENV_FILE" ]]; then
echo "Loading environment from $ENV_FILE"
set -a
source "$ENV_FILE"
set +a
else
echo "Environment file not found: $ENV_FILE"
exit 1
fi
docker compose --profile all -f tests/dockers/docker-compose.yml up -d --build
echo "::endgroup::"
shell: bash
# Make sure only the desired dotnet version is set both as target and as active SDK.
- name: Tweak target frameworks
shell: bash
run: |
find . -name '*.csproj' | xargs -I {} sed -E -i "s|<TargetFrameworks(.*)>.*</TargetFrameworks>|<TargetFramework\1>${CLR_VERSION}</TargetFramework>|" {}
find . -name '*.csproj' | xargs cat
jq -n --arg version ${{inputs.dotnet-version}} '{"sdk":{"version":$version,"rollForward":"latestMinor"}}' > global.json
- name: Check .NET version
shell: bash
run: dotnet --version
- name: Check .NET SDKs
shell: bash
run: dotnet --list-sdks
- name: Check .NET runtimes
shell: bash
run: dotnet --list-runtimes
- name: Restore dependencies
shell: bash
run: dotnet restore
- name: Build
shell: bash
run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true
- name: Test
shell: bash
env:
REDIS_VERSION: ${{ inputs.redis-version }}
run: |
echo "::group::Run tests"
echo "${{inputs.REDIS_CA_PEM}}" > tests/NRedisStack.Tests/bin/Debug/${CLR_VERSION}/redis_ca.pem
echo "${{inputs.REDIS_USER_CRT}}" > tests/NRedisStack.Tests/bin/Debug/${CLR_VERSION}/redis_user.crt
echo "${{inputs.REDIS_USER_PRIVATE_KEY}}" > tests/NRedisStack.Tests/bin/Debug/${CLR_VERSION}/redis_user_private.key
REDIS_VERSION=$(echo "$REDIS_VERSION" | cut -d'-' -f1)
echo $REDIS_VERSION
dotnet test -f ${CLR_VERSION} --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover -p:BuildInParallel=false tests/Test.proj --logger GitHubActions
echo "::endgroup::"
- name: Codecov
uses: codecov/codecov-action@v4
with:
verbose: true
- name: Build
shell: bash
run: dotnet pack -c Release
- name: Test against Nuget package from local source
if: inputs.verify-nuget-package == 'true'
working-directory: PackageVerification
shell: bash
run: |
echo "::group::Test against Nuget package from local source"
mkdir -p test-source
dotnet nuget add source $(readlink -f test-source) -n test-source
find .. -name '*.nupkg' | xargs -I {} dotnet nuget push {} -s test-source
ls -R
dotnet nuget remove source nuget.org
dotnet nuget list source
find . -name '*.csproj' | xargs -I {} sed -E -i 's|<TargetFrameworks(.*)>.*</TargetFrameworks>|<TargetFramework\1>${CLR_VERSION}</TargetFramework>|' {}
dotnet restore -s test-source -v detailed
dotnet run
echo "::endgroup::"