Skip to content

Commit

Permalink
Test binary package in CI
Browse files Browse the repository at this point in the history
Issue redis#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.
  • Loading branch information
gerzse committed Feb 14, 2024
1 parent fe18a3b commit 5548b7a
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,16 @@ jobs:
verbose: true
- name: Build
run: dotnet pack -c Release

- name: Test against Nuget package from local source
if: inputs.redis_stack_type == 'edge'
working-directory: dogfooding
run: |
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
dotnet restore -s test-source
dotnet run
53 changes: 53 additions & 0 deletions dogfooding/PackageTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using NRedisStack;
using NRedisStack.Core.DataTypes;
using StackExchange.Redis;

public class PackageTest
{
public static void Main()
{
ConfigurationOptions configurationOptions = new ConfigurationOptions();
configurationOptions.SyncTimeout = 20000;
configurationOptions.EndPoints.Add("localhost:6379");
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(configurationOptions);
IDatabase db = redis.GetDatabase();

db.Execute("FLUSHALL");

db.SortedSetAdd("X", "foo", 5.1);
db.SortedSetAdd("X", "bar", 8.4);
db.SortedSetAdd("X", "baz", 6.7);

var result = db.BzmPop(0, new[] { new RedisKey("X") }, MinMaxModifier.Max, count: 2);
Assert(2 == result!.Item2.Count);
Assert("bar" == result.Item2[0].Value);
Assert("baz" == result.Item2[1].Value);

result = db.BzmPop(0, "X", MinMaxModifier.Min);
Assert(1 == result!.Item2.Count);
Assert("foo" == result!.Item2[0].Value);

db.SortedSetAdd("X", "foo", 5.1);
db.SortedSetAdd("X", "bar", 8.4);
db.SortedSetAdd("X", "baz", 6.7);

var singleResult = db.BzPopMin("X", 0);
Assert("foo" == singleResult!.Item2.Value);

singleResult = db.BzPopMax("X", 0);
Assert("bar" == singleResult!.Item2.Value);

Console.WriteLine("All good.");
}

/// <summary>
/// Poor Man's assert, since we don't want to depend on NUnit.
/// </summary>
private static void Assert(bool condition)
{
if (!condition)
{
throw new System.Exception();
}
}
}
14 changes: 14 additions & 0 deletions dogfooding/dogfooding.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NRedisStack" Version="*" />
</ItemGroup>

</Project>

0 comments on commit 5548b7a

Please sign in to comment.