Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/ravendb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: ravendb

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

env:
config: Release
disable_test_parallelization: true

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Setup .NET 8
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x

- name: Setup .NET 9
uses: actions/setup-dotnet@v5
with:
dotnet-version: 9.0.x

- name: Setup .NET 10
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x

- name: Run RavenDb Tests
run: ./build.sh CIRavenDb --framework net9.0
1 change: 1 addition & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"CIPolecat",
"CIPulsar",
"CIRabbitMQ",
"CIRavenDb",
"CIRedis",
"CISqlite",
"CISqlServer",
Expand Down
13 changes: 13 additions & 0 deletions build/CITargets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,19 @@ void BuildTestProjectsWithFramework(string frameworkOverride, params AbsolutePat
RunSingleProjectOneClassAtATime(leaderElectionTests);
});

Target CIRavenDb => _ => _
.ProceedAfterFailure()
.Executes(() =>
{
var ravenDbTests = RootDirectory / "src" / "Persistence" / "RavenDbTests" / "RavenDbTests.csproj";
var leaderElectionTests = RootDirectory / "src" / "Persistence" / "LeaderElection" / "RavenDbTests.LeaderElection" / "RavenDbTests.LeaderElection.csproj";

BuildTestProjectsWithFramework("net9.0", ravenDbTests, leaderElectionTests);

RunSingleProjectOneClassAtATime(ravenDbTests, frameworkOverride: "net9.0");
RunSingleProjectOneClassAtATime(leaderElectionTests, frameworkOverride: "net9.0");
});

Target CIGrpc => _ => _
.ProceedAfterFailure()
.Executes(() =>
Expand Down
70 changes: 66 additions & 4 deletions build/TestAllPersistence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,37 @@

/// <summary>
/// Discovers individual test method names from source files for leader election projects.
/// Returns tuples of (className, methodName).
/// Returns tuples of (className, methodName). Also follows class inheritance into
/// compliance base classes in src/Testing/Wolverine.ComplianceTests/ so that inherited
/// [Fact]/[Theory] methods are attributed to the concrete class.
/// </summary>
static List<(string ClassName, string MethodName)> DiscoverTestMethods(string projectDir)
{
var methodPattern = new Regex(
@"\[\s*(?:Fact|Theory).*?\]\s*(?:\[.*?\]\s*)*public\s+(?:async\s+)?(?:Task|void)\s+(\w+)\s*\(",
RegexOptions.Compiled | RegexOptions.Singleline);

var classDeclarationPattern = new Regex(
@"(?:public\s+|internal\s+|abstract\s+|sealed\s+)*class\s+(\w+)\s*(?::\s*([\w<>,\s\.]+?))?\s*(?:\{|where\b)",
RegexOptions.Compiled);

var complianceBaseDir = FindComplianceTestsDir(projectDir);

var testFiles = Directory.GetFiles(projectDir, "*.cs", SearchOption.AllDirectories)
.Where(f => !f.Contains($"{Path.DirectorySeparatorChar}obj{Path.DirectorySeparatorChar}")
&& !f.Contains($"{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}"))
.ToList();

var results = new List<(string, string)>();
var seen = new HashSet<(string, string)>();

void AddMethod(string className, string methodName)
{
if (seen.Add((className, methodName)))
{
results.Add((className, methodName));
}
}

foreach (var testFile in testFiles)
{
Expand All @@ -111,10 +128,38 @@
try
{
var content = File.ReadAllText(testFile);
var matches = methodPattern.Matches(content);
foreach (Match match in matches)

foreach (Match match in methodPattern.Matches(content))
{
results.Add((className, match.Groups[1].Value));
AddMethod(className, match.Groups[1].Value);
}

if (complianceBaseDir == null) continue;

foreach (Match classMatch in classDeclarationPattern.Matches(content))
{
var baseList = classMatch.Groups[2].Value;
if (string.IsNullOrWhiteSpace(baseList)) continue;

var concreteClassName = classMatch.Groups[1].Value;
var baseTypeName = baseList.Split(',')[0].Trim().Split('<')[0].Trim();
if (string.IsNullOrWhiteSpace(baseTypeName)) continue;

var baseFile = Path.Combine(complianceBaseDir, baseTypeName + ".cs");
if (!File.Exists(baseFile)) continue;

try
{
var baseContent = File.ReadAllText(baseFile);
foreach (Match baseMatch in methodPattern.Matches(baseContent))
{
AddMethod(concreteClassName, baseMatch.Groups[1].Value);
}
}
catch (Exception ex)
{
Log.Warning("Could not read compliance base {File}: {Message}", baseFile, ex.Message);
}
}
}
catch (Exception ex)
Expand All @@ -126,6 +171,23 @@
return results;
}

/// <summary>
/// Walks up from the project directory to locate src/Testing/Wolverine.ComplianceTests/
/// so inherited compliance tests can be discovered.
/// </summary>
static string? FindComplianceTestsDir(string projectDir)

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in build/TestAllPersistence.cs

View workflow job for this annotation

GitHub Actions / test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
var current = new DirectoryInfo(projectDir);
while (current != null)
{
var candidate = Path.Combine(current.FullName, "src", "Testing", "Wolverine.ComplianceTests");
if (Directory.Exists(candidate)) return candidate;
current = current.Parent;
}

return null;
}

/// <summary>
/// Runs a single dotnet test invocation with retry logic.
/// Returns true if the test passed (on first attempt or retry).
Expand Down
Loading