-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/optional redis #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| name: PR Check | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [develop, master] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| dotnet-build: | ||
| name: .NET Build | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: '10.0.x' | ||
|
|
||
| - name: Restore dependencies | ||
| run: dotnet restore | ||
|
|
||
| - name: Build | ||
| run: dotnet build --configuration Release --no-restore | ||
|
|
||
| dotnet-test: | ||
| name: .NET Test | ||
| runs-on: ubuntu-latest | ||
| needs: dotnet-build | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: '10.0.x' | ||
|
|
||
| - name: Restore dependencies | ||
| run: dotnet restore | ||
|
|
||
| - name: Build | ||
| run: dotnet build --configuration Release --no-restore | ||
|
|
||
| - name: Test | ||
| run: dotnet test OpenLibraryRent.Tests --configuration Release --no-build --verbosity normal | ||
|
|
||
| npm-build: | ||
| name: npm Build | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| cache: 'npm' | ||
| cache-dependency-path: OpenLibraryRent/OpenLibraryRent.Client/package-lock.json | ||
|
|
||
| - name: Install dependencies | ||
| working-directory: OpenLibraryRent/OpenLibraryRent.Client | ||
| run: npm ci | ||
|
|
||
| - name: Build | ||
| working-directory: OpenLibraryRent/OpenLibraryRent.Client | ||
| run: npm run build | ||
|
|
||
| npm-check: | ||
| name: npm Check | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| cache: 'npm' | ||
| cache-dependency-path: OpenLibraryRent/OpenLibraryRent.Client/package-lock.json | ||
|
|
||
| - name: Install dependencies | ||
| working-directory: OpenLibraryRent/OpenLibraryRent.Client | ||
| run: npm ci | ||
|
|
||
| - name: Svelte Check | ||
| working-directory: OpenLibraryRent/OpenLibraryRent.Client | ||
| run: npm run check | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| branches: [master] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The release job is configured to run only on pushes to Useful? React with 👍 / 👎. |
||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| build-and-release: | ||
| name: Build and Release | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: '10.0.x' | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| cache: 'npm' | ||
| cache-dependency-path: OpenLibraryRent/OpenLibraryRent.Client/package-lock.json | ||
|
|
||
| - name: Install npm dependencies | ||
| working-directory: OpenLibraryRent/OpenLibraryRent.Client | ||
| run: npm ci | ||
|
|
||
| - name: Build frontend | ||
| working-directory: OpenLibraryRent/OpenLibraryRent.Client | ||
| run: npm run build | ||
|
|
||
| - name: Restore .NET dependencies | ||
| run: dotnet restore | ||
|
|
||
| - name: Build .NET | ||
| run: dotnet build --configuration Release --no-restore | ||
|
|
||
| - name: Publish | ||
| run: dotnet publish OpenLibraryRent/OpenLibraryRent.csproj --configuration Release --no-build --output ./publish | ||
|
|
||
| - name: Create version tag | ||
| id: version | ||
| run: | | ||
| VERSION=$(date +'%Y.%m.%d')-${{ github.run_number }} | ||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
| echo "Version: $VERSION" | ||
|
|
||
| - name: Create ZIP archive | ||
| run: | | ||
| cd publish | ||
| zip -r ../OpenLibraryRent-${{ steps.version.outputs.version }}.zip . | ||
| cd .. | ||
|
|
||
| - name: Create Release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| tag_name: v${{ steps.version.outputs.version }} | ||
| name: Release v${{ steps.version.outputs.version }} | ||
| body: | | ||
| ## OpenLibraryRent Release v${{ steps.version.outputs.version }} | ||
|
|
||
| **Changes:** | ||
| ${{ github.event.head_commit.message }} | ||
|
|
||
| **Commit:** ${{ github.sha }} | ||
| files: | | ||
| OpenLibraryRent-${{ steps.version.outputs.version }}.zip | ||
| draft: false | ||
| prerelease: false | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net10.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| <IsPackable>false</IsPackable> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="coverlet.collector" Version="6.0.4" /> | ||
| <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="10.0.0-*" /> | ||
| <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" /> | ||
| <PackageReference Include="Moq" Version="4.20.72" /> | ||
| <PackageReference Include="xunit" Version="2.9.3" /> | ||
| <PackageReference Include="xunit.runner.visualstudio" Version="3.1.4" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\OpenLibraryRent\OpenLibraryRent.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Using Include="Xunit" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| using OpenLibraryRent.Services.Caching; | ||
| using Xunit; | ||
|
|
||
| namespace OpenLibraryRent.Tests.Services.Caching; | ||
|
|
||
| public class CacheKeysTests | ||
| { | ||
| [Fact] | ||
| public void TenantInfo_Returns_Correct_Format() | ||
| { | ||
| // Arrange | ||
| var tenantId = "tenant-123"; | ||
|
|
||
| // Act | ||
| var key = CacheKeys.TenantInfo(tenantId); | ||
|
|
||
| // Assert | ||
| Assert.Equal("OpenLibraryRent:tenant:tenant-123:info", key); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void TenantSettings_Returns_Correct_Format() | ||
| { | ||
| // Arrange | ||
| var tenantId = "tenant-456"; | ||
|
|
||
| // Act | ||
| var key = CacheKeys.TenantSettings(tenantId); | ||
|
|
||
| // Assert | ||
| Assert.Equal("OpenLibraryRent:tenant:tenant-456:settings", key); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void BookByIsbn_Returns_Correct_Format() | ||
| { | ||
| // Arrange | ||
| var isbn = "978-4-123456-78-9"; | ||
|
|
||
| // Act | ||
| var key = CacheKeys.BookByIsbn(isbn); | ||
|
|
||
| // Assert | ||
| Assert.Equal("OpenLibraryRent:book:isbn:978-4-123456-78-9", key); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void UserPermissions_Returns_Correct_Format() | ||
| { | ||
| // Arrange | ||
| var tenantId = "tenant-123"; | ||
| var userId = "user-456"; | ||
|
|
||
| // Act | ||
| var key = CacheKeys.UserPermissions(tenantId, userId); | ||
|
|
||
| // Assert | ||
| Assert.Equal("OpenLibraryRent:tenant:tenant-123:user:user-456:permissions", key); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void TenantAll_Returns_Correct_Pattern_Format() | ||
| { | ||
| // Arrange | ||
| var tenantId = "tenant-123"; | ||
|
|
||
| // Act | ||
| var pattern = CacheKeys.TenantAll(tenantId); | ||
|
|
||
| // Assert | ||
| Assert.Equal("OpenLibraryRent:tenant:tenant-123:*", pattern); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData("tenant-1")] | ||
| [InlineData("abc123")] | ||
| [InlineData("test-tenant-id")] | ||
| public void TenantInfo_Consistent_For_Same_TenantId(string tenantId) | ||
| { | ||
| // Act | ||
| var key1 = CacheKeys.TenantInfo(tenantId); | ||
| var key2 = CacheKeys.TenantInfo(tenantId); | ||
|
|
||
| // Assert | ||
| Assert.Equal(key1, key2); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void CacheKeys_Are_Deterministic() | ||
| { | ||
| // Arrange | ||
| var tenantId = "test"; | ||
| var isbn = "1234567890"; | ||
| var userId = "user1"; | ||
|
|
||
| // Act - Call multiple times | ||
| var tenantKey1 = CacheKeys.TenantInfo(tenantId); | ||
| var tenantKey2 = CacheKeys.TenantInfo(tenantId); | ||
| var bookKey1 = CacheKeys.BookByIsbn(isbn); | ||
| var bookKey2 = CacheKeys.BookByIsbn(isbn); | ||
| var permKey1 = CacheKeys.UserPermissions(tenantId, userId); | ||
| var permKey2 = CacheKeys.UserPermissions(tenantId, userId); | ||
|
|
||
| // Assert - Same inputs produce same keys | ||
| Assert.Equal(tenantKey1, tenantKey2); | ||
| Assert.Equal(bookKey1, bookKey2); | ||
| Assert.Equal(permKey1, permKey2); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Different_Inputs_Produce_Different_Keys() | ||
| { | ||
| // Arrange & Act | ||
| var key1 = CacheKeys.TenantInfo("tenant-1"); | ||
| var key2 = CacheKeys.TenantInfo("tenant-2"); | ||
|
|
||
| // Assert | ||
| Assert.NotEqual(key1, key2); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workflow only runs for PRs targeting
developormaster, so pull requests intomainwill skip all CI checks from this file. In repositories wheremainis the active integration branch, this silently removes build/test coverage on incoming changes and lets regressions merge without the intended gate.Useful? React with 👍 / 👎.