Skip to content

feat: Idempotency for MessageCommands (#92) #64

feat: Idempotency for MessageCommands (#92)

feat: Idempotency for MessageCommands (#92) #64

# Copyright 2020 Energinet DataHub A/S
#
# Licensed under the Apache License, Version 2.0 (the "License2");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Publish ProcessManager NuGet bundle(s)
# DESCRIPTION:
#
# - ProcessManager.Client depends on ProcessManager.Abstractions
# - ProcessManager.Orchestrations.Abstractions depends on ProcessManager.Abstractions
#
# To ensure the version of ProcessManager.Abstractions is the same for both when changed
# in the same PR, we must build all using the same workflow.
#
# We consider ProcessManager.Client and ProcessManager.Abstractions as a bundle, which means
# they must use the same version numbers. ProcessManager.Orchestrations.Abstractions is
# considered its own bundle and can be versioned in isolation.
#
# If ProcessManager.Abstractions has changed then both its consumers must have their
# versions updated.
on:
# Build, test, pack and publish release packages
# Only executed if any NuGet packages content or build scripts has changed;
# not if solution file, documentation or tests has changed
push:
branches:
- main
paths:
- source/ProcessManager.Client/**
- source/ProcessManager.Abstractions/**
- source/ProcessManager.Orchestrations.Abstractions/**
- .github/workflows/processmanager-client-bundle-publish.yml
# Build, test, pack
# Executed if any NuGet package folder or build scripts has changed;
# including if documentation or tests has changed
workflow_call: {}
# Build, test, pack and publish prerelease packages
# Executed if manually triggered
workflow_dispatch: {}
env:
# Conditions
# TRIGGERED_BY_PR_COMMIT is true if this run is automatically triggered by a commit in a Pull Request (feature branch)
TRIGGERED_BY_PR_COMMIT: ${{ github.event_name == 'pull_request' }}
# BASE_SHA must be set to 'main' if this run is triggered manually; otherwise file changes will not be detected correctly
BASE_SHA: ${{ (github.event_name == 'workflow_dispatch') && 'main' || '' }}
# Necessary to manage Azure resources from automated tests
AZURE_KEYVAULT_URL: ${{ vars.integration_test_azure_keyvault_url }}
# Set value used by 'AzuriteManager'
# Use 'AzuriteBlobFolderPath' for TestCommon version 4.2.0 and lower
AzuriteBlobFolderPath: ${{ github.workspace }}\node_modules\.bin\
# Use 'AzuriteFolderPath' for TestCommon version 4.3.0 and higher
AzuriteFolderPath: ${{ github.workspace }}\node_modules\.bin\
# Overrides settings in 'functionhost.settings.json'
FunctionAppHostPath: ${{ github.workspace }}\node_modules\azure-functions-core-tools\bin\func.dll
jobs:
build_and_publish:
runs-on: windows-2022
name: Publish bundle to NuGet.org
environment: AzureAuth
# We need to have permissions here to be able to support manually triggering this workflow for releasing a pre-release.
permissions:
id-token: write # Needed by 'dotnet-solution-build-and-test' to login to Azure
contents: read # Needed by https://github.com/EnricoMi/publish-unit-test-result-action
issues: read # Needed by https://github.com/EnricoMi/publish-unit-test-result-action
checks: write # Needed by https://github.com/EnricoMi/publish-unit-test-result-action
pull-requests: write # Needed by https://github.com/EnricoMi/publish-unit-test-result-action
steps:
- name: Checkout repository
uses: Energinet-DataHub/.github/.github/actions/nuget-checkout-repository@v14
- name: Setup dotnet and tools
uses: Energinet-DataHub/.github/.github/actions/dotnet-setup-and-tools@v14
with:
use_azure_functions_tools: "true"
azure_functions_core_tools_version: 4.0.5455
- name: Build and test solution
uses: Energinet-DataHub/.github/.github/actions/dotnet-solution-build-and-test@v14
with:
solution_file_path: ./source/ProcessManager.NuGet.Filtered.slnf
azure_tenant_id: ${{ vars.integration_test_azure_tenant_id }}
azure_subscription_id: ${{ vars.integration_test_azure_subscription_id }}
azure_spn_id: ${{ vars.integration_test_azure_spn_id_oidc }}
publish_test_report: "true"
- name: Pack ProcessManager.Client project
uses: Energinet-DataHub/.github/.github/actions/nuget-project-pack@v14
with:
project_path: ./source/ProcessManager.Client/ProcessManager.Client.csproj
- name: Pack ProcessManager.Abstractions project
uses: Energinet-DataHub/.github/.github/actions/nuget-project-pack@v14
with:
project_path: ./source/ProcessManager.Abstractions/ProcessManager.Abstractions.csproj
- name: Pack ProcessManager.Orchestrations.Abstractions project
uses: Energinet-DataHub/.github/.github/actions/nuget-project-pack@v14
with:
project_path: ./source/ProcessManager.Orchestrations.Abstractions/ProcessManager.Orchestrations.Abstractions.csproj
- name: Package content or build has changed for PM.Client or PM.Abstractions
id: changed-content-client
uses: tj-actions/changed-files@v45
with:
base_sha: ${{ env.BASE_SHA }}
files: |
source/ProcessManager.Client/**/*.*
source/ProcessManager.Abstractions/**/*.*
.github/workflows/processmanager-client-bundle-publish.yml
- name: List all changed files for PM.Client or PM.Abstractions
env:
ALL_CHANGED_FILES: ${{ steps.changed-content-client.outputs.all_changed_files }}
shell: bash
run: |
for file in "$ALL_CHANGED_FILES"; do
echo "$file was changed"
done
- name: Assert version of ProcessManager.Client NuGet package and push it to NuGet.org
uses: Energinet-DataHub/.github/.github/actions/nuget-packages-assert-and-push@v14
with:
push_packages: ${{ env.TRIGGERED_BY_PR_COMMIT == 'false' && steps.changed-content-client.outputs.any_changed == 'true' }}
content_changed: ${{ steps.changed-content-client.outputs.any_changed }}
nuget_token: ${{ secrets.nuget_token }}
nupkg_recurse_path: source/ProcessManager.Client
- name: Assert version of ProcessManager.Abstractions NuGet package and push it to NuGet.org
uses: Energinet-DataHub/.github/.github/actions/nuget-packages-assert-and-push@v14
with:
push_packages: ${{ env.TRIGGERED_BY_PR_COMMIT == 'false' && steps.changed-content-client.outputs.any_changed == 'true' }}
content_changed: ${{ steps.changed-content-client.outputs.any_changed }}
nuget_token: ${{ secrets.nuget_token }}
nupkg_recurse_path: source/ProcessManager.Abstractions
# NOTICE:
# If dependency ProcessManager.Abstractions has changed then we enforce a publish as if the
# ProcessManager.Orchestrations.Abstractions has changed, because we want to ensure the
# version of ProcessManager.Orchestrations.Abstractions is bumped.
- name: Package content, dependencies or build has changed for PM.Abstractions or PM.Orchestrations.Abstractions
id: changed-content-orchestrations
uses: tj-actions/changed-files@v45
with:
base_sha: ${{ env.BASE_SHA }}
files: |
source/ProcessManager.Orchestrations.Abstractions/**/*.*
source/ProcessManager.Abstractions/**/*.*
.github/workflows/processmanager-client-bundle-publish.yml
- name: List all changed files for PM.Abstractions or PM.Orchestrations.Abstractions
env:
ALL_CHANGED_FILES: ${{ steps.changed-content-orchestrations.outputs.all_changed_files }}
shell: bash
run: |
for file in "$ALL_CHANGED_FILES"; do
echo "$file was changed"
done
- name: Assert version of ProcessManager.Orchestrations.Abstractions NuGet package and push it to NuGet.org
uses: Energinet-DataHub/.github/.github/actions/nuget-packages-assert-and-push@v14
with:
push_packages: ${{ env.TRIGGERED_BY_PR_COMMIT == 'false' && steps.changed-content-orchestrations.outputs.any_changed == 'true' }}
content_changed: ${{ steps.changed-content-orchestrations.outputs.any_changed }}
nuget_token: ${{ secrets.nuget_token }}
nupkg_recurse_path: source/ProcessManager.Orchestrations.Abstractions