Skip to content

Commit b7397f0

Browse files
committed
big refactring + tests
1 parent 039ec2f commit b7397f0

40 files changed

+3180
-981
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
push:
7+
branches: [ main ]
8+
9+
env:
10+
DOTNET_VERSION: '9.0.x'
11+
12+
jobs:
13+
build:
14+
name: Build and Test
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v5
20+
21+
- name: Setup .NET
22+
uses: actions/setup-dotnet@v4
23+
with:
24+
dotnet-version: ${{ env.DOTNET_VERSION }}
25+
26+
- name: Restore dependencies
27+
run: dotnet restore ManagedCode.Orleans.SignalR.sln
28+
29+
- name: Build
30+
run: dotnet build ManagedCode.Orleans.SignalR.sln --configuration Release --no-restore
31+
32+
- name: Test
33+
run: dotnet test ManagedCode.Orleans.SignalR.Tests/ManagedCode.Orleans.SignalR.Tests.csproj --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage"
34+
35+
- name: Upload coverage reports to Codecov
36+
uses: codecov/codecov-action@v5
37+
with:
38+
token: ${{ secrets.CODECOV_TOKEN }}
39+
files: ./**/coverage.cobertura.xml
40+
fail_ci_if_error: false

.github/workflows/dotnet.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/nuget.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
env:
9+
DOTNET_VERSION: '9.0.x'
10+
11+
jobs:
12+
build:
13+
name: Build and Test
14+
runs-on: ubuntu-latest
15+
16+
outputs:
17+
version: ${{ steps.version.outputs.version }}
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v5
22+
23+
- name: Setup .NET
24+
uses: actions/setup-dotnet@v4
25+
with:
26+
dotnet-version: ${{ env.DOTNET_VERSION }}
27+
28+
- name: Extract version from Directory.Build.props
29+
id: version
30+
run: |
31+
VERSION=$(grep -oPm1 "(?<=<Version>)[^<]+" Directory.Build.props)
32+
echo "version=$VERSION" >> $GITHUB_OUTPUT
33+
echo "Version from Directory.Build.props: $VERSION"
34+
35+
- name: Restore dependencies
36+
run: dotnet restore ManagedCode.Orleans.SignalR.sln
37+
38+
- name: Build
39+
run: dotnet build ManagedCode.Orleans.SignalR.sln --configuration Release --no-restore
40+
41+
- name: Test
42+
run: dotnet test ManagedCode.Orleans.SignalR.Tests/ManagedCode.Orleans.SignalR.Tests.csproj --configuration Release --no-build --verbosity normal
43+
44+
- name: Pack NuGet packages
45+
run: dotnet pack ManagedCode.Orleans.SignalR.sln --configuration Release --no-build -p:IncludeSymbols=false -p:SymbolPackageFormat=snupkg --output ./artifacts
46+
47+
- name: Upload artifacts
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: nuget-packages
51+
path: ./artifacts/*.nupkg
52+
retention-days: 5
53+
54+
publish-nuget:
55+
name: Publish to NuGet
56+
needs: build
57+
runs-on: ubuntu-latest
58+
if: github.ref == 'refs/heads/main'
59+
60+
outputs:
61+
published: ${{ steps.publish.outputs.published }}
62+
version: ${{ needs.build.outputs.version }}
63+
64+
steps:
65+
- name: Checkout
66+
uses: actions/checkout@v5
67+
68+
- name: Download artifacts
69+
uses: actions/download-artifact@v5
70+
with:
71+
name: nuget-packages
72+
path: ./artifacts
73+
74+
- name: Setup .NET
75+
uses: actions/setup-dotnet@v4
76+
with:
77+
dotnet-version: ${{ env.DOTNET_VERSION }}
78+
79+
- name: Publish to NuGet
80+
id: publish
81+
continue-on-error: true
82+
run: |
83+
set +e
84+
OUTPUT=""
85+
PUBLISHED=false
86+
87+
for package in ./artifacts/*.nupkg; do
88+
echo "Publishing $package..."
89+
RESULT=$(dotnet nuget push "$package" \
90+
--api-key ${{ secrets.NUGET_API_KEY }} \
91+
--source https://api.nuget.org/v3/index.json \
92+
--skip-duplicate 2>&1)
93+
EXIT_CODE=$?
94+
echo "$RESULT"
95+
OUTPUT="$OUTPUT$RESULT"
96+
97+
if [ $EXIT_CODE -eq 0 ]; then
98+
echo "Successfully published $package"
99+
PUBLISHED=true
100+
elif echo "$RESULT" | grep -q "already exists"; then
101+
echo "Package already exists, skipping..."
102+
else
103+
echo "Failed to publish $package"
104+
exit 1
105+
fi
106+
done
107+
108+
if [ "$PUBLISHED" = true ] || echo "$OUTPUT" | grep -q "Your package was pushed"; then
109+
echo "published=true" >> $GITHUB_OUTPUT
110+
echo "At least one package was successfully published"
111+
else
112+
echo "published=false" >> $GITHUB_OUTPUT
113+
echo "No new packages were published (all already exist)"
114+
fi
115+
116+
create-release:
117+
name: Create GitHub Release and Tag
118+
needs: publish-nuget
119+
runs-on: ubuntu-latest
120+
if: needs.publish-nuget.outputs.published == 'true'
121+
permissions:
122+
contents: write
123+
124+
steps:
125+
- name: Checkout
126+
uses: actions/checkout@v5
127+
with:
128+
fetch-depth: 0
129+
token: ${{ secrets.GITHUB_TOKEN }}
130+
131+
- name: Download artifacts
132+
uses: actions/download-artifact@v5
133+
with:
134+
name: nuget-packages
135+
path: ./artifacts
136+
137+
- name: Create and push tag
138+
id: create_tag
139+
run: |
140+
VERSION="${{ needs.publish-nuget.outputs.version }}"
141+
TAG="v$VERSION"
142+
143+
git config user.name "github-actions[bot]"
144+
git config user.email "github-actions[bot]@users.noreply.github.com"
145+
146+
if git rev-parse "$TAG" >/dev/null 2>&1; then
147+
echo "Tag $TAG already exists"
148+
echo "tag_exists=true" >> $GITHUB_OUTPUT
149+
else
150+
echo "Creating tag $TAG"
151+
git tag -a "$TAG" -m "Release $VERSION"
152+
git push origin "$TAG"
153+
echo "tag_exists=false" >> $GITHUB_OUTPUT
154+
fi
155+
156+
- name: Get previous tag
157+
id: prev_tag
158+
run: |
159+
CURRENT_TAG="v${{ needs.publish-nuget.outputs.version }}"
160+
PREVIOUS_TAG=$(git tag --sort=-version:refname | grep -A1 "^$CURRENT_TAG$" | tail -n1 || echo "")
161+
if [ "$PREVIOUS_TAG" = "$CURRENT_TAG" ] || [ -z "$PREVIOUS_TAG" ]; then
162+
PREVIOUS_TAG=$(git tag --sort=-version:refname | grep -v "^$CURRENT_TAG$" | head -n1 || echo "")
163+
fi
164+
echo "previous_tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT
165+
echo "Current tag: $CURRENT_TAG"
166+
echo "Previous tag: $PREVIOUS_TAG"
167+
168+
- name: Generate release notes
169+
id: release_notes
170+
run: |
171+
VERSION="${{ needs.publish-nuget.outputs.version }}"
172+
CURRENT_TAG="v$VERSION"
173+
PREVIOUS_TAG="${{ steps.prev_tag.outputs.previous_tag }}"
174+
175+
echo "# Release $VERSION" > release_notes.md
176+
echo "" >> release_notes.md
177+
echo "Released on $(date +'%Y-%m-%d')" >> release_notes.md
178+
echo "" >> release_notes.md
179+
180+
if [ -n "$PREVIOUS_TAG" ]; then
181+
echo "## 📋 Changes since $PREVIOUS_TAG" >> release_notes.md
182+
echo "" >> release_notes.md
183+
184+
echo "### ✨ Features" >> release_notes.md
185+
git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD --grep="^feat" --grep="^feature" >> release_notes.md || true
186+
echo "" >> release_notes.md
187+
188+
echo "### 🐛 Bug Fixes" >> release_notes.md
189+
git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD --grep="^fix" --grep="^bugfix" >> release_notes.md || true
190+
echo "" >> release_notes.md
191+
192+
echo "### 📚 Documentation" >> release_notes.md
193+
git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD --grep="^docs" --grep="^doc" >> release_notes.md || true
194+
echo "" >> release_notes.md
195+
196+
echo "### 🔧 Other Changes" >> release_notes.md
197+
git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD --invert-grep --grep="^feat" --grep="^feature" --grep="^fix" --grep="^bugfix" --grep="^docs" --grep="^doc" >> release_notes.md || true
198+
echo "" >> release_notes.md
199+
else
200+
echo "## 🎉 Initial Release" >> release_notes.md
201+
echo "" >> release_notes.md
202+
echo "### Recent Changes" >> release_notes.md
203+
git log --pretty=format:"- %s (%h)" --max-count=20 >> release_notes.md
204+
echo "" >> release_notes.md
205+
fi
206+
207+
echo "" >> release_notes.md
208+
echo "## 📦 NuGet Packages" >> release_notes.md
209+
echo "" >> release_notes.md
210+
for package in ./artifacts/*.nupkg; do
211+
PACKAGE_NAME=$(basename "$package" .nupkg)
212+
BASE_NAME=$(echo "$PACKAGE_NAME" | sed "s/\.$VERSION//")
213+
echo "- [$BASE_NAME v$VERSION](https://www.nuget.org/packages/$BASE_NAME/$VERSION)" >> release_notes.md
214+
done
215+
216+
echo "" >> release_notes.md
217+
echo "---" >> release_notes.md
218+
echo "*This release was automatically created by GitHub Actions*" >> release_notes.md
219+
220+
- name: Create GitHub Release
221+
uses: softprops/action-gh-release@v2
222+
with:
223+
tag_name: v${{ needs.publish-nuget.outputs.version }}
224+
name: v${{ needs.publish-nuget.outputs.version }}
225+
body_path: release_notes.md
226+
draft: false
227+
prerelease: false
228+
files: ./artifacts/*.nupkg
229+
token: ${{ secrets.GITHUB_TOKEN }}

AGENTS.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Repository Guidelines
2+
3+
This repo provides an Orleans-backed SignalR backplane. Use the conventions below to keep contributions consistent and easy to review.
4+
5+
## Project Structure & Module Organization
6+
- `ManagedCode.Orleans.SignalR.Core` — core types, options, and helpers shared by all modules.
7+
- `ManagedCode.Orleans.SignalR.Client` — client integration extensions.
8+
- `ManagedCode.Orleans.SignalR.Server` — Orleans grains and server-side plumbing.
9+
- `ManagedCode.Orleans.SignalR.Tests` — xUnit tests and a minimal test host under `TestApp/`.
10+
- `ManagedCode.Orleans.SignalR.slnx` and `Directory.Build.props` — solution and central build settings (net9.0, C# 13, analyzers, nullable).
11+
12+
## Build, Test, and Development Commands
13+
- Restore/build: `dotnet restore``dotnet build -c Debug`
14+
- Run tests: `dotnet test -c Debug` (xUnit; Coverlet collector is enabled for coverage)
15+
- Filter tests: `dotnet test --filter "FullyQualifiedName~PartitioningTests"`
16+
- Pack NuGet: `dotnet pack -c Release`
17+
- Format: `dotnet format` (run before committing)
18+
19+
## Coding Style & Naming Conventions
20+
- C#: 4‑space indent; file‑scoped namespaces; `Nullable` enabled; `EnableNETAnalyzers=true`.
21+
- Naming: PascalCase for types/members; camelCase for locals/parameters; interfaces prefixed `I`.
22+
- Domain naming: Orleans grain classes end with `Grain` (e.g., `SignalRGroupGrain`); namespaces start with `ManagedCode.Orleans.SignalR.*`.
23+
- Prefer explicit access modifiers, `readonly` where applicable, and expression‑bodied members when clearer.
24+
25+
## Testing Guidelines
26+
- Framework: xUnit with `[Fact]`/`[Theory]`. Tests live in `ManagedCode.Orleans.SignalR.Tests` and end with `*Tests.cs`.
27+
- Cluster tests: use Orleans TestingHost utilities; keep tests deterministic and isolated.
28+
- Coverage: keep or increase coverage on core logic. Example: `dotnet test -c Debug --collect:"XPlat Code Coverage"`.
29+
30+
## Commit & Pull Request Guidelines
31+
- Commits: short, imperative subject lines. History shows concise tags like “fix”, “tests”, “refactoring” — keep using them.
32+
- Examples: `fix: avoid deadlock in invocation`, `tests: improve group partitioning suite`.
33+
- PRs: include a clear description, linked issues, rationale, and how you tested. Add/adjust tests with behavior changes and update README if public APIs change.
34+
- CI hygiene: run `dotnet build` and `dotnet test` locally and ensure `dotnet format` yields no diffs before opening a PR.
35+
36+
## Security & Configuration Tips
37+
- Do not commit secrets or connection strings. Tests should use the provided in‑memory/TestHost setup.
38+
- Configuration lives in code and `Directory.Build.props`; discuss before introducing new external dependencies.
39+

0 commit comments

Comments
 (0)