Skip to content

Commit 5548b7a

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 fe18a3b commit 5548b7a

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

.github/workflows/reusable.yml

+13
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,16 @@ 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+
dotnet restore -s test-source
92+
dotnet run

dogfooding/PackageTest.cs

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
IDatabase db = redis.GetDatabase();
14+
15+
db.Execute("FLUSHALL");
16+
17+
db.SortedSetAdd("X", "foo", 5.1);
18+
db.SortedSetAdd("X", "bar", 8.4);
19+
db.SortedSetAdd("X", "baz", 6.7);
20+
21+
var result = db.BzmPop(0, new[] { new RedisKey("X") }, MinMaxModifier.Max, count: 2);
22+
Assert(2 == result!.Item2.Count);
23+
Assert("bar" == result.Item2[0].Value);
24+
Assert("baz" == result.Item2[1].Value);
25+
26+
result = db.BzmPop(0, "X", MinMaxModifier.Min);
27+
Assert(1 == result!.Item2.Count);
28+
Assert("foo" == result!.Item2[0].Value);
29+
30+
db.SortedSetAdd("X", "foo", 5.1);
31+
db.SortedSetAdd("X", "bar", 8.4);
32+
db.SortedSetAdd("X", "baz", 6.7);
33+
34+
var singleResult = db.BzPopMin("X", 0);
35+
Assert("foo" == singleResult!.Item2.Value);
36+
37+
singleResult = db.BzPopMax("X", 0);
38+
Assert("bar" == singleResult!.Item2.Value);
39+
40+
Console.WriteLine("All good.");
41+
}
42+
43+
/// <summary>
44+
/// Poor Man's assert, since we don't want to depend on NUnit.
45+
/// </summary>
46+
private static void Assert(bool condition)
47+
{
48+
if (!condition)
49+
{
50+
throw new System.Exception();
51+
}
52+
}
53+
}

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+
<TargetFramework>net6.0</TargetFramework>
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)