Skip to content

Commit

Permalink
Merge pull request #1053 from US-Trustee-Program/CAMS-461-durable-fun…
Browse files Browse the repository at this point in the history
…ction

CAMS-461 Durable function for consolidation migration from ACMS
  • Loading branch information
jamesobrooks authored Dec 10, 2024
2 parents d9a1c44 + 55f95f6 commit e3b6fee
Show file tree
Hide file tree
Showing 305 changed files with 5,355 additions and 2,564 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/continuous-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ on:
- "false"
- "true"
enableBicepDeployment:
description: "enableBicepDeployment: Execute main.bicep deployment for application component Azure resources"
description:
"enableBicepDeployment: Execute main.bicep deployment for application component Azure
resources"
required: true
default: "false"
type: choice
Expand Down Expand Up @@ -88,7 +90,7 @@ jobs:
unit-test-backend:
uses: ./.github/workflows/reusable-unit-test.yml
with:
path: backend/functions
path: backend
node-version: ${{ vars.NODE_VERSION }}

unit-test-common:
Expand All @@ -109,12 +111,13 @@ jobs:
secrets: inherit # pragma: allowlist secret
with:
nodeVersion: ${{ vars.NODE_VERSION }}
apiName: ${{ needs.setup.outputs.apiName }}
camsServerHostname: ${{ needs.setup.outputs.apiName }}.azurewebsites${{ vars.AZ_HOSTNAME_SUFFIX }}
camsServerHostname: ${{ needs.setup.outputs.apiFunctionName }}.azurewebsites${{ vars.AZ_HOSTNAME_SUFFIX }}
camsServerPort: ${{ vars.CAMS_SERVER_PORT }}
camsServerProtocol: ${{ vars.CAMS_SERVER_PROTOCOL }}
camsBasePath: ${{ vars.CAMS_BASE_PATH }}
webappName: ${{ needs.setup.outputs.webappName }}
apiFunctionName: ${{ needs.setup.outputs.apiFunctionName }}
migrationFunctionName: ${{ needs.setup.outputs.migrationFunctionName }}
environment: ${{ needs.setup.outputs.ghaEnvironment }}
launchDarklyEnvironment: ${{ vars.CAMS_LAUNCH_DARKLY_ENV }}

Expand All @@ -131,13 +134,16 @@ jobs:
unit-test-backend,
unit-test-common,
]
if: ((github.ref == 'refs/heads/main') || (github.ref == 'refs/heads/dependency-updates-auto') || (inputs.deployBranch == 'true'))
if:
((github.ref == 'refs/heads/main') || (github.ref == 'refs/heads/dependency-updates-auto') ||
(inputs.deployBranch == 'true'))
with:
ghaEnvironment: ${{ needs.setup.outputs.ghaEnvironment }}
azResourceGrpAppEncrypted: ${{ needs.setup.outputs.azResourceGrpAppEncrypted }}
azResourceGrpNetworkEncrypted: ${{ needs.setup.outputs.azResourceGrpNetworkEncrypted }}
stackName: ${{ needs.setup.outputs.stackName }}
apiName: ${{ needs.setup.outputs.apiName }}
apiFunctionName: ${{ needs.setup.outputs.apiFunctionName }}
migrationFunctionName: ${{ needs.setup.outputs.migrationFunctionName }}
webAppName: ${{ needs.setup.outputs.webappName }}
environmentHash: ${{ needs.setup.outputs.environmentHash }}
execVnetDeploy: ${{ needs.setup.outputs.execVnetDeploy }}
Expand All @@ -154,7 +160,8 @@ jobs:
ghaEnvironment: ${{ needs.setup.outputs.ghaEnvironment }}
azResourceGrpAppEncrypted: ${{ needs.setup.outputs.azResourceGrpAppEncrypted }}
stackName: ${{ needs.setup.outputs.stackName }}
apiName: ${{ needs.setup.outputs.apiName }}
apiFunctionName: ${{ needs.setup.outputs.apiFunctionName }}
migrationFunctionName: ${{ needs.setup.outputs.migrationFunctionName }}
webAppName: ${{ needs.setup.outputs.webappName }}
environmentHash: ${{ needs.setup.outputs.environmentHash }}
slotName: ${{ needs.setup.outputs.slotName }}
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/reusable-backend-slot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ on:
webAppName:
required: true
type: string
apiName:
apiFunctionName:
required: true
type: string
migrationFunctionName:
required: true
type: string
ghaEnvironment:
Expand Down Expand Up @@ -51,16 +54,19 @@ jobs:

