Skip to content
Merged
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
68 changes: 68 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build

on:
push:
branches:
- dev

jobs:
build:
name: Build and analyze
runs-on: windows-latest

steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up JDK 17
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4.8.0
with:
java-version: 17
distribution: 'zulu'

- name: Set up .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Cache SonarQube packages
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ~\.sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache SonarQube scanner
id: cache-sonar-scanner
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner

- name: Install SonarQube scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner

- name: SonarQube Begin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"SCMS_SQ" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}"

- name: Build solution
shell: powershell
run: |
dotnet build SCMS.sln

- name: SonarQube End
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,4 @@ MigrationBackup/
FodyWeavers.xsd

D:\SCMS\ZPrompt
.sonarqube/
11 changes: 1 addition & 10 deletions SCMS.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
ClockSkew = TimeSpan.FromMinutes(1)
};



options.Events = new JwtBearerEvents
{
Expand Down Expand Up @@ -136,15 +136,6 @@ await context.Response.WriteAsJsonAsync(
});



//using (var scope = app.Services.CreateScope())
//{
// var seeder = scope.ServiceProvider.GetRequiredService<SCMS.Domain.Features.Dev.MassDatabaseSeeder>();
// await seeder.Seed1YearDataAsync();
//}



app.UseHttpsRedirection();


Expand Down
3 changes: 1 addition & 2 deletions SCMS.Api/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
"PostgreSqlConnection": "Host=aws-1-ap-southeast-2.pooler.supabase.com;Port=6543;Database=postgres;Username=postgres.pevargmxjsdqcqzdyxak;Password=sasa123SASA123#;Pooling=false;Max Auto Prepare=0;"
},
"Database": {
"Provider": "InMemory",
"Provider": "Sqlite",
"EnsureCreated": true,
"InMemoryDatabaseName": "ScmsMemoryDb",
"SeedDemoUsers": true,
"SeedRealWorldData": true
},
Expand Down
22 changes: 3 additions & 19 deletions SCMS.Domain/FeatureManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public static async Task EnsureScmsDatabaseCreatedAsync(this IServiceProvider se
await EnsureSqliteSchemaCompatibilityAsync(context, logger);
}

await SqliteRealWorldSeeder.SeedAsync(context, configuration);
await SeedSqliteDemoUsersAsync(context, configuration);
logger.LogInformation("Database initialization completed.");
}
Expand Down Expand Up @@ -269,13 +268,6 @@ private static async Task<TblUser> EnsureDemoUserAsync(

private static void ConfigureDatabaseProvider(DbContextOptionsBuilder options, IConfiguration configuration)
{
if (IsInMemoryProvider(configuration))
{
var databaseName = configuration.GetValue<string>("Database:InMemoryDatabaseName") ?? "ScmsMemoryDb";
options.UseInMemoryDatabase(databaseName);
return;
}

if (IsSqliteProvider(configuration))
{
var connectionString = GetConnectionString(configuration, "SqliteConnection", "Data Source=scms.local.db");
Expand All @@ -290,7 +282,7 @@ private static void ConfigureDatabaseProvider(DbContextOptionsBuilder options, I
return;
}

throw new InvalidOperationException("Unsupported Database:Provider. Use 'InMemory', 'Sqlite' or 'PostgreSql'.");
throw new InvalidOperationException("Unsupported Database:Provider. Use 'Sqlite' or 'PostgreSql'.");
}

private static string GetConnectionString(IConfiguration configuration, string namedConnection, string? fallback)
Expand Down Expand Up @@ -323,20 +315,12 @@ private static bool IsPostgreSqlProvider(IConfiguration configuration)
|| string.Equals(provider, "Npgsql", StringComparison.OrdinalIgnoreCase);
}

private static bool IsInMemoryProvider(IConfiguration configuration)
{
var provider = GetDatabaseProvider(configuration);
return string.Equals(provider, "InMemory", StringComparison.OrdinalIgnoreCase)
|| string.Equals(provider, "Memory", StringComparison.OrdinalIgnoreCase)
|| string.Equals(provider, "MemoryDb", StringComparison.OrdinalIgnoreCase);
}

private static bool ShouldInitializeDatabase(IConfiguration configuration)
{
return IsInMemoryProvider(configuration) || IsSqliteProvider(configuration);
return IsSqliteProvider(configuration);
}

private static string GetDatabaseProvider(IConfiguration configuration)
=> configuration["Database:Provider"] ?? "InMemory";
=> configuration["Database:Provider"] ?? "Sqlite";
}
}
4 changes: 2 additions & 2 deletions SCMS.Domain/SCMS.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />

</ItemGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<ProjectReference Include="..\SCMS.Shared\SCMS.Shared.csproj" />
<ProjectReference Include="..\SCMS.Database\SCMS.Database.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Features\Photo\" />
</ItemGroup>
Expand Down
Loading
Loading