Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 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
14 changes: 12 additions & 2 deletions .github/actions/cosmosdb-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@ description: "Setup Cosmos DB Emulator environment"
runs:
using: "composite"
steps:
- name: Check for Docker Installation
shell: bash
run: |
if ! command -v docker &> /dev/null; then
echo "Docker could not be found. Install Docker before running this action."
exit 1
fi

- name: Pull and Run Cosmos DB Emulator
shell: bash
run: |
set -e
docker pull mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest
docker run \
--rm \
--publish 8081:8081 \
--name cosmosdb-linux-emulator \
--detach \
Expand All @@ -18,7 +28,7 @@ runs:
shell: bash
run: |
echo "Waiting for Cosmos DB Emulator to start... (it may require a few minutes)"
while ! curl --insecure https://localhost:8081/_explorer/emulator.pem >/dev/null 2>&1; do
until curl --insecure https://localhost:8081/_explorer/emulator.pem >/dev/null 2>&1; do
sleep 5
done

Expand All @@ -33,4 +43,4 @@ runs:
run: |
sudo cp ~/emulatorcert.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates
echo "Certificate updated. Cosmos DB Emulator configured successfully!"
echo "Certificate updated. Cosmos DB Emulator configured successfully!"
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
dotnet-version: |
6.0.x
8.0.x
9.0.x

- name: Run build
shell: pwsh
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pack&push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
dotnet-version: |
6.0.x
8.0.x
9.0.x