- name: Create API Slot Resource
run: |
slotStorageAccountName=ustpslot${{ inputs.environmentHash }}
migrationSlotStorageAccountName=ustpslot${{ inputs.environmentHash }}
apiSlotStorageAccountName=migrationslot${{ inputs.environmentHash }}
./ops/scripts/pipeline/slots/az-slot-api-resource-deploy.sh \
--resourceGroup ${{ steps.rgApp.outputs.out }} \
--idResourceGroup ${{ secrets.AZURE_RG }} \
--apiName ${{ inputs.apiName }} \
--apiFunctionName ${{ inputs.apiFunctionName }} \
--migrationFunctionName ${{ inputs.migrationFunctionName }} \
--webappName ${{ inputs.webappName }} \
--slotName ${{ inputs.slotName }} \
--kvIdName ${{ secrets.AZ_KV_APP_CONFIG_MANAGED_ID }} \
--sqlIdName ${{ secrets.AZ_SQL_IDENTITY_NAME }} \
--storageAccName ${slotStorageAccountName:0:24} \
--apiStorageAccName ${migrationSlotStorageAccountName:0:24} \
--migrationStorageAccName ${apiSlotStorageAccountName:0:24} \
--databaseName ${{ secrets.AZ_COSMOS_DATABASE_NAME }} \
--infoSha ${{ inputs.environmentHash || 'DOES_NOT_EXIST' }}
23 changes: 15 additions & 8 deletions .github/workflows/reusable-build-info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ on:
webappName:
description: "Expected Web Application name [used for Azure Resource]"
value: ${{ jobs.build-info.outputs.webappName }}
apiName:
apiFunctionName:
description: ""
value: ${{ jobs.build-info.outputs.apiName }}
value: ${{ jobs.build-info.outputs.apiFunctionName }}
azResourceGrpAppEncrypted:
description: ""
value: ${{ jobs.build-info.outputs.azResourceGrpAppEncrypted }}
Expand All @@ -31,6 +31,9 @@ on:
environmentHash:
description: ""
value: ${{ jobs.build-info.outputs.environmentHash }}
migrationFunctionName:
description: ""
value: ${{ jobs.build-info.outputs.migrationFunctionName }}
slotName:
description: ""
value: ${{ jobs.build-info.outputs.slotName }}
Expand All @@ -56,12 +59,13 @@ jobs:
outputs:
stackName: ${{ steps.build-info.outputs.stackName }}
webappName: ${{ steps.build-info.outputs.webappName }}
apiName: ${{ steps.build-info.outputs.apiName }}
apiFunctionName: ${{ steps.build-info.outputs.apiFunctionName }}
azResourceGrpAppEncrypted: ${{ steps.rgApp.outputs.out }}
azResourceGrpNetworkEncrypted: ${{ steps.rgNetwork.outputs.out }}
environmentHash: ${{ steps.check-env.outputs.environmentHash }}
execVnetDeploy: ${{ steps.build-info.outputs.execVnetDeploy }}
slotName: ${{ steps.build-info.outputs.slotName }}
migrationFunctionName: ${{ steps.build-info.outputs.migrationFunctionName }}
deployBicep: ${{ steps.check-bicep.outputs.deployBicep }}
initialDeployment: ${{ steps.check-initial-deployment.outputs.initialDeployment }}
steps:
Expand Down Expand Up @@ -101,9 +105,11 @@ jobs:
stackName=$(ops/scripts/pipeline/generate-stackname.sh ${{ inputs.environment }} ${{ vars.APP_NAME }} ${{ vars.DEV_SUFFIX }} ${{ github.ref_name }})
echo "Stack Name: $stackName"
webappName="${stackName}-webapp"
echo "Webapp Artifact: $webappName"
apiName="${stackName}-node-api"
echo "Api Artifact: $apiName"
echo "Webapp Name: $webappName"
apiFunctionName="${stackName}-node-api"
echo "Api Function Name: $apiFunctionName"
migrationFunctionName="${stackName}-migration"
echo "Migration Function Name: $migrationFunctionName"
# Deployment flags
echo "Bicep Deployment Flag: ${{ inputs.enableBicepDeployment == 'true' }}"
Expand All @@ -115,7 +121,8 @@ jobs:
echo "azResourceGrpNetwork=${{ secrets.AZ_NETWORK_RG }}${resourceGroupSuffix}" >> $GITHUB_OUTPUT
echo "stackName=${stackName}" >> $GITHUB_OUTPUT
echo "webappName=${webappName}" >> $GITHUB_OUTPUT
echo "apiName=${apiName}" >> $GITHUB_OUTPUT
echo "apiFunctionName=${apiFunctionName}" >> $GITHUB_OUTPUT
echo "migrationFunctionName=${migrationFunctionName}" >> $GITHUB_OUTPUT
echo "execVnetDeploy=${execVnetDeploy}" >> $GITHUB_OUTPUT
echo "slotName=${{ vars.SLOT_NAME }}" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -143,7 +150,7 @@ jobs:
- name: Check Initial Deployment
id: check-initial-deployment
run: |
initialDeployment=$(./ops/scripts/pipeline/check-for-environment.sh --resource-group ${{ steps.rgAppDecode.outputs.out }} --webappName ${{ steps.build-info.outputs.webappName }} --apiName ${{ steps.build-info.outputs.apiName }})
initialDeployment=$(./ops/scripts/pipeline/check-for-environment.sh --resource-group ${{ steps.rgAppDecode.outputs.out }} --webappName ${{ steps.build-info.outputs.webappName }} --apiName ${{ steps.build-info.outputs.apiFunctionName }})
echo "initialDeployment=${initialDeployment}" >> $GITHUB_OUTPUT
echo "Initial Deployment: ${initialDeployment}"
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/reusable-database-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ on:
azResourceGrpNetworkEncrypted:
required: true
type: string
apiName:
apiFunctionName:
required: true
type: string
migrationFunctionName:
required: true
type: string
environmentHash:
Expand Down Expand Up @@ -57,7 +60,7 @@ jobs:
- name: Deploy Cosmos MongoDB
id: azure-mongodb-deploy
run: |
allowedNetworks=$(az network vnet subnet list -g ${{ steps.rgNetwork.outputs.out }} --vnet-name ${{ vars.AZ_NETWORK_VNET_NAME }} --query "[?name=='snet-${{ inputs.apiName }}'].id" -o json)
allowedNetworks=$(az network vnet subnet list -g ${{ steps.rgNetwork.outputs.out }} --vnet-name ${{ vars.AZ_NETWORK_VNET_NAME }} --query "[?name=='snet-${{ inputs.apiFunctionName }}' || name=='snet-${{inputs.migrationFunctionName}}'].id" -o json)
./ops/scripts/pipeline/az-cosmos-deploy.sh \
-g ${{ secrets.AZURE_RG }} \
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/reusable-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: End-to-end Tests
on:
workflow_call:
inputs:
apiName:
apiFunctionName:
required: true
type: string
slotName:
Expand Down Expand Up @@ -75,13 +75,13 @@ jobs:
fi
echo "Seeding E2E CosmosDB..."
curl -v -d '{"txIdOverride": '0'}' -H "Content-Type: application/json" https://${{ inputs.apiName }}.azurewebsites${{ vars.AZ_HOSTNAME_SUFFIX }}/api/orders-sync?x-ms-routing-name=${{ inputs.slotName }}
curl -v -d '{"txIdOverride": '0'}' -H "Content-Type: application/json" https://${{ inputs.apiFunctionName }}.azurewebsites${{ vars.AZ_HOSTNAME_SUFFIX }}/api/orders-sync?x-ms-routing-name=${{ inputs.slotName }}
- name: Restart API and Install Node dependencies
working-directory: test/e2e
run: |
az functionapp restart --name ${{ inputs.apiName }} --resource-group ${{ steps.rgApp.outputs.out }} & az webapp restart --name ${{ inputs.webappName }} --resource-group ${{ steps.rgApp.outputs.out }}
az functionapp restart --name ${{ inputs.apiName }} --resource-group ${{ steps.rgApp.outputs.out }} --slot staging & az webapp restart --name ${{ inputs.webappName }} --resource-group ${{ steps.rgApp.outputs.out }} --slot staging
az functionapp restart --name ${{ inputs.apiFunctionName }} --resource-group ${{ steps.rgApp.outputs.out }} & az webapp restart --name ${{ inputs.webappName }} --resource-group ${{ steps.rgApp.outputs.out }}
az functionapp restart --name ${{ inputs.apiFunctionName }} --resource-group ${{ steps.rgApp.outputs.out }} --slot staging & az webapp restart --name ${{ inputs.webappName }} --resource-group ${{ steps.rgApp.outputs.out }} --slot staging
sleep 10
npm ci
npx playwright install chromium msedge
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/reusable-endpoint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Endpoint Tests
on:
workflow_call:
inputs:
apiName:
apiFunctionName:
required: true
type: string
slotName:
Expand Down Expand Up @@ -33,7 +33,7 @@ jobs:
env:
stackName: ${{ inputs.stackName }}
webappName: ${{ inputs.webappName }}
apiName: ${{ inputs.apiName }}
apiFunctionName: ${{ inputs.apiFunctionName }}
branchHashId: ${{ inputs.branchHashId }}
priority: 200
steps:
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
- name: Health check App Resources
run: |
./ops/scripts/pipeline/endpoint-test.sh \
--apiName ${{ inputs.apiName }} \
--apiFunctionName ${{ inputs.apiFunctionName }} \
--webappName ${{ inputs.webappName }} \
--hostSuffix ${{ vars.AZ_HOSTNAME_SUFFIX }} \
--gitSha ${{ github.sha }} \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reusable-frontend-slot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
webAppName:
required: true
type: string
apiName:
apiFunctionName:
required: true
type: string
ghaEnvironment:
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
./ops/scripts/pipeline/slots/az-slot-web-resource-deploy.sh \
--resourceGroup ${{ steps.rgApp.outputs.out }} \
--webappName ${{ inputs.webappName }} \
--apiName ${{ inputs.apiName }} \
--apiFunctionName ${{ inputs.apiFunctionName }} \
--slotName ${{ inputs.slotName }} \
--subscription ${{ secrets.AZURE_SUBSCRIPTION }} \
--network-rg ${{ steps.rgNetwork.outputs.out }} \
Expand Down
39 changes: 28 additions & 11 deletions .github/workflows/sub-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ on:
nodeVersion:
required: true
type: string
apiName:
apiFunctionName:
required: true
type: string
migrationFunctionName:
required: true
type: string
camsServerHostname:
Expand Down Expand Up @@ -84,28 +87,42 @@ jobs:
backend:
defaults:
run:
working-directory: backend/functions
working-directory: backend

