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: Create Dialogporten Serviceowner client library #1513

Open
wants to merge 68 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
d33461f
Squash
Fargekritt Nov 7, 2024
afa5316
Workflow test
Fargekritt Nov 25, 2024
d4b96db
Workflow
Fargekritt Nov 25, 2024
64db1f9
Workflow
Fargekritt Nov 25, 2024
cbd3e76
Workflow test
Fargekritt Nov 25, 2024
3689808
Workflow
Fargekritt Nov 25, 2024
7f17006
Nuget push workflow!
Fargekritt Nov 25, 2024
324cf3f
OI
Fargekritt Nov 25, 2024
288175c
Changed file test
Fargekritt Nov 25, 2024
e538c94
Update
Fargekritt Nov 25, 2024
7135268
Upd
Fargekritt Nov 25, 2024
2b9238b
up
Fargekritt Nov 25, 2024
a6e66b5
List all changes
Fargekritt Nov 26, 2024
eb590e1
hm
Fargekritt Nov 26, 2024
b499151
no da
Fargekritt Nov 26, 2024
f8691de
changes
Fargekritt Nov 26, 2024
ed42f73
testing again
Fargekritt Nov 26, 2024
2f613c0
oioi
Fargekritt Nov 26, 2024
71aefc8
no da!
Fargekritt Nov 26, 2024
1fb84e6
Added comments
Fargekritt Nov 26, 2024
60571b6
Workflow testing
Fargekritt Nov 27, 2024
2640a4b
funk
Fargekritt Nov 27, 2024
1f3c8b3
no da
Fargekritt Nov 27, 2024
76b5964
hm
Fargekritt Nov 27, 2024
d3062a2
no da
Fargekritt Nov 27, 2024
b09f6d4
oioi
Fargekritt Nov 27, 2024
fd8907e
Workflow maybe done
Fargekritt Nov 28, 2024
41a2eb5
Comment
Fargekritt Nov 28, 2024
1bdca4d
.NET9 adds its own base64URL, can remove the custom one
Fargekritt Nov 28, 2024
1b7f5a7
Cleaned up test
Fargekritt Nov 28, 2024
c4f5daf
Workflow test
Fargekritt Nov 28, 2024
56a5ebe
no
Fargekritt Nov 28, 2024
af4f6a3
Big finding out
Fargekritt Nov 28, 2024
708b09e
hm
Fargekritt Nov 28, 2024
4a15f4a
Clean up
Fargekritt Nov 28, 2024
3849c42
Arg
Fargekritt Nov 28, 2024
0894c17
hmm
Fargekritt Nov 28, 2024
329e8eb
Updated README.md
Fargekritt Nov 28, 2024
f46deb3
Merge branch 'main' into feat/add-WepApiClient-project
Fargekritt Nov 28, 2024
2a15b37
Clean up
Fargekritt Nov 29, 2024
431cc85
Workflow cleanup
Fargekritt Nov 29, 2024
4def26a
README updated
Fargekritt Nov 29, 2024
ff1d0f8
Created Basic test structure
Fargekritt Dec 5, 2024
347d729
Added more tests. Now test Create, Path, Get, and Purge
Fargekritt Dec 5, 2024
cdee031
Test fixture
Fargekritt Dec 6, 2024
d75e113
Removed generated file from test proj to not make conflicts
Fargekritt Dec 6, 2024
054c9ce
Updated how base url is set
Fargekritt Dec 6, 2024
b85b008
Created SearchTest
Fargekritt Dec 6, 2024
457e9b7
Created Get test
Fargekritt Dec 6, 2024
81df398
Updated tests to use local nuget
Fargekritt Dec 10, 2024
020e538
Merge branch 'main' into feat/add-WepApiClient-project
Fargekritt Dec 10, 2024
bf88cdc
Created UpdateTest
Fargekritt Dec 11, 2024
aac7bfa
Added deleteTest
Fargekritt Dec 11, 2024
21c9e87
Test refactor
Fargekritt Dec 11, 2024
4655774
Search multiple test
Fargekritt Dec 12, 2024
40f54fe
Multiple dialog search, and Invalid Patch test
Fargekritt Dec 12, 2024
0c663ee
Invalid Update test
Fargekritt Dec 12, 2024
5a3c578
Merge branch 'main' into feat/add-WepApiClient-project
Fargekritt Dec 12, 2024
a08e486
Updated tests
Fargekritt Dec 13, 2024
e71db25
Cleanup
Fargekritt Dec 13, 2024
b96fb3b
Merge branch 'main' into feat/add-WepApiClient-project
Fargekritt Dec 13, 2024
a82f91d
Updated tests
Fargekritt Dec 13, 2024
aba1aec
Cleanup
Fargekritt Dec 13, 2024
2d5dd74
Merge branch 'main' into feat/add-WepApiClient-project
Fargekritt Dec 13, 2024
075854b
Comments
Fargekritt Dec 13, 2024
b952394
Update src/Digdir.Library.Dialogporten.WebApiClient/Config/Maskinport…
Fargekritt Dec 13, 2024
9fd4304
Clean up
Fargekritt Dec 13, 2024
8d6b5c0
Merge remote-tracking branch 'origin/feat/add-WepApiClient-project' i…
Fargekritt Dec 13, 2024
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
17 changes: 8 additions & 9 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,23 +18,23 @@ 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"