- name: Pack & Push to NuGet
shell: pwsh
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
test_type: [
testType: [
{ name: "Abstractions", condition: "abstractions_changed" },
{ name: "CosmosDB", condition: "cosmosdb_changed" },
{ name: "Dapper", condition: "dapper_changed" },
Expand All @@ -87,12 +87,13 @@ jobs:
dotnet-version: |
6.0.x
8.0.x
9.0.x

- name: Start CosmosDB Emulator
if: matrix.test_type.name == 'CosmosDB' && needs.checks_tests_need.outputs.cosmosdb_changed == 'true'
if: matrix.testType.name == 'CosmosDB' && needs.checks_tests_need.outputs.cosmosdb_changed == 'true'
uses: ./.github/actions/cosmosdb-setup

- name: Run ${{ matrix.test_type.name }} tests
if: needs.checks_tests_need.outputs[matrix.test_type.condition] == 'true'
- name: Run ${{ matrix.testType.name }} tests
if: needs.checks_tests_need.outputs[matrix.testType.condition] == 'true'
shell: pwsh
run: ./test.ps1 -Configuration ${{ env.CONFIGURATION }} -TestType ${{ matrix.test_type.name }}
run: ./test.ps1 -Configuration ${{ env.CONFIGURATION }} -TestType ${{ matrix.testType.name }}
61 changes: 29 additions & 32 deletions FeatureManagement.Database.slnx
Original file line number Diff line number Diff line change
@@ -1,45 +1,42 @@
<Solution>
<Folder Name="/build/">
<File Path="build\Common.props" />
<File Path="build\icon.png" />
<File Path="build\NuGet.props" />
<File Path="build\Versioning.props" />
<File Path="build/Common.props" />
<File Path="build/icon.png" />
<File Path="build/NuGet.props" />
<File Path="build/Versioning.props" />
</Folder>
<Folder Name="/config/">
<File Path=".editorconfig" />
</Folder>
<Folder Name="/samples/">
<Project Path="samples\ConsoleApp\ConsoleApp.csproj" />
<Project Path="samples\WebApiApp\WebApiApp.csproj" />
<Project Path="samples/ConsoleApp/ConsoleApp.csproj" />
<Project Path="samples/WebApiApp/WebApiApp.csproj" />
</Folder>
<Folder Name="/src/">
<File Path="src\Directory.Packages.props" />
<Project Path="src\FeatureManagement.Database.Abstractions\FeatureManagement.Database.Abstractions.csproj" />
<Project Path="src\FeatureManagement.Database.CosmosDB\FeatureManagement.Database.CosmosDB.csproj" />
<Project Path="src\FeatureManagement.Database.Dapper\FeatureManagement.Database.Dapper.csproj" />
<Project Path="src\FeatureManagement.Database.EntityFrameworkCore.MySql\FeatureManagement.Database.EntityFrameworkCore.MySql.csproj" />
<Project Path="src\FeatureManagement.Database.EntityFrameworkCore.PostgreSQL\FeatureManagement.Database.EntityFrameworkCore.PostgreSQL.csproj" />
<Project Path="src\FeatureManagement.Database.EntityFrameworkCore.Sqlite\FeatureManagement.Database.EntityFrameworkCore.Sqlite.csproj" />
<Project Path="src\FeatureManagement.Database.EntityFrameworkCore.SqlServer\FeatureManagement.Database.EntityFrameworkCore.SqlServer.csproj" />
<Project Path="src\FeatureManagement.Database.EntityFrameworkCore\FeatureManagement.Database.EntityFrameworkCore.csproj" />
<Project Path="src\FeatureManagement.Database.MongoDB\FeatureManagement.Database.MongoDB.csproj" />
<Project Path="src\FeatureManagement.Database.NHibernate\FeatureManagement.Database.NHibernate.csproj" />
<File Path="src/Directory.Packages.props" />
<Project Path="src/FeatureManagement.Database.Abstractions/FeatureManagement.Database.Abstractions.csproj" />
<Project Path="src/FeatureManagement.Database.CosmosDB/FeatureManagement.Database.CosmosDB.csproj" />
<Project Path="src/FeatureManagement.Database.Dapper/FeatureManagement.Database.Dapper.csproj" />
<Project Path="src/FeatureManagement.Database.EntityFrameworkCore.MySql/FeatureManagement.Database.EntityFrameworkCore.MySql.csproj" />
<Project Path="src/FeatureManagement.Database.EntityFrameworkCore.PostgreSQL/FeatureManagement.Database.EntityFrameworkCore.PostgreSQL.csproj" />
<Project Path="src/FeatureManagement.Database.EntityFrameworkCore.Sqlite/FeatureManagement.Database.EntityFrameworkCore.Sqlite.csproj" />
<Project Path="src/FeatureManagement.Database.EntityFrameworkCore.SqlServer/FeatureManagement.Database.EntityFrameworkCore.SqlServer.csproj" />
<Project Path="src/FeatureManagement.Database.EntityFrameworkCore/FeatureManagement.Database.EntityFrameworkCore.csproj" />
<Project Path="src/FeatureManagement.Database.MongoDB/FeatureManagement.Database.MongoDB.csproj" />
<Project Path="src/FeatureManagement.Database.NHibernate/FeatureManagement.Database.NHibernate.csproj" />
</Folder>
<Folder Name="/tests/">
<File Path="tests\Directory.Build.props" />
<File Path="tests\Directory.Packages.props" />
<Project Path="tests\FeatureManagement.Database.CosmosDB.Tests\FeatureManagement.Database.CosmosDB.Tests.csproj" />
<Project Path="tests\FeatureManagement.Database.Dapper.Tests\FeatureManagement.Database.Dapper.Tests.csproj" />
<Project Path="tests\FeatureManagement.Database.EntityFrameworkCore.MySql.Tests\FeatureManagement.Database.EntityFrameworkCore.MySql.Tests.csproj" />
<Project Path="tests\FeatureManagement.Database.EntityFrameworkCore.PostgreSQL.Tests\FeatureManagement.Database.EntityFrameworkCore.PostgreSQL.Tests.csproj" />
<Project Path="tests\FeatureManagement.Database.EntityFrameworkCore.Sqlite.Tests\FeatureManagement.Database.EntityFrameworkCore.Sqlite.Tests.csproj" />
<Project Path="tests\FeatureManagement.Database.EntityFrameworkCore.SqlServer.Tests\FeatureManagement.Database.EntityFrameworkCore.SqlServer.Tests.csproj" />
<Project Path="tests\FeatureManagement.Database.EntityFrameworkCore.Tests\FeatureManagement.Database.EntityFrameworkCore.Tests.csproj" />
<Project Path="tests\FeatureManagement.Database.MongoDB.Tests\FeatureManagement.Database.MongoDB.Tests.csproj" />
<Project Path="tests\FeatureManagement.Database.NHibernate.Tests\FeatureManagement.Database.NHibernate.Tests.csproj" />
<Project Path="tests\FeatureManagement.Database.Abstractions.Tests\FeatureManagement.Database.Abstractions.Tests.csproj" />
<File Path="tests/Directory.Build.props" />
<File Path="tests/Directory.Packages.props" />
<Project Path="tests/FeatureManagement.Database.Abstractions.Tests/FeatureManagement.Database.Abstractions.Tests.csproj" />
<Project Path="tests/FeatureManagement.Database.CosmosDB.Tests/FeatureManagement.Database.CosmosDB.Tests.csproj" />
<Project Path="tests/FeatureManagement.Database.Dapper.Tests/FeatureManagement.Database.Dapper.Tests.csproj" />
<Project Path="tests/FeatureManagement.Database.EntityFrameworkCore.MySql.Tests/FeatureManagement.Database.EntityFrameworkCore.MySql.Tests.csproj" />
<Project Path="tests/FeatureManagement.Database.EntityFrameworkCore.PostgreSQL.Tests/FeatureManagement.Database.EntityFrameworkCore.PostgreSQL.Tests.csproj" />
<Project Path="tests/FeatureManagement.Database.EntityFrameworkCore.Sqlite.Tests/FeatureManagement.Database.EntityFrameworkCore.Sqlite.Tests.csproj" />
<Project Path="tests/FeatureManagement.Database.EntityFrameworkCore.SqlServer.Tests/FeatureManagement.Database.EntityFrameworkCore.SqlServer.Tests.csproj" />
<Project Path="tests/FeatureManagement.Database.EntityFrameworkCore.Tests/FeatureManagement.Database.EntityFrameworkCore.Tests.csproj" />
<Project Path="tests/FeatureManagement.Database.MongoDB.Tests/FeatureManagement.Database.MongoDB.Tests.csproj" />
<Project Path="tests/FeatureManagement.Database.NHibernate.Tests/FeatureManagement.Database.NHibernate.Tests.csproj" />
</Folder>
<Properties Name="Visual Studio">
<Property Name="OpenWith" Value="17" />
</Properties>
</Solution>
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ It includes abstractions and default implementations to facilitate easy integrat

The Wiki contains comprehensive information on the following topics:


* **[Packages](https://github.com/teociaps/FeatureManagement.Database/wiki/Packages)**: Overview of the available NuGet packages.
* **[Getting Started](https://github.com/teociaps/FeatureManagement.Database/wiki/Getting-Started)**: Instructions on how to begin using the library.
* **[Consumption](https://github.com/teociaps/FeatureManagement.Database/wiki/Consumption)**: Details on how to use feature flags in your application.
Expand Down
7 changes: 4 additions & 3 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# build.ps1
param(
[string]$Configuration = "Release"
[string]$Configuration = "Release",
[string]$SolutionFile = "FeatureManagement.Database.sln"
)

# Restore dependencies
Write-Host "Restoring dependencies..."
dotnet restore
dotnet restore $SolutionFile
if ($LASTEXITCODE -ne 0) {
Write-Error "dotnet restore failed"
exit $LASTEXITCODE
}

# Build the project
Write-Host "Building project..."
dotnet build --no-restore --configuration $Configuration
dotnet build $SolutionFile --no-restore --configuration $Configuration
if ($LASTEXITCODE -ne 0) {
Write-Error "dotnet build failed"
exit $LASTEXITCODE
Expand Down
2 changes: 1 addition & 1 deletion build/Common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<LangVersion>12.0</LangVersion>
<LangVersion>13.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace />
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions samples/ConsoleApp/ConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>false</PublishAot>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 0 additions & 7 deletions samples/WebApiApp/Controllers/WeatherForecastController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ public class WeatherForecastController : ControllerBase
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
];

private readonly ILogger<WeatherForecastController> _logger;

public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}

[HttpGet(Name = "GetWeatherForecast")]
[FeatureGate(Features.Weather)]
public IEnumerable<WeatherForecast> Get()
Expand Down
14 changes: 5 additions & 9 deletions samples/WebApiApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,23 @@
// Seed with feature
using var scope = app.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<FeatureManagementDbContext>();
if (!dbContext.Features.Any())
if (!await dbContext.Features.AnyAsync())
{
dbContext.Features.Add(new Feature
{
Name = WebApiApp.Features.Weather,
Settings = [new FeatureSettings { FilterType = FeatureFilterType.Percentage, Parameters = """{ "Value": 50 }""" }]
});
dbContext.SaveChanges();
await dbContext.SaveChangesAsync();
}

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseSwagger();
app.UseSwaggerUI();

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
await app.RunAsync();
6 changes: 3 additions & 3 deletions samples/WebApiApp/WebApiApp.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.3" />
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="4.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
25 changes: 13 additions & 12 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Dapper" Version="2.1.35" />
<PackageVersion Include="FluentNHibernate" Version="3.4.0" />
<PackageVersion Include="Microsoft.Azure.Cosmos" Version="3.46.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.11" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.11" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.11" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageVersion Include="Dapper" Version="2.1.66" />
<PackageVersion Include="FluentNHibernate" Version="3.4.1" />
<PackageVersion Include="Microsoft.Azure.Cosmos" Version="3.48.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.3" />
<PackageVersion Include="Microsoft.Extensions.Caching.Hybrid" Version="9.3.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.3" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="9.0.3" />
<PackageVersion Include="Microsoft.FeatureManagement" Version="4.0.0" />
<PackageVersion Include="MongoDB.Driver" Version="3.1.0" />
<PackageVersion Include="MongoDB.Driver" Version="3.3.0" />
<PackageVersion Include="NHibernate" Version="5.5.2" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.11" />
<PackageVersion Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
<PackageVersion Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0-preview.3.efcore.9.0.0" />
<PackageVersion Include="System.Text.Json" Version="9.0.3" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.1;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.1;net6.0;net8.0;net9.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\build\NuGet.props" />
Expand All @@ -17,10 +17,20 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.FeatureManagement" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0' Or '$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" />
<PackageReference Include="Microsoft.FeatureManagement" />
<PackageReference Include="System.Text.Json" />
<PackageReference Include="Microsoft.Extensions.Caching.Hybrid" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Extensions.Configuration.Json" VersionOverride="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" VersionOverride="8.0.0" />
<PackageReference Include="System.Text.Json" VersionOverride="8.0.5" />
</ItemGroup>

</Project>
Loading
Loading