Skip to content

Commit b5d5989

Browse files
Merge pull request #140 from microsoft/dev
feat: Enhance deployment pipeline, modularize test workflows, simplify infra, and update docs
2 parents 7fef6da + 146e075 commit b5d5989

21 files changed

+958
-598
lines changed

.github/workflows/deploy.yml

Lines changed: 81 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
1-
name: Validate Deployment
1+
name: Deploy-Test-Cleanup Pipeline
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
schedule:
8-
- cron: '0 5,17 * * *' # Runs at 5:00 AM and 5:00 PM GMT
9-
workflow_dispatch:
4+
workflow_run:
5+
workflows: ["Build Docker and Optional Push"]
6+
types:
7+
- completed
8+
branches:
9+
- main
10+
- dev
11+
- demo
12+
schedule:
13+
- cron: '0 5,17 * * *' # Runs at 5:00 AM and 5:00 PM GMT
14+
workflow_dispatch:
15+
16+
env:
17+
GPT_MIN_CAPACITY: 200
18+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
1019

1120
jobs:
1221
deploy:
1322
runs-on: ubuntu-latest
23+
outputs:
24+
RESOURCE_GROUP_NAME: ${{ steps.check_create_rg.outputs.RESOURCE_GROUP_NAME }}
25+
WEBAPP_URL: ${{ steps.get_output.outputs.WEBAPP_URL }}
1426
steps:
1527
- name: Checkout Code
1628
uses: actions/checkout@v3
@@ -36,7 +48,6 @@ jobs:
3648
UNIQUE_RG_NAME="arg-${ACCL_NAME}-${SHORT_UUID}"
3749
echo "RESOURCE_GROUP_NAME=${UNIQUE_RG_NAME}" >> $GITHUB_ENV
3850
echo "Generated RESOURCE_GROUP_NAME: ${UNIQUE_RG_NAME}"
39-
4051
4152
- name: Check and Create Resource Group
4253
id: check_create_rg
@@ -50,8 +61,8 @@ jobs:
5061
else
5162
echo "Resource group already exists."
5263
fi
64+
echo "RESOURCE_GROUP_NAME=${{ env.RESOURCE_GROUP_NAME }}" >> $GITHUB_OUTPUT
5365
54-
5566
- name: Generate Unique Solution Prefix
5667
id: generate_solution_prefix
5768
run: |
@@ -63,17 +74,42 @@ jobs:
6374
echo "SOLUTION_PREFIX=${UNIQUE_SOLUTION_PREFIX}" >> $GITHUB_ENV
6475
echo "Generated SOLUTION_PREFIX: ${UNIQUE_SOLUTION_PREFIX}"
6576
66-
6777
- name: Deploy Bicep Template
6878
id: deploy
6979
run: |
7080
set -e
81+
# set image tag based on branch
82+
if [[ "${{ env.BRANCH_NAME }}" == "main" ]]; then
83+
IMAGE_TAG="latest"
84+
elif [[ "${{ env.BRANCH_NAME }}" == "dev" ]]; then
85+
IMAGE_TAG="dev"
86+
elif [[ "${{ env.BRANCH_NAME }}" == "demo" ]]; then
87+
IMAGE_TAG="demo"
88+
else
89+
IMAGE_TAG="latest"
90+
fi
91+
7192
az deployment group create \
93+
--name ${{ env.SOLUTION_PREFIX }}-deployment \
7294
--resource-group ${{ env.RESOURCE_GROUP_NAME }} \
7395
--template-file infra/main.bicep \
74-
--parameters AzureAiServiceLocation=swedencentral Prefix=${{ env.SOLUTION_PREFIX }}\
96+
--parameters \
97+
Prefix="${{ env.SOLUTION_PREFIX }}" \
98+
AzureAiServiceLocation="eastus" \
99+
capacity=${{ env.GPT_MIN_CAPACITY }} \
100+
imageVersion="${IMAGE_TAG}"\
75101
--debug
76102
103+
- name: Get Deployment Output and extract Values
104+
id: get_output
105+
run: |
106+
set -e
107+
echo "Fetching deployment output..."
108+
BICEP_OUTPUT=$(az deployment group show --name ${{ env.SOLUTION_PREFIX }}-deployment --resource-group ${{ env.RESOURCE_GROUP_NAME }} --query "properties.outputs" -o json)
109+
echo "Extracting deployment output..."
110+
WEBAPP_URL=$(echo $BICEP_OUTPUT | jq -r '.weB_APP_URL.value')
111+
echo "WEBAPP_URL=$WEBAPP_URL" >> $GITHUB_OUTPUT
112+
echo "Deployment output: $BICEP_OUTPUT"
77113
78114
- name: Send Notification on Failure
79115
if: failure()
@@ -93,6 +129,34 @@ jobs:
93129
-H "Content-Type: application/json" \
94130
-d "$EMAIL_BODY" || echo "Failed to send notification"
95131

