Skip to content

Commit 153f360

Browse files
committed
added 3D preview, CI pipelines
1 parent e23f23b commit 153f360

35 files changed

+1989
-206
lines changed

.github/dependabot.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Dependabot configuration file
2+
# Docs: https://docs.github.com/code-security/dependabot/working-with-dependabot/availability-of-dependabot-features
3+
version: 2
4+
updates:
5+
# NuGet packages
6+
- package-ecosystem: "nuget"
7+
directory: "/"
8+
schedule:
9+
interval: "weekly"
10+
day: "monday"
11+
time: "03:00"
12+
timezone: "Etc/UTC"
13+
open-pull-requests-limit: 10
14+
target-branch: "overhaul"
15+
rebase-strategy: "auto"
16+
groups:
17+
minor-and-patch:
18+
update-types: ["minor", "patch"]
19+
major:
20+
update-types: ["major"]
21+
22+
# GitHub Actions
23+
- package-ecosystem: "github-actions"
24+
directory: "/"
25+
schedule:
26+
interval: "weekly"
27+
day: "monday"
28+
time: "03:30"
29+
timezone: "Etc/UTC"
30+
open-pull-requests-limit: 10
31+
target-branch: "overhaul"
32+
rebase-strategy: "auto"
33+
groups:
34+
actions:
35+
patterns: ["*"]

.github/workflows/build-test.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Dotnet Build and Test
2+
3+
on:
4+
push:
5+
branches: [ main, overhaul ]
6+
pull_request:
7+
branches: [ main, overhaul ]
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
build-test:
18+
name: Build and test
19+
runs-on: windows-latest
20+
env:
21+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
22+
DOTNET_NOLOGO: 1
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Setup .NET 9 SDK
30+
uses: actions/setup-dotnet@v4
31+
with:
32+
dotnet-version: 9.0.x
33+
cache: true
34+
cache-dependency-path: |
35+
**/*.sln
36+
**/*.csproj
37+
38+
- name: Restore
39+
run: dotnet restore
40+
41+
- name: Build
42+
run: dotnet build --configuration Release --no-restore /p:ContinuousIntegrationBuild=true
43+
44+
- name: Test
45+
if: ${{ hashFiles('**/*Tests.csproj') != '' || hashFiles('**/*Test.csproj') != '' }}
46+
run: >-
47+
dotnet test --configuration Release --no-build --verbosity normal
48+
--collect:"XPlat Code Coverage" --logger "trx;LogFileName=test_results.trx"
49+
50+
- name: Upload test results
51+
if: ${{ always() && (hashFiles('**/*Tests.csproj') != '' || hashFiles('**/*Test.csproj') != '' ) }}
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: test-results
55+
path: |
56+
**/TestResults/*.trx
57+
**/TestResults/**/coverage.cobertura.xml
58+
if-no-files-found: ignore

