Skip to content

Commit 20086d3

Browse files
Merge branch 'main' into copilot/fix-3
2 parents f8d1c14 + 6dab836 commit 20086d3

110 files changed

Lines changed: 4519 additions & 852 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/copilot-instructions.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Codebreaker Backend
2+
3+
Codebreaker Backend is a .NET 9 microservices solution using .NET Aspire orchestration for a game platform. The solution includes game APIs, clients, analyzers, and multiple service components with Azure integrations.
4+
5+
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
6+
7+
## Working Effectively
8+
9+
### Prerequisites
10+
- Install .NET 9 SDK: `curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 9.0`
11+
- Install .NET 8 runtime for multi-targeted tests: `curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 8.0 --runtime dotnet`
12+
- Set PATH: `export PATH="$HOME/.dotnet:$PATH"`
13+
- Verify installation: `dotnet --version` should show 9.0.103 or later
14+
15+
### Build Individual Solutions
16+
The repository contains multiple solution files that can be built independently:
17+
18+
- `dotnet build src/Codebreaker.Analyzers.sln` -- takes 9 seconds. NEVER CANCEL. Set timeout to 20+ seconds.
19+
- `dotnet build src/Codebreaker.Backend.Models.sln` -- takes 7 seconds. NEVER CANCEL. Set timeout to 20+ seconds.
20+
- `dotnet build src/Codebreaker.Backend.slnx` -- main solution
21+
- `dotnet build src/Codebreaker.GameAPIs.Client.sln` -- takes 10 seconds. NEVER CANCEL. Set timeout to 20+ seconds.
22+
- `dotnet build src/Codebreaker.Backend.Cosmos.sln` -- library solution
23+
- `dotnet build src/Codebreaker.Backend.SqlServer.sln` -- library solution
24+
- `dotnet build src/Codebreaker.Backend.Postgres.sln` -- library solution
25+
26+
### Test Individual Solutions
27+
- `dotnet test src/Codebreaker.Analyzers.sln` -- takes 4 seconds, runs 53 tests. NEVER CANCEL. Set timeout to 15+ seconds.
28+
- `dotnet test src/Codebreaker.Backend.Models.sln` -- requires .NET 8 runtime for net8.0 tests
29+
- `dotnet test src/Codebreaker.GameAPIs.Client.sln` -- takes 8 seconds, runs 11 tests. NEVER CANCEL. Set timeout to 20+ seconds.
30+
31+
### Build Individual Projects
32+
Individual projects build faster than full solutions:
33+
- `dotnet build src/services/gameapis/Codebreaker.GameAPIs/Codebreaker.GameAPIs.csproj` -- takes 3.5 seconds
34+
35+
### Run Individual Services
36+
Services can be run independently for development:
37+
- Game APIs: `cd src/services/gameapis/Codebreaker.GameAPIs && dotnet run` -- runs on http://localhost:9400
38+
- Services start quickly but require proper database configuration for full functionality
39+
40+
### Full Solution Build Limitations
41+
- The main solution `src/Codebreaker.Backend.slnx` is in .slnx format
42+
- Building the AppHost project requires private Azure DevOps feeds: `dotnet build src/services/host/Codebreaker.AppHost/Codebreaker.AppHost.csproj` -- takes 45+ minutes and requires Azure DevOps authentication. NEVER CANCEL. Set timeout to 60+ minutes.
43+
- Azure deployment requires `azd` CLI and Azure authentication
44+
45+
## Central Package Management
46+
The repository uses Central Package Management with `src/Directory.Packages.props`. When adding PackageReference items:
47+
- Do NOT specify versions in .csproj files
48+
- Add package versions to `src/Directory.Packages.props`
49+
- Build will fail if PackageReference has version but package not in Directory.Packages.props
50+
- Common packages already configured: Microsoft.NET.Test.Sdk, xunit, Moq, coverlet.collector
51+
52+
## Validation
53+
- Always run `dotnet format --verify-no-changes src/[solution].sln` before committing -- takes 10 seconds with detailed formatting analysis. NEVER CANCEL. Set timeout to 30+ seconds.
54+
- Always build and test changes on individual solutions before attempting full stack
55+
- Individual Game APIs service can be tested by running on localhost:9400
56+
- Test health endpoint: `curl http://localhost:9400/health` (expects 500 error without database)
57+
- Test Swagger: `curl http://localhost:9400/swagger` (expects 301 redirect)
58+
59+
## Architecture Overview
60+
**Key Projects:**
61+
- **AppHost**: .NET Aspire orchestration host (src/services/host/Codebreaker.AppHost)
62+
- **Game APIs**: Core game service (src/services/gameapis/Codebreaker.GameAPIs)
63+
- **Analyzers**: Game logic analyzers (src/services/common/Codebreaker.GameAPIs.Analyzers)
64+
- **Client Libraries**: API clients (src/clients/Codebreaker.GameAPIs.Client)
65+
- **Blazor App**: Web UI (src/services/Codebreaker.Blazor)
66+
- **Gateway**: API Gateway with YARP (src/services/gateway)
67+
- **Live Service**: SignalR service (src/services/live)
68+
- **Ranking Service**: Game ranking (src/services/ranking)
69+
- **User Service**: User management (src/services/user)
70+
- **Bot Services**: Game bots (src/services/bot)
71+
72+
**Data Access:**
73+
- Cosmos DB library: src/services/common/Codebreaker.Data.Cosmos
74+
- SQL Server library: src/services/common/Codebreaker.Data.SqlServer
75+
- PostgreSQL library: src/services/common/Codebreaker.Data.Postgres
76+
77+
## Azure Services Integration
78+
The solution integrates with:
79+
- Azure Container Apps
80+
- Azure Cosmos DB
81+
- Azure Active Directory B2C
82+
- Azure SignalR Services
83+
- Azure App Configuration
84+
- Azure Event Hub
85+
- Azure Storage
86+
- Azure Key Vault
87+
88+
## Common Tasks
89+
Use these outputs instead of running commands to save time:
90+
91+
### Repository Structure
92+
```
93+
src/
94+
├── Codebreaker.*.sln # Individual solution files
95+
├── Codebreaker.Backend.slnx # Main solution (.slnx format)
96+
├── Directory.Build.props # Common build properties
97+
├── Directory.Packages.props # Central package management
98+
├── clients/ # Client libraries
99+
├── services/
100+
│ ├── bot/ # Game bot services
101+
│ ├── common/ # Shared libraries (analyzers, data, models)
102+
│ ├── gameapis/ # Core game service
103+
│ ├── gateway/ # API gateway
104+
│ ├── host/ # Aspire AppHost
105+
│ ├── live/ # SignalR service
106+
│ ├── ranking/ # Ranking service
107+
│ ├── user/ # User service
108+
│ └── Codebreaker.Blazor/ # Web UI
109+
```
110+
111+
### Target Frameworks
112+
- Primary: net9.0
113+
- Multi-targeting: net8.0;net9.0 (for libraries)
114+
- Test projects: primarily net9.0
115+
116+
### Known Build Issues
117+
- Central Package Management requires proper setup
118+
- Private Azure DevOps feeds with anonymous access needed for full solution
119+
- Some test projects may need package reference fixes
120+
- Docker/container builds require Azure authentication
121+
122+
### Development Workflow
123+
1. Make code changes to individual projects
124+
2. Build individual solutions: `dotnet build src/[specific].sln`
125+
3. Run tests: `dotnet test src/[specific].sln`
126+
4. Format code: `dotnet format src/[specific].sln`
127+
5. Test individual services with `dotnet run`
128+
6. Use AppHost for full stack development (requires Azure setup)
129+
130+
### Performance Expectations
131+
- Individual solution builds: 3-10 seconds
132+
- Individual solution tests: 4-8 seconds
133+
- Code formatting: 10 seconds
134+
- Full AppHost build: 5+ minutes (requires private feeds)
135+
- Service startup: 2-5 seconds