dry-run-deploy-infra:
name: Dry run deploy infrastructure
uses: ./.github/workflows/workflow-deploy-infra.yml
Expand Down Expand Up @@ -93,7 +92,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_KEY: ${{ secrets.NUGET_API_TEST_KEY }}
Comment on lines +96 to +104
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve robustness of project file path resolution

The current implementation has several potential issues:

  1. The $(find ...) command is embedded in the path parameter and uses shell syntax that might not work consistently in GitHub Actions
  2. The pattern could match multiple files if there are test projects with similar names

Consider using a dedicated step to find the project file:

  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' }}
+   run: |
+     PROJECT_PATH=$(find . -name "Digdir.Library.Dialogporten.WebApiClient.csproj" -not -path "*/test/*" -print -quit)
+     echo "PROJECT_PATH=$PROJECT_PATH" >> $GITHUB_ENV
    with:
      version: ${{ needs.get-current-version.outputs.version }}
-     path: $(find . -name '*Digdir.Library.Dialogporten.WebApiClient.csproj' -printf "%p"  -quit)
+     path: ${{ env.PROJECT_PATH }}
    secrets:
      NUGET_API_KEY: ${{ secrets.NUGET_API_TEST_KEY }}

This approach:

  1. Uses a dedicated step for path resolution
  2. Excludes test projects using -not -path "*/test/*"
  3. Stores the result in an environment variable
  4. Fails fast if the project file is not found

Committable suggestion skipped: line range outside the PR's diff.


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: "Nuget Source"
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

Comment on lines +30 to +34
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix shell script quoting

The PROJECT variable assignment needs proper quoting to handle paths with spaces.

-          PROJECT=${{inputs.path}}
+          PROJECT="${{inputs.path}}"
           echo "PROJECT ${PROJECT}"
-          echo "PROJECT=${PROJECT}" >> $GITHUB_ENV
+          echo "PROJECT=${PROJECT}" >> "$GITHUB_ENV"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
run: |
PROJECT=${{inputs.path}}
echo "PROJECT ${PROJECT}"
echo "PROJECT=${PROJECT}" >> $GITHUB_ENV
run: |
PROJECT="${{inputs.path}}"
echo "PROJECT ${PROJECT}"
echo "PROJECT=${PROJECT}" >> "$GITHUB_ENV"
🧰 Tools
🪛 actionlint (1.7.4)

30-30: shellcheck reported issue in this script: SC2086:info:3:30: Double quote to prevent globbing and word splitting

(shellcheck)

- 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}
Comment on lines +41 to +44
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix command argument quoting

The project path needs proper quoting in dotnet commands.

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

-        run: dotnet pack --configuration Release /p:Version=${{ inputs.version }} -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output . ${PROJECT}
+        run: dotnet pack --configuration Release /p:Version="${{ inputs.version }}" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output . "${PROJECT}"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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}
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}"
🧰 Tools
🪛 actionlint (1.7.4)

41-41: shellcheck reported issue in this script: SC2086:info:1:71: Double quote to prevent globbing and word splitting

(shellcheck)


44-44: shellcheck reported issue in this script: SC2086:info:1:134: Double quote to prevent globbing and word splitting

(shellcheck)


- 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}}

Comment on lines +60 to +62
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix NuGet push command and remove trailing whitespace

