Skip to content

Commit 914af2f

Browse files
committed
Fixing problems
1 parent f4902aa commit 914af2f

File tree

17 files changed

+405
-20
lines changed

17 files changed

+405
-20
lines changed

.github/scripts/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ The compatibility validation system helps ensure that changes to the Chronicle g
1111
### Scripts
1212

1313
#### `generate-grpc-schema.sh`
14+
1415
Generates a Protocol Buffers schema definition from the Chronicle Contracts project.
1516

1617
**Usage:**
18+
1719
```bash
1820
.github/scripts/generate-grpc-schema.sh <output-file> [repo-root]
1921
```
@@ -23,21 +25,25 @@ Generates a Protocol Buffers schema definition from the Chronicle Contracts proj
2325
- `repo-root` (optional): Root directory of the repository. If not provided, auto-detects based on script location.
2426

2527
**Example:**
28+
2629
```bash
2730
.github/scripts/generate-grpc-schema.sh schema.proto
2831
# Or with custom repo root
2932
.github/scripts/generate-grpc-schema.sh schema.proto /path/to/repo
3033
```
3134

3235
#### `compare-grpc-schemas.sh`
36+
3337
Compares two gRPC schema files and detects breaking changes.
3438

3539
**Usage:**
40+
3641
```bash
3742
.github/scripts/compare-grpc-schemas.sh <baseline-schema> <current-schema>
3843
```
3944

4045
**Example:**
46+
4147
```bash
4248
.github/scripts/compare-grpc-schemas.sh baseline.proto current.proto
4349
```
@@ -47,21 +53,25 @@ Exit codes:
4753
- `1`: Breaking changes detected
4854

4955
#### `update-pr-description.sh`
56+
5057
Updates a pull request description with a warning about gRPC breaking changes.
5158

5259
**Usage:**
60+
5361
```bash
5462
GH_TOKEN=<token> .github/scripts/update-pr-description.sh <pr-number> <breaking-changes>
5563
```
5664

5765
**Example:**
66+
5867
```bash
5968
GH_TOKEN=$GITHUB_TOKEN .github/scripts/update-pr-description.sh 123 "Service 'Foo' was removed;Method 'Bar' signature changed"
6069
```
6170

6271
### Workflows
6372

6473
#### `grpc-compatibility.yml`
74+
6575
Reusable workflow that checks for gRPC contract compatibility.
6676

6777
**Inputs:**
@@ -72,6 +82,7 @@ Reusable workflow that checks for gRPC contract compatibility.
7282
- `breaking-changes`: Semicolon-separated list of breaking changes
7383