runs-on: ubuntu-latest
environment: ${{ inputs.environment }}

steps:
- uses: actions/checkout@v3

- name: Execute Build
run: |
pushd ../../common
npm ci
popd
npm run use-bash
npm run build-common
npm ci
npm run build
- name: Package Application
run: OUT=${{ inputs.apiName }} npm run pack
npm run build:api
npm run build:migration
- name: Package API
run: OUT=${{ inputs.apiFunctionName }} npm run pack

- name: Package Migration
run: OUT=${{ inputs.migrationFunctionName }} npm run pack:migration

- name: Upload API Azure Functions Artifact
uses: actions/[email protected]
with:
name: ${{ inputs.apiFunctionName }}-build
path: backend/function-apps/api/${{ inputs.apiFunctionName }}.zip
if-no-files-found: error

- name: Upload Node Azure Functions Artifact
- name: Upload Migration Azure Functions Artifact
uses: actions/[email protected]
with:
name: ${{ inputs.apiName }}-build
path: backend/functions/${{ inputs.apiName }}.zip
name: ${{ inputs.migrationFunctionName }}-build
path: backend/function-apps/migration/${{ inputs.migrationFunctionName }}.zip
if-no-files-found: error
Loading

0 comments on commit e3b6fee

Please sign in to comment.