.github/workflows/codeql.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: CodeQL
2+
3+
on:
4+
push:
5+
branches: [ main, overhaul ]
6+
pull_request:
7+
branches: [ main, overhaul ]
8+
schedule:
9+
- cron: '0 3 * * 1'
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
security-events: write
15+
actions: read
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
analyze:
23+
name: CodeQL analyze (C#)
24+
runs-on: windows-latest
25+
env:
26+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
27+
DOTNET_NOLOGO: 1
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Setup .NET 9 SDK
33+
uses: actions/setup-dotnet@v4
34+
with:
35+
dotnet-version: 9.0.x
36+
37+
- name: Initialize CodeQL
38+
uses: github/codeql-action/init@v3
39+
with:
40+
languages: csharp
41+
42+
- name: Autobuild
43+
uses: github/codeql-action/autobuild@v3
44+
45+
- name: Manual build fallback
46+
if: failure()
47+
run: |
48+
dotnet restore
49+
dotnet build --configuration Release --no-restore
50+
51+
- name: Perform CodeQL Analysis
52+
uses: github/codeql-action/analyze@v3
53+
with:
54+
category: '/language:csharp'
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Dependency Review
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
dependency-review:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Dependency Review
19+
uses: actions/dependency-review-action@v4
20+
with:
21+
allow-licenses: ''
22+
deny-licenses: ''
23+
fail-on-severity: high
24+
warn-only: false
25+
comment-summary-in-pr: true
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Vulnerability Audit
2+
3+
on:
4+
schedule:
5+
- cron: '0 4 * * 1' # Weekly on Mondays at 04:00 UTC
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
audit:
13+
runs-on: windows-latest
14+
env:
15+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
16+
DOTNET_NOLOGO: 1
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup .NET 9 SDK
22+
uses: actions/setup-dotnet@v4
23+
with:
24+
dotnet-version: 9.0.x
25+
26+
- name: Restore
27+
run: dotnet restore
28+
29+
- name: List vulnerable packages (JSON)
30+
run: |
31+
dotnet list package --vulnerable --include-transitive --format json > vuln-report.json
32+
type vuln-report.json
33+
34+
- name: Fail on high/critical vulnerabilities
35+
shell: pwsh
36+
run: |
37+
$content = Get-Content vuln-report.json -Raw
38+
$high = [regex]::Matches($content, '"severity"\s*:\s*"High"', 'IgnoreCase').Count
39+
$critical = [regex]::Matches($content, '"severity"\s*:\s*"Critical"', 'IgnoreCase').Count
40+
$total = $high + $critical
41+
Write-Host "High: $high, Critical: $critical"
42+
if ($total -gt 0) {
43+
throw "Found $total High/Critical vulnerabilities"
44+
}
45+
46+
- name: Upload audit artifact
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: vulnerability-audit
50+
path: vuln-report.json
51+
if-no-files-found: error

Data/Repositories/ISkuRepository.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@ public interface ISkuRepository
1010
Task UpdateAsync(SKU sku, CancellationToken ct = default);
1111
Task DeleteAsync(string skuId, CancellationToken ct = default);
1212
Task<int> SaveChangesAsync(CancellationToken ct = default);
13+
event EventHandler<SKU>? SkuAdded;
14+
event EventHandler<SKU>? SkuUpdated;
15+
event EventHandler<string>? SkuDeleted;
1316
}
1417
}

Data/Repositories/SkuRepository.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ namespace Stack_Solver.Data.Repositories
55
{
66
public class SkuRepository(IDbContextFactory<ApplicationDbContext> factory) : ISkuRepository
77
{
8+
public event EventHandler<SKU>? SkuAdded;
9+
public event EventHandler<SKU>? SkuUpdated;
10+
public event EventHandler<string>? SkuDeleted;
11+
812
public async Task<IList<SKU>> GetAllAsync(CancellationToken ct = default)
913
{
1014
using var db = await factory.CreateDbContextAsync(ct);
@@ -22,13 +26,15 @@ public async Task AddAsync(SKU sku, CancellationToken ct = default)
2226
using var db = await factory.CreateDbContextAsync(ct);
2327
db.Skus.Add(sku);
2428
await db.SaveChangesAsync(ct);
29+
SkuAdded?.Invoke(this, sku);
2530
}
2631

2732
public async Task UpdateAsync(SKU sku, CancellationToken ct = default)
2833
{
2934
using var db = await factory.CreateDbContextAsync(ct);
3035
db.Skus.Update(sku);
3136
await db.SaveChangesAsync(ct);
37+
SkuUpdated?.Invoke(this, sku);
3238
}
3339

3440
public async Task DeleteAsync(string skuId, CancellationToken ct = default)
@@ -39,6 +45,7 @@ public async Task DeleteAsync(string skuId, CancellationToken ct = default)
3945
{
4046
db.Skus.Remove(entity);
4147
await db.SaveChangesAsync(ct);
48+
SkuDeleted?.Invoke(this, skuId);
4249
}
4350
}
4451

0 commit comments

Comments
 (0)