.github/workflows/azure-dev.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Run when commits are pushed to 254-sharedtestenvironment
2+
on:
3+
workflow_dispatch:
4+
push:
5+
# Run when commits are pushed to mainline branch (main or master)
6+
# Set this to the mainline branch you are using
7+
branches:
8+
- 254-sharedtestenvironment
9+
10+
# Set up permissions for deploying with secretless Azure federated credentials
11+
# https://learn.microsoft.com/en-us/azure/developer/github/connect-from-azure?tabs=azure-portal%2Clinux#set-up-azure-login-with-openid-connect-authentication
12+
permissions:
13+
id-token: write
14+
contents: read
15+
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
env:
21+
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
22+
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
23+
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
24+
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }}
25+
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v5
29+
- name: Install azd
30+
uses: Azure/setup-azd@v2.2.0
31+
- name: Install .NET Aspire workload
32+
run: dotnet workload install aspire
33+
34+
- name: Log in with Azure (Federated Credentials)
35+
run: |
36+
azd auth login `
37+
--client-id "$Env:AZURE_CLIENT_ID" `
38+
--federated-credential-provider "github" `
39+
--tenant-id "$Env:AZURE_TENANT_ID"
40+
shell: pwsh
41+
42+
43+
- name: Provision Infrastructure
44+
run: azd provision --no-prompt
45+
env:
46+
AZD_INITIAL_ENVIRONMENT_CONFIG: ${{ secrets.AZD_INITIAL_ENVIRONMENT_CONFIG }}
47+
48+
- name: Deploy Application
49+
run: azd deploy --no-prompt

.github/workflows/codebreaker-azure.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ jobs:
3737
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
3838
steps:
3939
- name: Checkout
40-
uses: actions/checkout@v4
40+
uses: actions/checkout@v5
4141
with:
4242
submodules: 'true'
4343

4444
- name: Install azd
45-
uses: Azure/setup-azd@v2.1.0
45+
uses: Azure/setup-azd@v2.2.0
4646

4747
- name: Setup .NET
48-
uses: actions/setup-dotnet@v4
48+
uses: actions/setup-dotnet@v5
4949
with:
5050
dotnet-version: 9.0.x
5151

.github/workflows/codebreaker-lib-analyzers-stable.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
env:
12-
solutionfile-path: src/Codebreaker.Analyzers.sln
12+
solutionfile-path: src/Codebreaker.Analyzers.slnx
1313
projectfile-path: src/services/common/Codebreaker.GameAPIs.Analyzers/Codebreaker.Analyzers.csproj
1414
artifact-name: codebreaker-analyzers-stable
1515

1616
steps:
1717
- name: Checkout to the branch
18-
uses: actions/checkout@v4
18+
uses: actions/checkout@v5
1919
with:
2020
ref: main
2121

2222
- name: Setup .NET
23-
uses: actions/setup-dotnet@v4
23+
uses: actions/setup-dotnet@v5
2424
with:
2525
dotnet-version: 9.0.x
2626

.github/workflows/codebreaker-lib-analyzers.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99
paths:
1010
- 'src/services/common/Codebreaker.GameAPIs.Analyzers/**'
1111
- 'src/services/common/Codebreaker.GameAPIs.Analyzers.Tests/**'
12-
- 'src/Codebreaker.Analyzers.sln'
1312

1413
# Allow manually trigger
1514
workflow_dispatch:
@@ -21,7 +20,7 @@ jobs:
2120
version-suffix: preview.1.
2221
version-number: ${{ github.run_number }}
2322
version-offset: 38
24-
solutionfile-path: src/Codebreaker.Analyzers.sln
23+
solutionfile-path: src/Codebreaker.Analyzers.slnx
2524
projectfile-path: src/services/common/Codebreaker.GameAPIs.Analyzers/Codebreaker.Analyzers.csproj
2625
dotnet-version: '9.0.x'
2726
artifact-name: codebreaker-analyzers

.github/workflows/codebreaker-lib-backendmodels-stable.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
env:
12-
solutionfile-path: src/Codebreaker.Backend.Models.sln
12+
solutionfile-path: src/Codebreaker.Backend.Models.slnx
1313
projectfile-path: src/services/common/Codebreaker.GameAPIs.Models/Codebreaker.GameAPIs.Models.csproj
1414
artifact-name: codebreaker-backendmodels-stable
1515

1616
steps:
1717
- name: Checkout to the branch
18-
uses: actions/checkout@v4
18+
uses: actions/checkout@v5
1919
with:
2020
ref: main
2121

2222
- name: Setup .NET
23-
uses: actions/setup-dotnet@v4
23+
uses: actions/setup-dotnet@v5
2424
with:
2525
dotnet-version: 9.0.x
2626

.github/workflows/codebreaker-lib-backendmodels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
[ main ]
99
paths:
1010
- 'src/services/common/Codebreaker.GameAPIs.Models/**'
11-
- 'src/Codebreaker.Backend.Models.sln'
11+
- 'src/Codebreaker.Backend.Models.slnx'
1212

1313
# Allow manually trigger
1414
workflow_dispatch:

.github/workflows/codebreaker-lib-client-stable.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
env:
12-
solutionfile-path: src/Codebreaker.GameAPIs.Client.sln
12+
solutionfile-path: src/Codebreaker.GameAPIs.Client.slnx
1313
projectfile-path: src/clients/Codebreaker.GameAPIs.Client/Codebreaker.GameAPIs.Client.csproj
1414
artifact-name: codebreaker-client-stable
1515

1616
steps:
1717
- name: Checkout to the branch
18-
uses: actions/checkout@v4
18+
uses: actions/checkout@v5
1919
with:
2020
ref: main
2121

2222
- name: Setup .NET
23-
uses: actions/setup-dotnet@v4
23+
uses: actions/setup-dotnet@v5
2424
with:
2525
dotnet-version: 9.0.x
2626

.github/workflows/codebreaker-lib-client.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99
paths:
1010
- 'src/clients/Codebreaker.GameAPIs.Client/**'
1111
- 'src/clients/Codebreaker.GameAPIs.Client.Tests/**'
12-
- 'src/Codebreaker.GameAPIs.Client.sln'
1312

1413
# Allow manually trigger
1514
workflow_dispatch:
@@ -21,7 +20,7 @@ jobs:
2120
version-suffix: preview.1.
2221
version-number: ${{ github.run_number }}
2322
version-offset: 10
24-
solutionfile-path: src/Codebreaker.GameAPIs.Client.sln
23+
solutionfile-path: src/Codebreaker.GameAPIs.Client.slnx
2524
projectfile-path: src/clients/Codebreaker.GameAPIs.Client/Codebreaker.GameAPIs.Client.csproj
2625
dotnet-version: '9.0.x'
2726
artifact-name: codebreaker-clientlib

.github/workflows/codebreaker-lib-cosmos-stable.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
env:
12-
solutionfile-path: src/Codebreaker.Backend.Cosmos.sln
12+
solutionfile-path: src/Codebreaker.Backend.Cosmos.slnx
1313
projectfile-path: src/services/common/Codebreaker.Data.Cosmos/Codebreaker.Data.Cosmos.csproj
1414
artifact-name: codebreaker-cosmos-stable
1515

1616
steps:
1717
- name: Checkout to the branch
18-
uses: actions/checkout@v4
18+
uses: actions/checkout@v5
1919
with:
2020
ref: main
2121

2222
- name: Setup .NET
23-
uses: actions/setup-dotnet@v4
23+
uses: actions/setup-dotnet@v5
2424
with:
2525
dotnet-version: 9.0.x
2626

0 commit comments

Comments
 (0)