132+
- name: Logout from Azure
133+
if: always()
134+
run: |
135+
az logout
136+
echo "Logged out from Azure."
137+
138+
e2e-test:
139+
needs: deploy
140+
uses: ./.github/workflows/test-automation.yml
141+
with:
142+
CODEMOD_WEB_URL: ${{ needs.deploy.outputs.WEBAPP_URL }}
143+
secrets: inherit
144+
145+
cleanup-deployment:
146+
if: always() && needs.deploy.outputs.RESOURCE_GROUP_NAME != ''
147+
needs: [deploy, e2e-test]
148+
runs-on: ubuntu-latest
149+
env:
150+
RESOURCE_GROUP_NAME: ${{ needs.deploy.outputs.RESOURCE_GROUP_NAME }}
151+
steps:
152+
- name: Setup Azure CLI
153+
run: |
154+
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
155+
az --version # Verify installation
156+
157+
- name: Login to Azure
158+
run: |
159+
az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
96160
97161
- name: Get Log Analytics Workspace and OpenAI from Resource Group
98162
if: always()
@@ -126,7 +190,6 @@ jobs:
126190
echo "OpenAI resource name: ${openai_resource_name}"
127191
fi
128192

129-
130193
- name: List KeyVaults and Store in Array
131194
if: always()
132195
id: list_keyvaults
@@ -177,7 +240,6 @@ jobs:
177240
178241
echo "Log analytics workspace resource purging completed successfully"
179242
180-
181243
- name: Delete Bicep Deployment
182244
if: always()
183245
run: |
@@ -195,7 +257,6 @@ jobs:
195257
echo "Resource group does not exists."
196258
fi
197259
198-
199260
- name: Wait for resource deletion to complete
200261
if: always()
201262
run: |
@@ -255,7 +316,6 @@ jobs:
255316
break
256317
fi
257318
done
258-
259319
260320
- name: Purging the Resources
261321
if: always()
@@ -302,3 +362,9 @@ jobs:
302362
fi
303363
done
304364
echo "Resource purging completed successfully"
365+
366+
- name: Logout from Azure
367+
if: always()
368+
run: |
369+
az logout
370+
echo "Logged out from Azure."

.github/workflows/test-automation.yml

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
name: Test Automation Code Modernization
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
- dev
8-
paths:
9-
- 'tests/e2e-test/**'
10-
schedule:
11-
- cron: '0 13 * * *' # Runs at 1 PM UTC
12-
workflow_dispatch:
4+
workflow_call:
5+
inputs:
6+
CODEMOD_WEB_URL:
7+
required: true
8+
type: string
9+
description: "Web URL for Code Modernization"
10+
secrets:
11+
EMAILNOTIFICATION_LOGICAPP_URL_TA:
12+
required: false
13+
description: "Logic App URL for email notifications"
1314

1415
env:
15-
url: ${{ vars.CODEMOD_WEB_URL }}
16-
accelerator_name: "Code Modernization"
16+
url: ${{ inputs.CODEMOD_WEB_URL }}
17+
accelerator_name: "Code Modernization"
1718

1819
jobs:
1920
test:
20-
2121
runs-on: ubuntu-latest
2222
steps:
2323
- name: Checkout repository
@@ -33,15 +33,6 @@ jobs:
3333
with:
3434
creds: '{"clientId":"${{ secrets.AZURE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}'
3535

