Skip to content

Commit 2069211

Browse files
committed
Test binary package in CI
Issue #195 In the integration workflows, publish the binary package into a local Nuget source and use it as a binary, to make sure it works that way.
1 parent db17b89 commit 2069211

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

.github/workflows/reusable.yml

+14
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,17 @@ jobs:
7777
verbose: true
7878
- name: Build
7979
run: dotnet pack -c Release
80+
81+
- name: Test against Nuget package from local source
82+
if: inputs.redis_stack_type == 'edge'
83+
working-directory: dogfooding
84+
run: |
85+
mkdir -p test-source
86+
dotnet nuget add source $(readlink -f test-source) -n test-source
87+
find .. -name '*.nupkg' | xargs -I {} dotnet nuget push {} -s test-source
88+
ls -R
89+
dotnet nuget remove source nuget.org
90+
dotnet nuget list source
91+
find . -name '*.csproj' | xargs -I {} sed -E -i 's|<TargetFrameworks(.*)>.*</TargetFrameworks>|<TargetFramework\1>${{inputs.clr_version}}</TargetFramework>|' {}
92+
dotnet restore -s test-source
93+
dotnet run

dogfooding/PackageTest.cs

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using NRedisStack;
2+
using NRedisStack.Core.DataTypes;
3+
using StackExchange.Redis;
4+
5+
public class PackageTest
6+
{
7+
public static void Main()
8+
{
9+
ConfigurationOptions configurationOptions = new ConfigurationOptions();
10+
configurationOptions.SyncTimeout = 20000;
11+
configurationOptions.EndPoints.Add("localhost:6379");
12+
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(configurationOptions);
13+
14+
IDatabase db = redis.GetDatabase();
15+
db.Execute("FLUSHALL");
16+
17+
// Try a command from StackExchange.
18+
db.SortedSetAdd("X", "foo", 5.1);
19+
20+
// And a command from NRedisStack.
21+
var result = db.BZMPop(0, "X", MinMaxModifier.Min);
22+
Assert(1 == result!.Item2.Count);
23+
Assert("foo" == result!.Item2[0].Value);
24+
25+
Console.WriteLine("All good.");
26+
}
27+
28+
/// <summary>
29+
/// Poor Man's assert, since we don't want to depend on NUnit.
30+
/// </summary>
31+
private static void Assert(bool condition)
32+
{
33+
if (!condition)
34+
{
35+
throw new System.Exception();
36+
}
37+
}
38+
}

dogfooding/dogfooding.csproj

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="NRedisStack" Version="*" />
12+
</ItemGroup>
13+
14+
</Project>

0 commit comments

Comments
 (0)