Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
94 changes: 94 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build-test:
runs-on: ubuntu-latest
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL || 'https://sonarcloud.io' }}
SONAR_PROJECT_KEY: ${{ vars.SONAR_PROJECT_KEY }}
SONAR_ORGANIZATION: ${{ vars.SONAR_ORGANIZATION }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x

- name: Setup Java 17 (SonarScanner requirement)
if: env.SONAR_TOKEN != ''
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4
with:
distribution: temurin
java-version: '17'

- name: Install SonarScanner for .NET
if: env.SONAR_TOKEN != ''
run: dotnet tool install --global dotnet-sonarscanner

# Self-hosted SonarQube: set the SONAR_HOST_URL repo variable and REMOVE the /o: line below
# (organization is a SonarCloud-only concept).
- name: Begin SonarQube analysis
if: env.SONAR_TOKEN != ''
run: >
dotnet sonarscanner begin
/k:"$SONAR_PROJECT_KEY"
/o:"$SONAR_ORGANIZATION"
/d:sonar.token="$SONAR_TOKEN"
/d:sonar.host.url="$SONAR_HOST_URL"
/d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml"
/d:sonar.exclusions="benchmarks/**,samples/**"

- name: Restore
run: dotnet restore AspNet.Cache.sln

# The library enforces TreatWarningsAsErrors via its own csproj; not forcing it solution-wide
# here keeps SonarAnalyzer smells in the excluded sample/benchmark projects from breaking the
# analysis build. The strict -warnaserror gate runs in the allocation-gate job and locally.
- name: Build
run: dotnet build AspNet.Cache.sln -c Release --no-restore /p:TreatWarningsAsErrors=false

- name: Test with coverage
run: >
dotnet test test/AspNet.Cache.Test/AspNet.Cache.Test.csproj -c Release --no-build
/p:CollectCoverage=true
/p:CoverletOutputFormat=opencover
/p:Threshold=80
/p:ThresholdType=line
/p:Include="[AspNet.Cache]*"

- name: End SonarQube analysis
if: env.SONAR_TOKEN != ''
run: dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN"

allocation-gate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4

- name: Setup .NET
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x

- name: Run benchmarks (short job)
run: dotnet run -c Release --project benchmarks/AspNet.Cache.Benchmarks -- --filter "*CacheBenchmarks*" --job short --exporters json

- name: Enforce allocation budgets
shell: pwsh
run: ./build/check-allocation-budgets.ps1
75 changes: 0 additions & 75 deletions .github/workflows/dotnetcore.yml

This file was deleted.

64 changes: 64 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Release

on:
push:
tags: ['v*']

permissions:
id-token: write # NuGet Trusted Publishing (OIDC) — no API key secret needed
contents: write

jobs:
release:
runs-on: ubuntu-latest
environment: production # matches the NuGet Trusted Publishing policy's Environment claim
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x

- name: Extract version from tag
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV"

- name: Restore
run: dotnet restore AspNet.Cache.sln

- name: Build
run: dotnet build AspNet.Cache.sln -c Release --no-restore -warnaserror /p:Version=${{ env.VERSION }}

- name: Test
run: dotnet test test/AspNet.Cache.Test/AspNet.Cache.Test.csproj -c Release --no-build

- name: Pack
run: >
dotnet pack AspNet.Cache/AspNet.Cache.csproj -c Release --no-build -o out
/p:Version=${{ env.VERSION }}
/p:ContinuousIntegrationBuild=true

- name: NuGet login (Trusted Publishing)
id: nuget-login
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1
with:
user: slipalison

- name: Push to NuGet.org
env:
NUGET_API_KEY: ${{ steps.nuget-login.outputs.NUGET_API_KEY }}
run: >
dotnet nuget push "out/*.nupkg"
--api-key "$NUGET_API_KEY"
--source https://api.nuget.org/v3/index.json
--skip-duplicate

- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "$GITHUB_REF_NAME" out/*.nupkg out/*.snupkg --generate-notes
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,11 @@ __pycache__/
/test/Core.Winchester.Tests/coverage.json
/test/Core.Winchester.Tests/coverage.cobertura.xml
*.info

# BenchmarkDotNet
BenchmarkDotNet.Artifacts/
.claude
PLANO-MODERNIZACAO.md
# Coverage reports
coverage*.xml
*.opencover.xml
54 changes: 54 additions & 0 deletions AspNet.Cache.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,80 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{66320409-64EC-F7C5-3DEF-65E7510DAAD1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNet.Cache.Benchmarks", "benchmarks\AspNet.Cache.Benchmarks\AspNet.Cache.Benchmarks.csproj", "{9D6D47E3-980D-4BF9-A3FB-B589211B043B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{5D20AA90-6969-D8BD-9DCD-8634F4692FDA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNet.Cache.Sample", "samples\AspNet.Cache.Sample\AspNet.Cache.Sample.csproj", "{7CC1F4FC-EF38-4F8C-BD75-360F62B9DEC7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3390E21C-20D0-45F8-9AD1-4286FF67C598}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3390E21C-20D0-45F8-9AD1-4286FF67C598}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3390E21C-20D0-45F8-9AD1-4286FF67C598}.Debug|x64.ActiveCfg = Debug|Any CPU
{3390E21C-20D0-45F8-9AD1-4286FF67C598}.Debug|x64.Build.0 = Debug|Any CPU
{3390E21C-20D0-45F8-9AD1-4286FF67C598}.Debug|x86.ActiveCfg = Debug|Any CPU
{3390E21C-20D0-45F8-9AD1-4286FF67C598}.Debug|x86.Build.0 = Debug|Any CPU
{3390E21C-20D0-45F8-9AD1-4286FF67C598}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3390E21C-20D0-45F8-9AD1-4286FF67C598}.Release|Any CPU.Build.0 = Release|Any CPU
{3390E21C-20D0-45F8-9AD1-4286FF67C598}.Release|x64.ActiveCfg = Release|Any CPU
{3390E21C-20D0-45F8-9AD1-4286FF67C598}.Release|x64.Build.0 = Release|Any CPU
{3390E21C-20D0-45F8-9AD1-4286FF67C598}.Release|x86.ActiveCfg = Release|Any CPU
{3390E21C-20D0-45F8-9AD1-4286FF67C598}.Release|x86.Build.0 = Release|Any CPU
{8FEFACF5-56FA-47C7-973A-4C10EE0B1A1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8FEFACF5-56FA-47C7-973A-4C10EE0B1A1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8FEFACF5-56FA-47C7-973A-4C10EE0B1A1C}.Debug|x64.ActiveCfg = Debug|Any CPU
{8FEFACF5-56FA-47C7-973A-4C10EE0B1A1C}.Debug|x64.Build.0 = Debug|Any CPU
{8FEFACF5-56FA-47C7-973A-4C10EE0B1A1C}.Debug|x86.ActiveCfg = Debug|Any CPU
{8FEFACF5-56FA-47C7-973A-4C10EE0B1A1C}.Debug|x86.Build.0 = Debug|Any CPU
{8FEFACF5-56FA-47C7-973A-4C10EE0B1A1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8FEFACF5-56FA-47C7-973A-4C10EE0B1A1C}.Release|Any CPU.Build.0 = Release|Any CPU
{8FEFACF5-56FA-47C7-973A-4C10EE0B1A1C}.Release|x64.ActiveCfg = Release|Any CPU
{8FEFACF5-56FA-47C7-973A-4C10EE0B1A1C}.Release|x64.Build.0 = Release|Any CPU
{8FEFACF5-56FA-47C7-973A-4C10EE0B1A1C}.Release|x86.ActiveCfg = Release|Any CPU
{8FEFACF5-56FA-47C7-973A-4C10EE0B1A1C}.Release|x86.Build.0 = Release|Any CPU
{9D6D47E3-980D-4BF9-A3FB-B589211B043B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9D6D47E3-980D-4BF9-A3FB-B589211B043B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9D6D47E3-980D-4BF9-A3FB-B589211B043B}.Debug|x64.ActiveCfg = Debug|Any CPU
{9D6D47E3-980D-4BF9-A3FB-B589211B043B}.Debug|x64.Build.0 = Debug|Any CPU
{9D6D47E3-980D-4BF9-A3FB-B589211B043B}.Debug|x86.ActiveCfg = Debug|Any CPU
{9D6D47E3-980D-4BF9-A3FB-B589211B043B}.Debug|x86.Build.0 = Debug|Any CPU
{9D6D47E3-980D-4BF9-A3FB-B589211B043B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9D6D47E3-980D-4BF9-A3FB-B589211B043B}.Release|Any CPU.Build.0 = Release|Any CPU
{9D6D47E3-980D-4BF9-A3FB-B589211B043B}.Release|x64.ActiveCfg = Release|Any CPU
{9D6D47E3-980D-4BF9-A3FB-B589211B043B}.Release|x64.Build.0 = Release|Any CPU
{9D6D47E3-980D-4BF9-A3FB-B589211B043B}.Release|x86.ActiveCfg = Release|Any CPU
{9D6D47E3-980D-4BF9-A3FB-B589211B043B}.Release|x86.Build.0 = Release|Any CPU
{7CC1F4FC-EF38-4F8C-BD75-360F62B9DEC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7CC1F4FC-EF38-4F8C-BD75-360F62B9DEC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7CC1F4FC-EF38-4F8C-BD75-360F62B9DEC7}.Debug|x64.ActiveCfg = Debug|Any CPU
{7CC1F4FC-EF38-4F8C-BD75-360F62B9DEC7}.Debug|x64.Build.0 = Debug|Any CPU
{7CC1F4FC-EF38-4F8C-BD75-360F62B9DEC7}.Debug|x86.ActiveCfg = Debug|Any CPU
{7CC1F4FC-EF38-4F8C-BD75-360F62B9DEC7}.Debug|x86.Build.0 = Debug|Any CPU
{7CC1F4FC-EF38-4F8C-BD75-360F62B9DEC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7CC1F4FC-EF38-4F8C-BD75-360F62B9DEC7}.Release|Any CPU.Build.0 = Release|Any CPU
{7CC1F4FC-EF38-4F8C-BD75-360F62B9DEC7}.Release|x64.ActiveCfg = Release|Any CPU
{7CC1F4FC-EF38-4F8C-BD75-360F62B9DEC7}.Release|x64.Build.0 = Release|Any CPU
{7CC1F4FC-EF38-4F8C-BD75-360F62B9DEC7}.Release|x86.ActiveCfg = Release|Any CPU
{7CC1F4FC-EF38-4F8C-BD75-360F62B9DEC7}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{8FEFACF5-56FA-47C7-973A-4C10EE0B1A1C} = {2ACD33BC-B50B-4296-879C-0660E72B18CF}
{9D6D47E3-980D-4BF9-A3FB-B589211B043B} = {66320409-64EC-F7C5-3DEF-65E7510DAAD1}
{7CC1F4FC-EF38-4F8C-BD75-360F62B9DEC7} = {5D20AA90-6969-D8BD-9DCD-8634F4692FDA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E47ABF9E-13CB-4CD1-B06B-3C7E9A86CD60}
Expand Down
48 changes: 39 additions & 9 deletions AspNet.Cache/AspNet.Cache.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,47 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AnalysisLevel>latest-recommended</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup>
<PackageId>AspNet.Cache</PackageId>
<Version>2.0.0</Version>
<Authors>slipalison</Authors>
<Description>Declarative response caching for ASP.NET Core MVC actions on top of any IDistributedCache provider (Redis, SQL Server, in-memory, MongoDB). Allocation-conscious: span-based key generation, pooled buffers, IBufferDistributedCache fast path, LOH-free by default.</Description>
<PackageTags>aspnetcore;cache;caching;idistributedcache;redis;actionfilter;performance;response-cache</PackageTags>
<PackageProjectUrl>https://github.com/slipalison/AspNet.Cache</PackageProjectUrl>
<RepositoryUrl>https://github.com/slipalison/AspNet.Cache</RepositoryUrl>
<Version>1.0.0</Version>
<Authors>slipalison</Authors>
<RepositoryType>git</RepositoryType>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="3.1.3" />
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
</Project>

<!-- net8's shared framework predates IBufferDistributedCache; pull it from the 9.0 package.
On net9.0/net10.0 the type ships in the shared framework, so no package reference is needed. -->
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="9.0.*" />
</ItemGroup>

<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\" />
<InternalsVisibleTo Include="AspNet.Cache.Test" />
<InternalsVisibleTo Include="AspNet.Cache.Benchmarks" />
</ItemGroup>

</Project>
Loading
Loading