36-
- name: Start Container App
37-
id: start-container-app
38-
uses: azure/cli@v2
39-
with:
40-
azcliversion: 'latest'
41-
inlineScript: |
42-
az rest -m post -u "/subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CODEMOD_RG }}/providers/Microsoft.App/containerApps/${{ vars.CODEMOD_FRONTEND_CONTAINER_NAME }}/start?api-version=2025-01-01"
43-
az rest -m post -u "/subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CODEMOD_RG }}/providers/Microsoft.App/containerApps/${{ vars.CODEMOD_BACKEND_CONTAINER_NAME }}/start?api-version=2025-01-01"
44-
4536
- name: Install dependencies
4637
run: |
4738
python -m pip install --upgrade pip
@@ -50,6 +41,11 @@ jobs:
5041
- name: Ensure browsers are installed
5142
run: python -m playwright install --with-deps chromium
5243

44+
- name: Open URL
45+
run: |
46+
echo "Opening URL: ${{ env.url }}"
47+
python -m webbrowser "${{ env.url }}"
48+
5349
- name: Run tests(1)
5450
id: test1
5551
run: |
@@ -118,14 +114,4 @@ jobs:
118114
# Send the notification
119115
curl -X POST "${{ secrets.EMAILNOTIFICATION_LOGICAPP_URL_TA }}" \
120116
-H "Content-Type: application/json" \
121-
-d "$EMAIL_BODY" || echo "Failed to send notification"
122-
123-
- name: Stop Container App
124-
if: always()
125-
uses: azure/cli@v2
126-
with:
127-
azcliversion: 'latest'
128-
inlineScript: |
129-
az rest -m post -u "/subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CODEMOD_RG }}/providers/Microsoft.App/containerApps/${{ vars.CODEMOD_FRONTEND_CONTAINER_NAME }}/stop?api-version=2025-01-01"
130-
az rest -m post -u "/subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CODEMOD_RG }}/providers/Microsoft.App/containerApps/${{ vars.CODEMOD_BACKEND_CONTAINER_NAME }}/stop?api-version=2025-01-01"
131-
az logout
117+
-d "$EMAIL_BODY" || echo "Failed to send notification"

azure.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ hooks:
2626
posix:
2727
shell: sh
2828
run: >
29-
chmod u+r+x ./scripts/validate_model_deployment_quota.sh; chmod u+r+x ./scripts/validate_model_quota.sh; ./scripts/validate_model_deployment_quota.sh --subscription "$AZURE_SUBSCRIPTION_ID" --location "${AZURE_AISERVICE_LOCATION:-japaneast}" --models-parameter "aiModelDeployments"
30-
interactive: false
29+
chmod u+r+x ./scripts/validate_model_deployment_quota.sh; chmod u+r+x ./scripts/validate_model_quota.sh; ./scripts/validate_model_deployment_quota.sh --SubscriptionId "$AZURE_SUBSCRIPTION_ID" --Location "${AZURE_AISERVICE_LOCATION:-japaneast}" --ModelsParameter "aiModelDeployments"
30+
interactive: true
3131
continueOnError: false
3232

3333
windows:
3434
shell: pwsh
3535
run: >
3636
$location = if ($env:AZURE_AISERVICE_LOCATION) { $env:AZURE_AISERVICE_LOCATION } else { "japaneast" };
3737
./scripts/validate_model_deployment_quota.ps1 -SubscriptionId $env:AZURE_SUBSCRIPTION_ID -Location $location -ModelsParameter "aiModelDeployments"
38-
interactive: false
38+
interactive: true
3939
continueOnError: false

infra/abbreviations.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"ai": {
33
"aiSearch": "srch-",
44
"aiServices": "aisa-",
5+
"aiFoundry": "aif-",
6+
"aiFoundryProject": "aifp-",
57
"aiVideoIndexer": "avi-",
68
"machineLearningWorkspace": "mlw-",
79
"openAIService": "oai-",

0 commit comments

Comments
 (0)