Skip to content

Commit 7c2e4cd

Browse files
transitory documents - move common models and core to own projects. (#733)
cleanup warnings.
1 parent fe91ba9 commit 7c2e4cd

573 files changed

Lines changed: 15269 additions & 3835 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.

.editorconfig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Remove the line below if you want to inherit .editorconfig settings from higher directories
2+
root = true
3+
4+
# C# files
5+
[*.cs]
6+
7+
#### Core EditorConfig Options ####
8+
9+
# Indentation and spacing
10+
indent_size = 4
11+
indent_style = space
12+
tab_width = 4
13+
14+
# New line preferences
15+
end_of_line = lf
16+
insert_final_newline = true
17+
18+
# Analyzer severities
19+
# IDE0005: Using directive is unnecessary
20+
dotnet_diagnostic.IDE0005.severity = warning
21+
# CA1873: Potentially expensive logging argument evaluation
22+
dotnet_diagnostic.CA1873.severity = none
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Build transitory-documents-api
2+
description: Builds the transitory-documents-api codebase
3+
4+
inputs:
5+
working_directory:
6+
description: The working directory where the code will be built.
7+
required: true
8+
dotnet_version:
9+
description: The .NET version that will be used.
10+
required: true
11+
12+
runs:
13+
using: composite
14+
15+
steps:
16+
- name: Setup .NET Core
17+
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4
18+
with:
19+
dotnet-version: ${{ inputs.dotnet_version }}
20+
21+
- run: dotnet format --verify-no-changes --severity info
22+
shell: bash
23+
working-directory: ${{ inputs.working_directory }}/transitory-documents-api
24+
continue-on-error: false
25+
26+
- run: dotnet restore
27+
shell: bash
28+
working-directory: ${{ inputs.working_directory }}
29+
30+
- run: dotnet build --configuration Release --no-restore
31+
shell: bash
32+
working-directory: ${{ inputs.working_directory }}/transitory-documents-api
33+
34+
- run: dotnet test --no-restore --verbosity normal
35+
shell: bash
36+
working-directory: ${{ inputs.working_directory }}/tests

.github/workflows/build-and-test-api.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ on:
77
paths:
88
- 'api/**'
99
- 'db/**'
10+
- 'models/**'
11+
- 'core/**'
1012
- 'cso-client/**'
1113
- 'dars-client/**'
1214
- 'jc-interface-client/**'
1315
- 'pcss-client/**'
16+
- 'transitory-documents-client/**'
1417
- 'tests/**'
1518

1619
workflow_dispatch:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build and Test transitory-documents-api
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
pull_request:
8+
branches:
9+
- master
10+
paths:
11+
- 'transitory-documents-api/**'
12+
- 'transitory-documents-client/**'
13+
- 'models/**'
14+
- 'core/**'
15+
16+
workflow_dispatch:
17+
18+
env:
19+
WORKING_DIRECTORY: .
20+
21+
jobs:
22+
build-and-test:
23+
runs-on: ubuntu-latest
24+
25+
strategy:
26+
matrix:
27+
dotnet-major-version: [10]
28+
dotnet-minor-version: [0]
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
33+
34+
- name: Building transitory documents codebase
35+
uses: ./.github/workflows/actions/build-transitory-documents-api
36+
with:
37+
working_directory: ${{ env.WORKING_DIRECTORY }}
38+
dotnet_version: ${{ matrix.dotnet-major-version }}.${{ matrix.dotnet-minor-version }}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Deploy transitory-documents-api
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- 'transitory-documents-api/**'
9+
- 'models/**'
10+
- 'core/**'
11+
12+
workflow_dispatch:
13+
inputs:
14+
gitops-branch:
15+
description: GitOps repository branch to update
16+
required: false
17+
default: main
18+
gitops-environment:
19+
description: GitOps environment (dev, test, prod)
20+
required: false
21+
default: dev
22+
23+
permissions:
24+
contents: read
25+
packages: write
26+
27+
env:
28+
WORKING_DIRECTORY: .
29+
IMAGE_NAME: jasper-transitory-documents-api
30+
GITHUB_IMAGE_REPO: ghcr.io/${{ github.repository_owner }}/jasper
31+
GITOPS_REPOSITORY: bcgov-c/tenant-gitops-e4161f
32+
GITOPS_BRANCH: ${{ github.event.inputs.gitops-branch || 'main' }}
33+
GITOPS_ENVIRONMENT: ${{ github.event.inputs.gitops-environment || 'dev' }}
34+
GITOPS_FILE_PATH: deploy/transitory-documents-api/${{ github.event.inputs.gitops-environment || 'dev' }}_values.yaml
35+
36+
jobs:
37+
build:
38+
name: Build, Create and Push Image
39+
runs-on: ubuntu-latest
40+
outputs:
41+
short_sha: ${{ steps.short_sha.outputs.SHORT_SHA }}
42+
43+
strategy:
44+
matrix:
45+
dotnet-major-version: [10]
46+
dotnet-minor-version: [0]
47+
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
51+
52+
- name: Build API codebase
53+
uses: ./.github/workflows/actions/build-transitory-documents-api
54+
with:
55+
working_directory: ${{ env.WORKING_DIRECTORY }}
56+
dotnet_version: ${{ matrix.dotnet-major-version }}.${{ matrix.dotnet-minor-version }}
57+
58+
- name: Log in to the GHCR
59+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3
60+
with:
61+
registry: ghcr.io
62+
username: ${{ github.actor }}
63+
password: ${{ secrets.GITHUB_TOKEN }}
64+
65+
- name: Get short SHA
66+
id: short_sha
67+
run: |
68+
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
69+
70+
- name: Setup Image Metadata
71+
id: meta
72+
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
73+
with:
74+
images: |
75+
${{ env.GITHUB_IMAGE_REPO }}/${{ env.IMAGE_NAME }}
76+
tags: |
77+
type=raw,value=${{ steps.short_sha.outputs.SHORT_SHA }}
78+
79+
- name: Set up Docker Buildx
80+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
81+
82+
- name: Build and Push Image to ghcr.io
83+
id: build_image
84+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6
85+
with:
86+
push: true
87+
context: .
88+
file: ./docker/transitory-documents-api/Dockerfile.release
89+
tags: ${{ steps.meta.outputs.tags }}
90+
labels: ${{ steps.meta.outputs.labels }}
91+
build-args: |
92+
dotnet_version=${{ matrix.dotnet-major-version }}.${{ matrix.dotnet-minor-version }}
93+
94+
- name: Checkout tenant gitops repository
95+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
96+
with:
97+
repository: ${{ env.GITOPS_REPOSITORY }}
98+
ssh-key: ${{ secrets.TENANT_GITOPS_E4161F_DEPLOY_KEY }}
99+
ref: ${{ env.GITOPS_BRANCH }}
100+
path: tenant-gitops-e4161f
101+
102+
- name: Update transitory-documents-api dev image reference
103+
uses: fjogeleit/yaml-update-action@451fb54614e46f952fc18ffd99e8c93b7b13f85e # v0.15.0
104+
with:
105+
workDir: tenant-gitops-e4161f
106+
valueFile: ${{ env.GITOPS_FILE_PATH }}
107+
changes: |
108+
{
109+
"$['transitory-documents-api'].image.repository": "${{ env.GITHUB_IMAGE_REPO }}/${{ env.IMAGE_NAME }}",
110+
"$['transitory-documents-api'].image.tag": "${{ steps.short_sha.outputs.SHORT_SHA }}"
111+
}
112+
commitChange: false
113+
114+
- name: Load SSH deploy key
115+
uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 # v0.9.0
116+
with:
117+
ssh-private-key: ${{ secrets.TENANT_GITOPS_E4161F_DEPLOY_KEY }}
118+
119+
- name: Commit and push gitops update
120+
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9
121+
with:
122+
cwd: tenant-gitops-e4161f
123+
add: ${{ env.GITOPS_FILE_PATH }}
124+
message: Update transitory-documents-api ${{ env.GITOPS_ENVIRONMENT }} image to ${{ steps.short_sha.outputs.SHORT_SHA }}
125+
push: true

.vscode/launch.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

SCV.sln

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dars-client", "dars-client\
1616
EndProject
1717
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cso-client", "cso-client\cso-client.csproj", "{3FE50416-F9ED-591F-1B5F-DBFD49311713}"
1818
EndProject
19+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "transitory-documents-api", "transitory-documents-api\transitory-documents-api.csproj", "{69C5DC46-ACCE-404C-B392-4AA0921E2543}"
20+
EndProject
21+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "transitory-documents-client", "transitory-documents-client\transitory-documents-client.csproj", "{2A5C851A-91D9-412F-8D70-A419FE8FD990}"
22+
EndProject
23+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "core", "core\core.csproj", "{EA5798DF-7387-488B-A79F-5008031A2F22}"
24+
EndProject
25+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "models", "models\models.csproj", "{A4E730B4-88A7-4F22-B4F4-D60820C4A686}"
26+
EndProject
27+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4C3B75C2-DF8E-4603-A97B-7C7D6D3B0DD8}"
28+
ProjectSection(SolutionItems) = preProject
29+
.editorconfig = .editorconfig
30+
EndProjectSection
31+
EndProject
1932
Global
2033
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2134
Debug|Any CPU = Debug|Any CPU
@@ -50,6 +63,22 @@ Global
5063
{3FE50416-F9ED-591F-1B5F-DBFD49311713}.Debug|Any CPU.Build.0 = Debug|Any CPU
5164
{3FE50416-F9ED-591F-1B5F-DBFD49311713}.Release|Any CPU.ActiveCfg = Release|Any CPU
5265
{3FE50416-F9ED-591F-1B5F-DBFD49311713}.Release|Any CPU.Build.0 = Release|Any CPU
66+
{69C5DC46-ACCE-404C-B392-4AA0921E2543}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
67+
{69C5DC46-ACCE-404C-B392-4AA0921E2543}.Debug|Any CPU.Build.0 = Debug|Any CPU
68+
{69C5DC46-ACCE-404C-B392-4AA0921E2543}.Release|Any CPU.ActiveCfg = Release|Any CPU
69+
{69C5DC46-ACCE-404C-B392-4AA0921E2543}.Release|Any CPU.Build.0 = Release|Any CPU
70+
{2A5C851A-91D9-412F-8D70-A419FE8FD990}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
71+
{2A5C851A-91D9-412F-8D70-A419FE8FD990}.Debug|Any CPU.Build.0 = Debug|Any CPU
72+
{2A5C851A-91D9-412F-8D70-A419FE8FD990}.Release|Any CPU.ActiveCfg = Release|Any CPU
73+
{2A5C851A-91D9-412F-8D70-A419FE8FD990}.Release|Any CPU.Build.0 = Release|Any CPU
74+
{EA5798DF-7387-488B-A79F-5008031A2F22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
75+
{EA5798DF-7387-488B-A79F-5008031A2F22}.Debug|Any CPU.Build.0 = Debug|Any CPU
76+
{EA5798DF-7387-488B-A79F-5008031A2F22}.Release|Any CPU.ActiveCfg = Release|Any CPU
77+
{EA5798DF-7387-488B-A79F-5008031A2F22}.Release|Any CPU.Build.0 = Release|Any CPU
78+
{A4E730B4-88A7-4F22-B4F4-D60820C4A686}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
79+
{A4E730B4-88A7-4F22-B4F4-D60820C4A686}.Debug|Any CPU.Build.0 = Debug|Any CPU
80+
{A4E730B4-88A7-4F22-B4F4-D60820C4A686}.Release|Any CPU.ActiveCfg = Release|Any CPU
81+
{A4E730B4-88A7-4F22-B4F4-D60820C4A686}.Release|Any CPU.Build.0 = Release|Any CPU
5382
EndGlobalSection
5483
GlobalSection(SolutionProperties) = preSolution
5584
HideSolutionNode = FALSE

api/Controllers/AccessControlManagementControllerBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
using FluentValidation;
44
using Microsoft.AspNetCore.Mvc;
55
using MongoDB.Bson;
6-
using Scv.Api.Models;
76
using Scv.Api.Services;
7+
using Scv.Models;
88

99
namespace Scv.Api.Controllers;
1010

api/Controllers/ApplicationController.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
using System.Reflection;
2-
using System.Linq;
2+
using System.Threading.Tasks;
33
using Microsoft.AspNetCore.Authorization;
44
using Microsoft.AspNetCore.Http;
55
using Microsoft.AspNetCore.Mvc;
66
using Microsoft.Extensions.Configuration;
7-
using Scv.Api.Helpers;
87
using Scv.Api.Infrastructure.Authorization;
98
using Scv.Api.Services;
10-
using System.Threading.Tasks;
9+
using Scv.Core.Helpers.Extensions;
1110

1211
namespace Scv.Api.Controllers;
1312

@@ -40,4 +39,4 @@ public async Task<IActionResult> GetApplicationInfo()
4039
Configuration = dbConfig,
4140
});
4241
}
43-
}
42+
}

