Skip to content
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

Feat/add wep api client project #1513

Draft
wants to merge 39 commits into
base: main
Choose a base branch
from
Draft
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
22 changes: 16 additions & 6 deletions .github/workflows/ci-cd-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
on:
workflow_dispatch:
push:
branches: [main]
branches: [ main ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
Expand Down Expand Up @@ -40,7 +40,7 @@ jobs:
build-and-test:
name: Build and test backend
uses: ./.github/workflows/workflow-build-and-test.yml
needs: [check-for-changes]
needs: [ check-for-changes ]
if: ${{ github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasBackendChanges == 'true' || needs.check-for-changes.outputs.hasTestChanges == 'true' }}

publish:
Expand All @@ -62,7 +62,7 @@ jobs:

deploy-infra:
name: Deploy infra to test
needs: [get-current-version, check-for-changes, generate-git-short-sha]
needs: [ get-current-version, check-for-changes, generate-git-short-sha ]
if: ${{ github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasInfraChanges == 'true' }}
uses: ./.github/workflows/workflow-deploy-infra.yml
secrets:
Expand Down Expand Up @@ -108,9 +108,19 @@ jobs:
version: ${{ needs.get-current-version.outputs.version }}-${{ needs.generate-git-short-sha.outputs.gitShortSha }}
runMigration: ${{ github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasMigrationChanges == 'true' }}

publish-sdk-to-nuget:
uses: ./.github/workflows/workflow-publish-nuget.yml
needs: [ get-current-version, generate-git-short-sha, check-for-changes ]
if: ${{ needs.check-for-changes.outputs.hasBackendChanges == 'true' || needs.check-for-changes.outputs.hasTestChanges == 'true' }}
with:
version: ${{ needs.get-current-version.outputs.version }}-rc.${{ needs.generate-git-short-sha.outputs.gitShortSha }}
path: $(find . -name '*Digdir.Library.Dialogporten.WebApiClient.csproj' -printf "%p" -quit)
secrets:
NUGET_API_KEY: ${{ secrets.NUGET_API_TEST_KEY }}

deploy-slack-notifier:
name: Deploy slack notifier (test)
needs: [check-for-changes]
needs: [ check-for-changes ]
if: ${{ github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasSlackNotifierChanges == 'true' }}
uses: ./.github/workflows/workflow-deploy-function.yml
secrets:
Expand All @@ -126,7 +136,7 @@ jobs:

publish-schema-npm:
name: Deploy schema npm package
needs: [check-for-changes, get-current-version, generate-git-short-sha, deploy-apps]
needs: [ check-for-changes, get-current-version, generate-git-short-sha, deploy-apps ]
if: ${{ always() && !failure() && !cancelled() && (github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasSchemaChanges == 'true') }}
uses: ./.github/workflows/workflow-publish-schema.yml
with:
Expand All @@ -138,7 +148,7 @@ jobs:
name: "Run K6 functional end-to-end tests"
# we want the end-to-end tests to be dependent on deployment of infrastructure and apps, but if infrastructure is skipped, we still want to run the tests
if: ${{ always() && !failure() && !cancelled() && (github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasBackendChanges == 'true' || needs.check-for-changes.outputs.hasTestChanges == 'true') }}
needs: [deploy-apps, check-for-changes]
needs: [ deploy-apps, check-for-changes ]
uses: ./.github/workflows/workflow-run-k6-tests.yml
secrets:
TOKEN_GENERATOR_USERNAME: ${{ secrets.TOKEN_GENERATOR_USERNAME }}
Expand Down
26 changes: 18 additions & 8 deletions .github/workflows/ci-cd-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

on:
pull_request:
branches: [main]
branches: [ main ]
paths-ignore:
- "tests/k6/**"
- "CHANGELOG.md"

jobs:
generate-git-short-sha:
Expand All @@ -19,22 +18,33 @@ jobs:
check-for-changes:
name: Check for changes
uses: ./.github/workflows/workflow-check-for-changes.yml

build:
uses: ./.github/workflows/workflow-build-and-test.yml
needs: [check-for-changes]
needs: [ check-for-changes ]
if: ${{ needs.check-for-changes.outputs.hasBackendChanges == 'true' || needs.check-for-changes.outputs.hasTestChanges == 'true' }}

build-infrastructure:
uses: ./.github/workflows/workflow-build-infrastructure.yml
needs: [check-for-changes]
needs: [ check-for-changes ]
if: ${{ always() && needs.check-for-changes.outputs.hasInfraChanges == 'true' }}
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
with:
environment: "test"

# TESTING AV NUGET SKAL IKKE SKJØRES I PULL REQUEST
publish-sdk-to-nuget:
uses: ./.github/workflows/workflow-publish-nuget.yml
needs: [ get-current-version, generate-git-short-sha, check-for-changes ]
if: ${{ needs.check-for-changes.outputs.hasBackendChanges == 'true' || needs.check-for-changes.outputs.hasTestChanges == 'true' }}
with:
version: ${{ needs.get-current-version.outputs.version }}-rc.${{ needs.generate-git-short-sha.outputs.gitShortSha }}
path: $(find . -name '*Digdir.Library.Dialogporten.WebApiClient.csproj' -printf "%p" -quit)
secrets:
NUGET_API_KEY: ${{ secrets.NUGET_API_TEST_KEY }}

dry-run-deploy-infra:
name: Dry run deploy infrastructure
Expand Down Expand Up @@ -93,7 +103,7 @@ jobs:
delete-github-deployments:
name: Delete GitHub deployments
uses: ./.github/workflows/workflow-delete-deployments.yml
needs: [dry-run-deploy-apps, dry-run-deploy-infra]
needs: [ dry-run-deploy-apps, dry-run-deploy-infra ]
if: ${{ always() && !failure() && !cancelled() }}
with:
gitSha: ${{ github.event.pull_request.head.sha }}
gitSha: ${{ github.event.pull_request.head.sha }}
30 changes: 20 additions & 10 deletions .github/workflows/ci-cd-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

check-for-changes:
name: Check for changes
needs: [get-versions-from-github]
needs: [ get-versions-from-github ]
uses: ./.github/workflows/workflow-check-for-changes.yml
with:
infra_base_sha: ${{ needs.get-versions-from-github.outputs.infra_version_sha }}
Expand All @@ -33,7 +33,7 @@ jobs:
deploy-infra:
name: Deploy infra to staging
if: ${{ github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasInfraChanges == 'true' }}
needs: [get-current-version, check-for-changes]
needs: [ get-current-version, check-for-changes ]
uses: ./.github/workflows/workflow-deploy-infra.yml
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
Expand All @@ -50,7 +50,7 @@ jobs:

store-infra-version:
name: Store Latest Deployed Infra Version as GitHub Variable
needs: [deploy-infra, get-current-version]
needs: [ deploy-infra, get-current-version ]
if: ${{ needs.deploy-infra.result == 'success' }}
uses: ./.github/workflows/workflow-store-github-env-variable.yml
with:
Expand All @@ -64,7 +64,7 @@ jobs:
name: Build and publish docker images
uses: ./.github/workflows/workflow-publish.yml
if: ${{ github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasBackendChanges == 'true' }}
needs: [get-current-version, check-for-changes]
needs: [ get-current-version, check-for-changes ]
secrets:
GCR_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -74,7 +74,7 @@ jobs:
deploy-apps:
name: Deploy apps to staging
needs:
[get-current-version, check-for-changes, deploy-infra, publish]
[ get-current-version, check-for-changes, deploy-infra, publish ]
if: ${{ always() && !failure() && !cancelled() && (github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasBackendChanges == 'true') }}
uses: ./.github/workflows/workflow-deploy-apps.yml
secrets:
Expand All @@ -93,9 +93,19 @@ jobs:
version: ${{ needs.get-current-version.outputs.version }}
runMigration: ${{ github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasMigrationChanges == 'true' }}

publish-sdk-to-nuget:
uses: ./.github/workflows/workflow-publish-nuget.yml
needs: [ get-current-version, check-for-changes ]
if: ${{ needs.check-for-changes.outputs.hasBackendChanges == 'true' || needs.check-for-changes.outputs.hasTestChanges == 'true' }}
with:
version: ${{ needs.get-current-version.outputs.version }}
path: $(find . -name '*Digdir.Library.Dialogporten.WebApiClient.csproj' -printf "%p" -quit)
secrets:
NUGET_API_TEST_KEY: ${{ secrets.NUGET_API_TEST_KEY }}

store-apps-version:
name: Store Latest Deployed Apps Version as GitHub Variable
needs: [deploy-apps, get-current-version]
needs: [ deploy-apps, get-current-version ]
if: ${{ always() && !failure() && !cancelled() && (github.event_name == 'workflow_dispatch' || needs.deploy-apps.outputs.deployment_executed == 'true') }}
uses: ./.github/workflows/workflow-store-github-env-variable.yml
with:
Expand All @@ -107,7 +117,7 @@ jobs:

deploy-slack-notifier:
name: Deploy slack notifier (staging)
needs: [check-for-changes]
needs: [ check-for-changes ]
if: ${{ github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasSlackNotifierChanges == 'true' }}
uses: ./.github/workflows/workflow-deploy-function.yml
secrets:
Expand All @@ -123,7 +133,7 @@ jobs:

publish-schema-npm:
name: Publish schema npm package
needs: [check-for-changes, get-current-version, deploy-apps]
needs: [ check-for-changes, get-current-version, deploy-apps ]
if: ${{ always() && !failure() && !cancelled() && (github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasSchemaChanges == 'true') }}
uses: ./.github/workflows/workflow-publish-schema.yml
with:
Expand All @@ -135,7 +145,7 @@ jobs:
name: "Run K6 functional end-to-end tests"
# we want the end-to-end tests to be dependent on deployment of infrastructure and apps, but if infrastructure is skipped, we still want to run the tests
if: ${{ always() && !failure() && !cancelled() && (github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasBackendChanges == 'true') }}
needs: [deploy-apps, check-for-changes]
needs: [ deploy-apps, check-for-changes ]
uses: ./.github/workflows/workflow-run-k6-tests.yml
secrets:
TOKEN_GENERATOR_USERNAME: ${{ secrets.TOKEN_GENERATOR_USERNAME }}
Expand All @@ -150,7 +160,7 @@ jobs:

send-slack-message-on-failure:
name: Send Slack message on failure
needs: [deploy-infra, deploy-apps, deploy-slack-notifier, run-e2e-tests, publish-schema-npm, publish]
needs: [ deploy-infra, deploy-apps, deploy-slack-notifier, run-e2e-tests, publish-schema-npm, publish ]
if: ${{ always() && failure() && !cancelled() }}
uses: ./.github/workflows/workflow-send-ci-cd-status-slack-message.yml
with:
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/workflow-publish-nuget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: "Publish nuget package"

on:
workflow_call:
inputs:
version:
description: "Version"
required: true
type: string
Fargekritt marked this conversation as resolved.
Show resolved Hide resolved
path:
description: "Path to project"
required: true
type: string
source:
description: "Source to push to"
required: false
type: string
default: https://int.nugettest.org
secrets:
NUGET_API_KEY:
required: true
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: set PROJECT variable to point to project
run: |
PROJECT=${{inputs.path}}
echo "PROJECT ${PROJECT}"
echo "PROJECT=${PROJECT}" >> $GITHUB_ENV

- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: ./global.json

- name: Build
run: dotnet build --configuration Release /p:Version=${{ inputs.version }} ${PROJECT}

- name: Pack with debug symbols
run: dotnet pack --configuration Release /p:Version=${{ inputs.version }} -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output . ${PROJECT}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: package
path: '*.*nupkg'
push:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: package

- name: Push to NuGet
run: dotnet nuget push *.nupkg --source ${{ inputs.source }} --api-key ${{secrets.NUGET_API_KEY}}

14 changes: 14 additions & 0 deletions .refitter
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kalle denne WebApiClient.refitter. e.l og så kan vi heller spesifisere den i refitter-commanden?

refitter ./openapi.json --settings-file ./WebApiClient.refitter elns

"openApiPath": "docs/schema/V1/swagger.verified.json",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blir refitter bare kalt kun en gang? Eller gjør vi det hver gang API endrer seg? Isåfall burde vi kanskje ha det som en del av bygg-steget? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

akkurat nå blir den generert av en test lignene swaggerSnapshot testen. men holder på å prøver meg litt frem for å finne en løsning

"namespace": "Digdir.Library.Dialogporten.WebApiClient.Features.V1",
"outputFolder": "src/Digdir.Library.Dialogporten.WebApiClient/Features/V1/",
"operationNameGenerator": "SingleClientFromOperationId",
"multipleInterfaces": "ByTag",
"includeTags": [

],
"useCancellationTokens": true,
"returnIApiResponse": true,
"useDynamicQuerystringParameters": true,
"outputFilename": "RefitterInterface.cs"
}
24 changes: 24 additions & 0 deletions Digdir.Domain.Dialogporten.sln
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Digdir.Library.Utils.AspNet
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Digdir.Tool.Dialogporten.SlackNotifier.Tests", "tests\Digdir.Tool.Dialogporten.SlackNotifier.Tests\Digdir.Tool.Dialogporten.SlackNotifier.Tests.csproj", "{F7DF2792-9C83-49F7-B7DD-556E8EC577DB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebApiClient", "WebApiClient", "{9B809C3A-B169-4599-A2D3-A25E87C510FC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Digdir.Library.Dialogporten.WebApiClient", "src\Digdir.Library.Dialogporten.WebApiClient\Digdir.Library.Dialogporten.WebApiClient.csproj", "{714FBB11-ADC0-44E8-A768-D1A59D641D31}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Digdir.Library.Dialogporten.WebApiClient.Sample", "src\Digdir.Library.Dialogporten.WebApiClient.Sample\Digdir.Library.Dialogporten.WebApiClient.Sample.csproj", "{F8CB7159-4346-4436-9C35-BFCFDDE5DC2B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Digdir.Library.Dialogporten.WebApiClient.Integration.Tests", "tests\Digdir.Library.Dialogporten.WebApiClient.Integration.Tests\Digdir.Library.Dialogporten.WebApiClient.Integration.Tests.csproj", "{7014AC47-0DF5-48C1-BD72-EE587FF3278B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -165,6 +173,18 @@ Global
{F7DF2792-9C83-49F7-B7DD-556E8EC577DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F7DF2792-9C83-49F7-B7DD-556E8EC577DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F7DF2792-9C83-49F7-B7DD-556E8EC577DB}.Release|Any CPU.Build.0 = Release|Any CPU
{714FBB11-ADC0-44E8-A768-D1A59D641D31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{714FBB11-ADC0-44E8-A768-D1A59D641D31}.Debug|Any CPU.Build.0 = Debug|Any CPU
{714FBB11-ADC0-44E8-A768-D1A59D641D31}.Release|Any CPU.ActiveCfg = Release|Any CPU
{714FBB11-ADC0-44E8-A768-D1A59D641D31}.Release|Any CPU.Build.0 = Release|Any CPU
{F8CB7159-4346-4436-9C35-BFCFDDE5DC2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F8CB7159-4346-4436-9C35-BFCFDDE5DC2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F8CB7159-4346-4436-9C35-BFCFDDE5DC2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F8CB7159-4346-4436-9C35-BFCFDDE5DC2B}.Release|Any CPU.Build.0 = Release|Any CPU
{7014AC47-0DF5-48C1-BD72-EE587FF3278B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7014AC47-0DF5-48C1-BD72-EE587FF3278B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7014AC47-0DF5-48C1-BD72-EE587FF3278B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7014AC47-0DF5-48C1-BD72-EE587FF3278B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -196,6 +216,10 @@ Global
{E389C7C8-9610-40AC-86DC-769B1B7DC78E} = {CADB8189-4AA1-4732-844A-C41DBF3EC8B7}
{6A485C65-3613-4A49-A16F-2789119F6F38} = {096E9B69-6783-4446-A895-0B6D7729A0D9}
{F7DF2792-9C83-49F7-B7DD-556E8EC577DB} = {CADB8189-4AA1-4732-844A-C41DBF3EC8B7}
{9B809C3A-B169-4599-A2D3-A25E87C510FC} = {096E9B69-6783-4446-A895-0B6D7729A0D9}
{714FBB11-ADC0-44E8-A768-D1A59D641D31} = {9B809C3A-B169-4599-A2D3-A25E87C510FC}
{F8CB7159-4346-4436-9C35-BFCFDDE5DC2B} = {9B809C3A-B169-4599-A2D3-A25E87C510FC}
{7014AC47-0DF5-48C1-BD72-EE587FF3278B} = {CADB8189-4AA1-4732-844A-C41DBF3EC8B7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B2FE67FF-7622-4AFB-AD8E-961B6A39D888}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Digdir.Library.Dialogporten.WebApiClient\Digdir.Library.Dialogporten.WebApiClient.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="appsettings.local.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Loading
Loading