Skip to content

feat: adaptive sdk for asp.net #2

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 23 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,26 @@ on:
pull_request:
branches: [ main ]

# strategy: linux, macos, windows
# test & cov
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
- uses: actions/setup-dotnet@v3
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
- run: dotnet restore
- run: dotnet build --no-restore
- run: dotnet test --no-build --no-restore --verbosity normal --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
- if: failure()
uses: actions/upload-artifact@v3
with:
name: TestResults-${{ github.run_id }}
path: '**/TestResults/*'
- uses: codecov/codecov-action@v2
30 changes: 0 additions & 30 deletions .github/workflows/docs.yml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/lint.yml

This file was deleted.

35 changes: 30 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,44 @@
name: Release

on:
push:
branches: [ main ]
release:
types:
- released
- prereleased

jobs:
build:
runs-on: ubuntu-latest
release:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
- uses: actions/setup-dotnet@v3
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
include-prerelease: true
- run: dotnet restore
- run: dotnet build --no-restore
- run: dotnet test --no-build --no-restore --verbosity normal --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover

- name: Pack packages
run: |
$ReleaseTag = "${{ github.event.release.tag_name }}";
$Version = ($ReleaseTag).TrimStart('v');
echo "Publishing version: $Version";
dotnet pack -c Release -o packages /p:PackageVersion=$Version /p:Version=$Version;
- uses: actions/upload-artifact@v3
with:
name: 'packages-${{ github.event.release.tag_name }}'
path: './packages'

# - name: Upload to github packages
# run: |
# dotnet nuget add source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json -n github.com -u ${{ github.repository_owner }} -p ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text
# dotnet nuget push .\packages\*.nupkg -s github.com -k ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
- name: Upload to nuget
run: |
dotnet nuget push .\packages\*.nupkg -s nuget.org -k ${{ secrets.NUGET_API_KEY }} --skip-duplicate
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

[submodule "tests/FeatureProbe.Server.Sdk.UT/resources/test"]
path = tests/FeatureProbe.Server.Sdk.UT/resources/test
[submodule "tests/FeatureProbe.Server.Sdk.Tests/resources/test"]
path = tests/FeatureProbe.Server.Sdk.Tests/resources/test
url = git@github.com:FeatureProbe/server-sdk-specification.git
1 change: 1 addition & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ header:
- "**/*.md"
- "**/obj/**/*"
- "**/bin/**/*"
- "**/TestResults/**/*"
- "**/*.sln"
- "**/*.json"
- "nlog.config"
2 changes: 0 additions & 2 deletions FeatureProbe.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Github Workflow", "Github W
.github\workflows\build.yml = .github\workflows\build.yml
.github\workflows\codeql.yml = .github\workflows\codeql.yml
.github\workflows\release.yml = .github\workflows\release.yml
.github\workflows\docs.yml = .github\workflows\docs.yml
.github\workflows\lint.yml = .github\workflows\lint.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{E283CF98-D2A5-445A-9474-F0DE1F587F9F}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,26 @@
* limitations under the License.
*/

namespace FeatureProbe.AspNet.Sdk.SampleApi;
using FeatureProbe.Server.Sdk;
using Microsoft.AspNetCore.Mvc;

public class WeatherForecast
{
public DateOnly Date { get; set; }
namespace FeatureProbe.AspNet.Sdk.SampleApi.Controllers;

public int TemperatureC { get; set; }
[ApiController]
[Route("/featureprobe")]
public class FeatureProbeController : ControllerBase
{
private readonly FPClient _fpClient;

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public FeatureProbeController(FPClient fpClient)
{
_fpClient = fpClient;
}

public string? Summary { get; set; }
[HttpGet]
public FPDetail<bool> Get([FromQuery] string userId)
{
var user = new FPUser().With("userId", userId);
return _fpClient.BoolDetail("campaign_allow_list", user, false);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup Condition=" '$(RunConfiguration)' == 'https' " />
<PropertyGroup Condition=" '$(RunConfiguration)' == 'http' " />
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.7" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\FeatureProbe.AspNet.Sdk\FeatureProbe.AspNet.Sdk.csproj" />
</ItemGroup>

</Project>
25 changes: 5 additions & 20 deletions samples/FeatureProbe.AspNet.Sdk.SampleApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,13 @@
* limitations under the License.
*/

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
using FeatureProbe.AspNet.Sdk;

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddFeatureProbe(builder.Configuration.GetSection("FeatureProbe"))
.AddControllers();

var app = builder.Build();

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

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
Original file line number Diff line number Diff line change
@@ -1,41 +1,12 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:18943",
"sslPort": 44383
}
},
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5247",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7248;http://localhost:5247",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"launchUrl": "featureprobe?userId=00001",
"dotnetRunMessages": true
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
6 changes: 6 additions & 0 deletions samples/FeatureProbe.AspNet.Sdk.SampleApi/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"FeatureProbe": {
"RemoteUrl": "http://localhost:4009/server",
"SdkKey": "server-8ed48815ef044428826787e9a238b9c6a479f98c",
"RefreshInterval": 5,
"StartWait": 200
},
"Logging": {
"LogLevel": {
"Default": "Information",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<Description>Example Console app for using FeatureProbe.Server.Sdk</Description>
</PropertyGroup>

Expand Down
7 changes: 4 additions & 3 deletions samples/FeatureProbe.Server.Sdk.SampleConsole/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ public static void Main()
//// Must provide the server-side SDK Key for your project and environment
.ServerSdkKey("server-8ed48815ef044428826787e9a238b9c6a479f98c")
//// RemoteUrl is where you deploy the FeatureProbe server, by default, SDK will use its API for reporting events, synchronizing toggles, and so
.RemoteUrl("https://featureprobe.io/server") // FeatureProbe online demo
// .RemoteUrl("http://localhost:4009/server") // Default URL for local Docker installation, also the default value if unset
.RemoteUrl(
"http://localhost:4009/server") // Default URL for local Docker installation, also the default value if unset
// .RemoteUrl("https://featureprobe.io/server") // FeatureProbe online demo
//// Below are three modes of synchronizing toggles, you can choose one of them
.StreamingMode()
// .PollingMode()
// .LocalFileMode("datasource/repo.json")
// .LocalFileMode(Path.Combine("datasource", "repo.json"))
//// Optionally provide a logger factory to enable logging
.WithLoggers(LoggerFactory.Create(builder => builder.AddNLog()))
.Build();
Expand Down
Loading