api/Controllers/AuthController.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
using Microsoft.AspNetCore.Authorization;
88
using Microsoft.AspNetCore.Mvc;
99
using Microsoft.Extensions.Configuration;
10-
using Scv.Api.Helpers;
11-
using Scv.Api.Helpers.Extensions;
1210
using Scv.Api.Infrastructure.Authorization;
1311
using Scv.Api.Infrastructure.Encryption;
14-
using Scv.Api.Models.auth;
12+
using Scv.Core.Helpers;
13+
using Scv.Core.Helpers.Extensions;
1514
using Scv.Db.Models;
1615
using Scv.Db.Models.Auth;
16+
using Scv.Models.auth;
1717

1818
namespace Scv.Api.Controllers
1919
{
@@ -46,8 +46,8 @@ public async Task<IActionResult> Logout()
4646

4747
var logoutUrl = $"{Configuration.GetNonEmptyValue("Keycloak:Authority")}/protocol/openid-connect/logout";
4848

49-
var forwardedHost = HttpContext.Request.Headers.ContainsKey("X-Forwarded-Host")
50-
? HttpContext.Request.Headers["X-Forwarded-Host"].ToString()
49+
var forwardedHost = HttpContext.Request.Headers.TryGetValue("X-Forwarded-Host", out Microsoft.Extensions.Primitives.StringValues value)
50+
? value.ToString()
5151
: Request.Host.ToString();
5252
var forwardedPort = HttpContext.Request.Headers["X-Forwarded-Port"];
5353

0 commit comments

Comments
 (0)