7484
**Usage in other workflows:**
85+
7586
```yaml
7687
jobs:
7788
check-grpc:

.github/scripts/generate-grpc-schema.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,34 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1212

1313
# Allow repo root to be specified as second argument, otherwise auto-detect
1414
if [ -n "$2" ]; then
15-
REPO_ROOT="$2"
15+
REPO_ROOT="$(cd "$2" && pwd)"
1616
else
1717
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
1818
fi
1919

2020
echo "Generating gRPC schema from Contracts..."
2121
echo "Repository root: $REPO_ROOT"
2222

23-
# Create a temporary project to generate the schema
24-
TEMP_DIR=$(mktemp -d)
23+
# Create a temporary project inside the repo root so MSBuild can find Directory.Packages.props
24+
TEMP_DIR=$(mktemp -d "$REPO_ROOT/.grpc-schema-gen-XXXXXX")
2525
trap "rm -rf $TEMP_DIR" EXIT
2626

27+
# Create an empty Directory.Build.props to prevent inheriting repo-wide build settings
28+
# (e.g. analyzer packages that expect CPM). The referenced Contracts.csproj is inside
29+
# the repo and will still pick up the real Directory.Build.props from its own directory
30+
# traversal.
31+
cat > "$TEMP_DIR/Directory.Build.props" << 'EOF'
32+
<Project />
33+
EOF
34+
2735
cat > "$TEMP_DIR/SchemaGenerator.csproj" << EOF
2836
<Project Sdk="Microsoft.NET.Sdk">
2937
<PropertyGroup>
3038
<OutputType>Exe</OutputType>
3139
<TargetFramework>net10.0</TargetFramework>
3240
<Nullable>enable</Nullable>
3341
<ImplicitUsings>enable</ImplicitUsings>
42+
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
3443
</PropertyGroup>
3544
<ItemGroup>
3645
<ProjectReference Include="$REPO_ROOT/Source/Kernel/Contracts/Contracts.csproj" />

.grpc-schema-gen-FdBkOS/Program.cs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
using ProtoBuf.Grpc.Reflection;
2+
using ProtoBuf.Meta;
3+
using System.Text;
4+
using Cratis.Chronicle.Contracts;
5+
using Cratis.Chronicle.Contracts.Clients;
6+
using Cratis.Chronicle.Contracts.Events;
7+
using Cratis.Chronicle.Contracts.Events.Constraints;
8+
using Cratis.Chronicle.Contracts.EventSequences;
9+
using Cratis.Chronicle.Contracts.Host;
10+
using Cratis.Chronicle.Contracts.Identities;
11+
using Cratis.Chronicle.Contracts.Jobs;
12+
using Cratis.Chronicle.Contracts.Observation;
13+
using Cratis.Chronicle.Contracts.Observation.Reactors;
14+
using Cratis.Chronicle.Contracts.Observation.Reducers;
15+
using Cratis.Chronicle.Contracts.Observation.Webhooks;
16+
using Cratis.Chronicle.Contracts.Projections;
17+
using Cratis.Chronicle.Contracts.ReadModels;
18+
using Cratis.Chronicle.Contracts.Recommendations;
19+
using Cratis.Chronicle.Contracts.Security;
20+
using Cratis.Chronicle.Contracts.Seeding;
21+
22+
// Group service types by their namespace (package)
23+
var serviceTypesByPackage = new Dictionary<string, List<Type>>
24+
{
25+
["Cratis.Chronicle.Contracts"] = new List<Type> { typeof(IEventStores), typeof(INamespaces) },
26+
["Cratis.Chronicle.Contracts.Clients"] = new List<Type> { typeof(IConnectionService) },
27+
["Cratis.Chronicle.Contracts.Events"] = new List<Type> { typeof(IEventTypes) },
28+
["Cratis.Chronicle.Contracts.Events.Constraints"] = new List<Type> { typeof(IConstraints) },
29+
["Cratis.Chronicle.Contracts.EventSequences"] = new List<Type> { typeof(IEventSequences) },
30+
["Cratis.Chronicle.Contracts.Host"] = new List<Type> { typeof(IServer) },
31+
["Cratis.Chronicle.Contracts.Identities"] = new List<Type> { typeof(IIdentities) },
32+
["Cratis.Chronicle.Contracts.Jobs"] = new List<Type> { typeof(IJobs) },
33+
["Cratis.Chronicle.Contracts.Observation"] = new List<Type> { typeof(IObservers), typeof(IFailedPartitions) },
34+
["Cratis.Chronicle.Contracts.Observation.Reactors"] = new List<Type> { typeof(IReactors) },
35+
["Cratis.Chronicle.Contracts.Observation.Reducers"] = new List<Type> { typeof(IReducers) },
36+
["Cratis.Chronicle.Contracts.Observation.Webhooks"] = new List<Type> { typeof(IWebhooks) },
37+
["Cratis.Chronicle.Contracts.Projections"] = new List<Type> { typeof(IProjections) },
38+
["Cratis.Chronicle.Contracts.ReadModels"] = new List<Type> { typeof(IReadModels) },
39+
["Cratis.Chronicle.Contracts.Recommendations"] = new List<Type> { typeof(IRecommendations) },
40+
["Cratis.Chronicle.Contracts.Security"] = new List<Type> { typeof(IApplications), typeof(IUsers) },
41+
["Cratis.Chronicle.Contracts.Seeding"] = new List<Type> { typeof(IEventSeeding) }
42+
};
43+
44+
var combinedSchema = new StringBuilder();
45+
combinedSchema.AppendLine("syntax = \"proto3\";");
46+
combinedSchema.AppendLine();
47+
48+
foreach (var kvp in serviceTypesByPackage)
49+
{
50+
var generator = new SchemaGenerator
51+
{
52+
ProtoSyntax = ProtoSyntax.Proto3
53+
};
54+
55+
try
56+
{
57+
var schema = generator.GetSchema(kvp.Value.ToArray());
58+
59+
// Remove the syntax line from individual schemas as we add it once at the top
60+
var lines = schema.Split('\n');
61+
foreach (var line in lines)
62+
{
63+
if (!line.StartsWith("syntax =") && !string.IsNullOrWhiteSpace(line))
64+
{
65+
combinedSchema.AppendLine(line);
66+
}
67+
}
68+
69+
combinedSchema.AppendLine();
70+
}
71+
catch (Exception ex)
72+
{
73+
Console.Error.WriteLine($"Error generating schema for package {kvp.Key}: {ex.Message}");
74+
}
75+
}
76+
77+
Console.WriteLine(combinedSchema.ToString());
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net10.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
8+
</PropertyGroup>
9+
<ItemGroup>
10+
<ProjectReference Include="./Source/Kernel/Contracts/Contracts.csproj" />
11+
<PackageReference Include="protobuf-net.Grpc.Reflection" Version="1.2.2" />
12+
</ItemGroup>
13+
</Project>

.grpc-schema-gen-WyTx03/Program.cs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
using ProtoBuf.Grpc.Reflection;
2+
using ProtoBuf.Meta;
3+
using System.Text;
4+
using Cratis.Chronicle.Contracts;
5+
using Cratis.Chronicle.Contracts.Clients;
6+
using Cratis.Chronicle.Contracts.Events;
7+
using Cratis.Chronicle.Contracts.Events.Constraints;
8+
using Cratis.Chronicle.Contracts.EventSequences;
9+
using Cratis.Chronicle.Contracts.Host;
10+
using Cratis.Chronicle.Contracts.Identities;
11+
using Cratis.Chronicle.Contracts.Jobs;
12+
using Cratis.Chronicle.Contracts.Observation;
13+
using Cratis.Chronicle.Contracts.Observation.Reactors;
14+
using Cratis.Chronicle.Contracts.Observation.Reducers;
15+
using Cratis.Chronicle.Contracts.Observation.Webhooks;
16+
using Cratis.Chronicle.Contracts.Projections;
17+
using Cratis.Chronicle.Contracts.ReadModels;
18+
using Cratis.Chronicle.Contracts.Recommendations;
19+
using Cratis.Chronicle.Contracts.Security;
20+
using Cratis.Chronicle.Contracts.Seeding;
21+
22+
// Group service types by their namespace (package)
23+
var serviceTypesByPackage = new Dictionary<string, List<Type>>
24+
{
25+
["Cratis.Chronicle.Contracts"] = new List<Type> { typeof(IEventStores), typeof(INamespaces) },
26+
["Cratis.Chronicle.Contracts.Clients"] = new List<Type> { typeof(IConnectionService) },
27+
["Cratis.Chronicle.Contracts.Events"] = new List<Type> { typeof(IEventTypes) },
28+
["Cratis.Chronicle.Contracts.Events.Constraints"] = new List<Type> { typeof(IConstraints) },
29+
["Cratis.Chronicle.Contracts.EventSequences"] = new List<Type> { typeof(IEventSequences) },
30+
["Cratis.Chronicle.Contracts.Host"] = new List<Type> { typeof(IServer) },
31+
["Cratis.Chronicle.Contracts.Identities"] = new List<Type> { typeof(IIdentities) },
32+
["Cratis.Chronicle.Contracts.Jobs"] = new List<Type> { typeof(IJobs) },
33+
["Cratis.Chronicle.Contracts.Observation"] = new List<Type> { typeof(IObservers), typeof(IFailedPartitions) },
34+
["Cratis.Chronicle.Contracts.Observation.Reactors"] = new List<Type> { typeof(IReactors) },
35+
["Cratis.Chronicle.Contracts.Observation.Reducers"] = new List<Type> { typeof(IReducers) },
36+
["Cratis.Chronicle.Contracts.Observation.Webhooks"] = new List<Type> { typeof(IWebhooks) },
37+
["Cratis.Chronicle.Contracts.Projections"] = new List<Type> { typeof(IProjections) },
38+
["Cratis.Chronicle.Contracts.ReadModels"] = new List<Type> { typeof(IReadModels) },
39+
["Cratis.Chronicle.Contracts.Recommendations"] = new List<Type> { typeof(IRecommendations) },
40+
["Cratis.Chronicle.Contracts.Security"] = new List<Type> { typeof(IApplications), typeof(IUsers) },
41+
["Cratis.Chronicle.Contracts.Seeding"] = new List<Type> { typeof(IEventSeeding) }
42+
};
43+
44+
var combinedSchema = new StringBuilder();
45+
combinedSchema.AppendLine("syntax = \"proto3\";");
46+
combinedSchema.AppendLine();
47+
48+
foreach (var kvp in serviceTypesByPackage)
49+
{
50+
var generator = new SchemaGenerator
51+
{
52+
ProtoSyntax = ProtoSyntax.Proto3
53+
};
54+
55+
try
56+
{
57+
var schema = generator.GetSchema(kvp.Value.ToArray());
58+
59+
// Remove the syntax line from individual schemas as we add it once at the top
60+
var lines = schema.Split('\n');
61+
foreach (var line in lines)
62+
{
63+
if (!line.StartsWith("syntax =") && !string.IsNullOrWhiteSpace(line))
64+
{
65+
combinedSchema.AppendLine(line);
66+
}
67+
}
68+
69+
combinedSchema.AppendLine();
70+
}
71+
catch (Exception ex)
72+
{
73+
Console.Error.WriteLine($"Error generating schema for package {kvp.Key}: {ex.Message}");
74+
}
75+
}
76+
77+
Console.WriteLine(combinedSchema.ToString());
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net10.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
<ProjectReference Include="./Source/Kernel/Contracts/Contracts.csproj" />
10+
<PackageReference Include="protobuf-net.Grpc.Reflection" Version="1.2.2" />
11+
</ItemGroup>
12+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<Project />

.grpc-schema-gen-aIbNZe/Program.cs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
using ProtoBuf.Grpc.Reflection;
2+
using ProtoBuf.Meta;
3+
using System.Text;
4+
using Cratis.Chronicle.Contracts;
5+
using Cratis.Chronicle.Contracts.Clients;
6+
using Cratis.Chronicle.Contracts.Events;
7+
using Cratis.Chronicle.Contracts.Events.Constraints;
8+
using Cratis.Chronicle.Contracts.EventSequences;
9+
using Cratis.Chronicle.Contracts.Host;
10+
using Cratis.Chronicle.Contracts.Identities;
11+
using Cratis.Chronicle.Contracts.Jobs;
12+
using Cratis.Chronicle.Contracts.Observation;
13+
using Cratis.Chronicle.Contracts.Observation.Reactors;
14+
using Cratis.Chronicle.Contracts.Observation.Reducers;
15+
using Cratis.Chronicle.Contracts.Observation.Webhooks;
16+
using Cratis.Chronicle.Contracts.Projections;
17+
using Cratis.Chronicle.Contracts.ReadModels;
18+
using Cratis.Chronicle.Contracts.Recommendations;
19+
using Cratis.Chronicle.Contracts.Security;
20+
using Cratis.Chronicle.Contracts.Seeding;
21+
22+
// Group service types by their namespace (package)
23+
var serviceTypesByPackage = new Dictionary<string, List<Type>>
24+
{
25+
["Cratis.Chronicle.Contracts"] = new List<Type> { typeof(IEventStores), typeof(INamespaces) },
26+
["Cratis.Chronicle.Contracts.Clients"] = new List<Type> { typeof(IConnectionService) },
27+
["Cratis.Chronicle.Contracts.Events"] = new List<Type> { typeof(IEventTypes) },
28+
["Cratis.Chronicle.Contracts.Events.Constraints"] = new List<Type> { typeof(IConstraints) },
29+
["Cratis.Chronicle.Contracts.EventSequences"] = new List<Type> { typeof(IEventSequences) },
30+
["Cratis.Chronicle.Contracts.Host"] = new List<Type> { typeof(IServer) },
31+
["Cratis.Chronicle.Contracts.Identities"] = new List<Type> { typeof(IIdentities) },
32+
["Cratis.Chronicle.Contracts.Jobs"] = new List<Type> { typeof(IJobs) },
33+
["Cratis.Chronicle.Contracts.Observation"] = new List<Type> { typeof(IObservers), typeof(IFailedPartitions) },
34+
["Cratis.Chronicle.Contracts.Observation.Reactors"] = new List<Type> { typeof(IReactors) },
35+
["Cratis.Chronicle.Contracts.Observation.Reducers"] = new List<Type> { typeof(IReducers) },
36+
["Cratis.Chronicle.Contracts.Observation.Webhooks"] = new List<Type> { typeof(IWebhooks) },
37+
["Cratis.Chronicle.Contracts.Projections"] = new List<Type> { typeof(IProjections) },
38+
["Cratis.Chronicle.Contracts.ReadModels"] = new List<Type> { typeof(IReadModels) },
39+
["Cratis.Chronicle.Contracts.Recommendations"] = new List<Type> { typeof(IRecommendations) },
40+
["Cratis.Chronicle.Contracts.Security"] = new List<Type> { typeof(IApplications), typeof(IUsers) },
41+
["Cratis.Chronicle.Contracts.Seeding"] = new List<Type> { typeof(IEventSeeding) }
42+
};
43+
44+
var combinedSchema = new StringBuilder();
45+
combinedSchema.AppendLine("syntax = \"proto3\";");
46+
combinedSchema.AppendLine();
47+
48+
foreach (var kvp in serviceTypesByPackage)
49+
{
50+
var generator = new SchemaGenerator
51+
{
52+
ProtoSyntax = ProtoSyntax.Proto3
53+
};
54+
55+
try
56+
{
57+
var schema = generator.GetSchema(kvp.Value.ToArray());
58+
59+
// Remove the syntax line from individual schemas as we add it once at the top
60+
var lines = schema.Split('\n');
61+
foreach (var line in lines)
62+
{
63+
if (!line.StartsWith("syntax =") && !string.IsNullOrWhiteSpace(line))
64+
{
65+
combinedSchema.AppendLine(line);
66+
}
67+
}
68+
69+
combinedSchema.AppendLine();
70+
}
71+
catch (Exception ex)
72+
{
73+
Console.Error.WriteLine($"Error generating schema for package {kvp.Key}: {ex.Message}");
74+
}
75+
}
76+
77+
Console.WriteLine(combinedSchema.ToString());
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net10.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
8+
</PropertyGroup>
9+
<ItemGroup>
10+
<ProjectReference Include="./Source/Kernel/Contracts/Contracts.csproj" />
11+
<PackageReference Include="protobuf-net.Grpc.Reflection" Version="1.2.2" />
12+
</ItemGroup>
13+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<Project />

0 commit comments

Comments
 (0)