The NuGet push command needs proper globbing and the file has trailing whitespace.

-      - name: Push to NuGet
-        run: dotnet nuget push *.nupkg --source ${{ inputs.source }} --api-key ${{secrets.NUGET_API_KEY}}
-        
+      - name: Push to NuGet
+        run: dotnet nuget push "./*.nupkg" --source "${{ inputs.source }}" --api-key "${{secrets.NUGET_API_KEY}}"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Push to NuGet
run: dotnet nuget push *.nupkg --source ${{ inputs.source }} --api-key ${{secrets.NUGET_API_KEY}}
- name: Push to NuGet
run: dotnet nuget push "./*.nupkg" --source "${{ inputs.source }}" --api-key "${{secrets.NUGET_API_KEY}}"
🧰 Tools
🪛 actionlint (1.7.4)

61-61: shellcheck reported issue in this script: SC2035:info:1:19: Use ./glob or -- glob so names with dashes won't become options

(shellcheck)

🪛 yamllint (1.35.1)

[error] 62-62: trailing spaces

(trailing-spaces)

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
2 changes: 1 addition & 1 deletion docs/schema/V1/swagger.verified.json
Original file line number Diff line number Diff line change
Expand Up @@ -6970,4 +6970,4 @@
"url": "https://altinn-dev-api.azure-api.net/dialogporten"
}
]
}
}
24 changes: 24 additions & 0 deletions src/Digdir.Library.Dialogporten.WebApiClient.Sample/Dialogs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Digdir.Library.Dialogporten.WebApiClient.Features.V1;
using Refit;

namespace Digdir.Library.Dialogporten.WebApiClient.Sample;

public sealed class Dialogs(IServiceownerApi client)
{
public async Task<IApiResponse> Purge(Guid dialogId, Guid? ifMatch = null)
{
var response = await client.V1ServiceOwnerDialogsPurgePurgeDialog(dialogId, ifMatch);
Console.WriteLine($"Purge response status code: {response.StatusCode}");
Console.WriteLine($"Purge Response: {response.StatusCode}");
return response;
}
Comment on lines +8 to +14
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve error handling and logging in Purge method.

The current implementation has several issues:

  1. Duplicate status code logging
  2. No error handling for API calls
  3. Direct console logging in a library method
 public async Task<IApiResponse> Purge(Guid dialogId, Guid? ifMatch = null)
 {
+    try
+    {
         var response = await client.V1ServiceOwnerDialogsPurgePurgeDialog(dialogId, ifMatch);
-        Console.WriteLine($"Purge response status code: {response.StatusCode}");
-        Console.WriteLine($"Purge Response: {response.StatusCode}");
+        if (!response.IsSuccessStatusCode)
+        {
+            throw new DialogportenApiException($"Failed to purge dialog {dialogId}. Status: {response.StatusCode}", response);
+        }
         return response;
+    }
+    catch (ApiException ex)
+    {
+        throw new DialogportenApiException($"API error while purging dialog {dialogId}", ex);
+    }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public async Task<IApiResponse> Purge(Guid dialogId, Guid? ifMatch = null)
{
var response = await client.V1ServiceOwnerDialogsPurgePurgeDialog(dialogId, ifMatch);
Console.WriteLine($"Purge response status code: {response.StatusCode}");
Console.WriteLine($"Purge Response: {response.StatusCode}");
return response;
}
public async Task<IApiResponse> Purge(Guid dialogId, Guid? ifMatch = null)
{
try
{
var response = await client.V1ServiceOwnerDialogsPurgePurgeDialog(dialogId, ifMatch);
if (!response.IsSuccessStatusCode)
{
throw new DialogportenApiException($"Failed to purge dialog {dialogId}. Status: {response.StatusCode}", response);
}
return response;
}
catch (ApiException ex)
{
throw new DialogportenApiException($"API error while purging dialog {dialogId}", ex);
}
}


public static void PrintGetDialog(V1ServiceOwnerDialogsQueriesGet_Dialog dialog)
{
Console.WriteLine($"System Label: {dialog.SystemLabel}");
Console.WriteLine($"Dialog Status: {dialog.Status}");
Console.WriteLine($"Dialog Org: {dialog.Org}");
Console.WriteLine($"Dialog Progress: {dialog.Progress}");
Console.WriteLine($"Deleted at: {dialog.DeletedAt}");
}
}
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