Skip to content

Commit 4e1da8a

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 2ec5430 commit 4e1da8a

File tree

3 files changed

+106
-0
lines changed

3 files changed

+106
-0
lines changed

.github/workflows/reusable.yml

+14
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,17 @@ jobs:
7878
verbose: true
7979
- name: Build
8080
run: dotnet pack -c Release
81+
82+
- name: Test against Nuget package from local source
83+
if: inputs.redis_stack_type == 'edge'
84+
working-directory: dogfooding
85+
run: |
86+
mkdir -p test-source
87+
dotnet nuget add source $(readlink -f test-source) -n test-source
88+
find .. -name '*.nupkg' | xargs -I {} dotnet nuget push {} -s test-source
89+
ls -R
90+
dotnet nuget remove source nuget.org
91+
dotnet nuget list source
92+
find . -name '*.csproj' | xargs -I {} sed -E -i 's|<TargetFrameworks(.*)>.*</TargetFrameworks>|<TargetFramework\1>${{inputs.clr_version}}</TargetFramework>|' {}
93+
dotnet restore -s test-source
94+
dotnet run
+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
using NRedisStack.Core.DataTypes;
2+
using NRedisStack.RedisStackCommands;
3+
using NRedisStack.Search.Literals.Enums;
4+
using NRedisStack.Search;
5+
using NRedisStack;
6+
using StackExchange.Redis;
7+
using System.Collections.Generic;
8+
using System.Threading;
9+
using System;
10+
using static NRedisStack.Search.Schema;
11+
12+
13+
public class PackageVerification
14+
{
15+
public static void Main()
16+
{
17+
ConfigurationOptions configurationOptions = new ConfigurationOptions();
18+
configurationOptions.SyncTimeout = 20000;
19+
configurationOptions.EndPoints.Add("localhost:6379");
20+
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(configurationOptions);
21+
22+
IDatabase db = redis.GetDatabase();
23+
db.Execute("FLUSHALL");
24+
25+
IJsonCommands json = db.JSON();
26+
27+
json.Set("product:15970", "$", new
28+
{
29+
id = 15970,
30+
description = "Turtle Navy Blue Shirt",
31+
price = 34.95,
32+
});
33+
34+
json.Set("product:59263", "$", new
35+
{
36+
id = 59263,
37+
description = "Titan Silver Watch",
38+
price = 129.99,
39+
});
40+
41+
ISearchCommands ft = db.FT();
42+
43+
try
44+
{
45+
ft.DropIndex("idx1");
46+
}
47+
catch
48+
{
49+
}
50+
51+
ft.Create("idx1", new FTCreateParams().On(IndexDataType.JSON)
52+
.Prefix("product:"),
53+
new Schema().AddNumericField(new FieldName("$.id", "id"))
54+
.AddTextField(new FieldName("$.description", "description"))
55+
.AddNumericField(new FieldName("$.price", "price")));
56+
57+
// wait for index to be created
58+
Thread.Sleep(2000);
59+
60+
List<string> results = ft.Search("idx1", new Query("@description:Blue")).ToJson();
61+
62+
Assert(1 == results.Count);
63+
64+
var expected = "{\"id\":15970,\"description\":\"Turtle Navy Blue Shirt\",\"price\":34.95}";
65+
Assert(expected == results[0]);
66+
67+
Console.WriteLine("All good.");
68+
}
69+
70+
/// <summary>
71+
/// Poor Man's assert, since we don't want to depend on NUnit.
72+
/// </summary>
73+
private static void Assert(bool condition)
74+
{
75+
if (!condition)
76+
{
77+
throw new System.Exception();
78+
}
79+
}
80+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="NRedisStack" Version="*" />
10+
</ItemGroup>
11+
12+
</Project>

0 commit comments

Comments
 (0)