Skip to content

Commit a49782a

Browse files
feat: Use Existing AI Project Resource & Test Automation Workflow Improvements
2 parents e5bb003 + b49d4ad commit a49782a

20 files changed

+785
-355
lines changed

.github/workflows/deploy-KMGeneric.yml

Lines changed: 256 additions & 126 deletions
Large diffs are not rendered by default.

.github/workflows/test-automation.yml

Lines changed: 83 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,28 @@ on:
77
- dev
88
paths:
99
- 'tests/e2e-test/**'
10-
schedule:
11-
- cron: '0 13 * * *' # Runs at 1 PM UTC
12-
workflow_dispatch:
1310

11+
workflow_dispatch:
12+
# NEW: Add workflow_call to make it reusable
13+
workflow_call:
14+
inputs:
15+
KMGENERIC_URL:
16+
required: false
17+
type: string
18+
description: "Web URL for KMGeneric (overrides environment variable)"
19+
KMGENERIC_URL_API:
20+
required: false
21+
type: string
22+
description: "API URL for KMGeneric (overrides environment variable)"
23+
secrets:
24+
EMAILNOTIFICATION_LOGICAPP_URL_TA:
25+
required: false
26+
description: "Logic App URL for email notifications"
1427
env:
15-
url: ${{ vars.KMG_WEB_URL }}
16-
api_url: ${{ vars.KMG_API_URL }}
17-
accelerator_name: "KMGeneric"
28+
# Use input URL if provided (from deploy pipeline), otherwise fall back to vars
29+
url: ${{ inputs.KMGENERIC_URL }}
30+
api_url: ${{ inputs.KMGENERIC_URL_API}}
31+
accelerator_name: "KMGeneric"
1832

1933
jobs:
2034
test:
@@ -35,6 +49,40 @@ jobs:
3549
3650
- name: Ensure browsers are installed
3751
run: python -m playwright install --with-deps chromium
52+
- name: Validate URL
53+
run: |
54+
if [ -z "${{ env.url }}" ]; then
55+
echo "ERROR: No URL provided for testing"
56+
exit 1
57+
elif [ -z "${{ env.api_url }}" ]; then
58+
echo "ERROR: No API URL provided for testing"
59+
exit 1
60+
fi
61+
echo "Testing URL: ${{ env.url }}"
62+
echo "Testing API URL: ${{ env.api_url }}"
63+
- name: Wait for Application to be Ready
64+
run: |
65+
echo "Waiting for application to be ready at ${{ env.url }} "
66+
max_attempts=10
67+
attempt=1
68+
69+
while [ $attempt -le $max_attempts ]; do
70+
echo "Attempt $attempt: Checking if application is ready..."
71+
if curl -f -s "${{ env.url }}" > /dev/null; then
72+
echo "Application is ready!"
73+
break
74+
fi
75+
76+
if [ $attempt -eq $max_attempts ]; then
77+
echo "Application is not ready after $max_attempts attempts"
78+
exit 1
79+
fi
80+
81+
echo "Application not ready, waiting 30 seconds..."
82+
sleep 30
83+
attempt=$((attempt + 1))
84+
done
85+
3886
3987
- name: Run tests(1)
4088
id: test1
@@ -73,34 +121,57 @@ jobs:
73121
uses: actions/upload-artifact@v4
74122
if: ${{ !cancelled() }}
75123
with:
76-
name: test-report
124+
125+
name: test-report-${{ github.run_id }}
77126
path: tests/e2e-test/report/*
127+
- name: Determine Test Result
128+
id: test_result
129+
run: |
130+
IS_SUCCESS=${{ steps.test1.outcome == 'success' || steps.test2.outcome == 'success' || steps.test3.outcome == 'success' }}
131+
echo "IS_SUCCESS=$IS_SUCCESS" >> $GITHUB_OUTPUT
132+
133+
if [ "$IS_SUCCESS" = "true" ]; then
134+
echo "✅ Tests passed!"
135+
else
136+
echo "❌ All test attempts failed"
137+
exit 1
138+
fi
78139
79140
- name: Send Notification
80141
if: always()
81142
run: |
82143
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
83144
REPORT_URL=${{ steps.upload_report.outputs.artifact-url }}
84-
IS_SUCCESS=${{ steps.test1.outcome == 'success' || steps.test2.outcome == 'success' || steps.test3.outcome == 'success' }}
145+
146+
IS_SUCCESS=${{ steps.test_result.outputs.IS_SUCCESS }}
147+
148+
85149
# Construct the email body
86150
if [ "$IS_SUCCESS" = "true" ]; then
87151
EMAIL_BODY=$(cat <<EOF
88152
{
89-
"body": "<p>Dear Team,</p><p>We would like to inform you that the ${{ env.accelerator_name }} Test Automation process has completed successfully.</p><p><strong>Run URL:</strong> <a href=\"${RUN_URL}\">${RUN_URL}</a><br></p><p><strong>Test Report:</strong> <a href=\"${REPORT_URL}\">${REPORT_URL}</a></p><p>Best regards,<br>Your Automation Team</p>",
153+
154+
"body": "<p>Dear Team,</p><p>We would like to inform you that the ${{ env.accelerator_name }} Test Automation process has completed successfully.</p><p><strong>Run URL:</strong> <a href=\"${RUN_URL}\">${RUN_URL}</a><br></p><p><strong>Test Report:</strong> <a href=\"${REPORT_URL}\">${REPORT_URL}</a></p><p><strong>Tested URL:</strong> ${{ env.url }}</p><p>Best regards,<br>Your Automation Team</p>",
155+
90156
"subject": "${{ env.accelerator_name }} Test Automation - Success"
91157
}
92158
EOF
93159
)
94160
else
95161
EMAIL_BODY=$(cat <<EOF
96162
{
97-
"body": "<p>Dear Team,</p><p>We would like to inform you that the ${{ env.accelerator_name }} Test Automation process has encountered an issue and has failed to complete successfully.</p><p><strong>Run URL:</strong> <a href=\"${RUN_URL}\">${RUN_URL}</a><br> ${OUTPUT}</p><p><strong>Test Report:</strong> <a href=\"${REPORT_URL}\">${REPORT_URL}</a></p><p>Please investigate the matter at your earliest convenience.</p><p>Best regards,<br>Your Automation Team</p>",
163+
164+
"body": "<p>Dear Team,</p><p>We would like to inform you that the ${{ env.accelerator_name }} Test Automation process has encountered an issue and has failed to complete successfully.</p><p><strong>Run URL:</strong> <a href=\"${RUN_URL}\">${RUN_URL}</a><br></p><p><strong>Test Report:</strong> <a href=\"${REPORT_URL}\">${REPORT_URL}</a></p><p><strong>Tested URL:</strong> ${{ env.url }}</p><p>Please investigate the matter at your earliest convenience.</p><p>Best regards,<br>Your Automation Team</p>",
165+
98166
"subject": "${{ env.accelerator_name }} Test Automation - Failure"
99167
}
100168
EOF
101169
)
102170
fi
171+
172+
103173
# Send the notification
104-
curl -X POST "${{ secrets.EMAILNOTIFICATION_LOGICAPP_URL_TA}}" \
174+
curl -X POST "${{ secrets.EMAILNOTIFICATION_LOGICAPP_URL_TA }}" \
105175
-H "Content-Type: application/json" \
106-
-d "$EMAIL_BODY" || echo "Failed to send notification"
176+
-d "$EMAIL_BODY" || echo "Failed to send notification"
177+

azure.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ hooks:
1212
preprovision:
1313
windows:
1414
run: |
15-
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"; $logFile = "azd_preprovision_$timestamp.log"; ./infra/scripts/docker-build.ps1 $env:AZURE_SUBSCRIPTION_ID $env:AZURE_ENV_NAME $env:AZURE_LOCATION $env:AZURE_RESOURCE_GROUP $env:USE_LOCAL_BUILD *>&1 | Tee-Object -FilePath $logFile
15+
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"; $logFile = "azd_preprovision_$timestamp.log"; ./infra/scripts/docker-build.ps1 $env:AZURE_SUBSCRIPTION_ID $env:AZURE_ENV_NAME $env:AZURE_LOCATION $env:AZURE_RESOURCE_GROUP $env:USE_LOCAL_BUILD $env:AZURE_ENV_IMAGETAG *>&1 | Tee-Object -FilePath $logFile
1616
shell: pwsh
1717
continueOnError: false
1818
interactive: true
1919
posix:
2020
run: |
21-
timestamp=$(date +"%Y%m%d-%H%M%S"); logFile="azd_preprovision_$timestamp.log"; sed -i 's/\r$//' ./infra/scripts/docker-build.sh; ./infra/scripts/docker-build.sh "$AZURE_SUBSCRIPTION_ID" "$AZURE_ENV_NAME" "$AZURE_LOCATION" "$AZURE_RESOURCE_GROUP" "$USE_LOCAL_BUILD" 2>&1 | tee "$logFile"
21+
timestamp=$(date +"%Y%m%d-%H%M%S"); logFile="azd_preprovision_$timestamp.log"; sed -i 's/\r$//' ./infra/scripts/docker-build.sh; ./infra/scripts/docker-build.sh "$AZURE_SUBSCRIPTION_ID" "$AZURE_ENV_NAME" "$AZURE_LOCATION" "$AZURE_RESOURCE_GROUP" "$USE_LOCAL_BUILD" "$AZURE_ENV_IMAGETAG" 2>&1 | tee "$logFile"
2222
shell: sh
2323
continueOnError: false
2424
interactive: true

documents/CustomizingAzdParameters.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ By default this template will use the environment name as the prefix to prevent
99

1010
| Name | Type | Default Value | Purpose |
1111
| ----------------------------------------- | ------- | ------------------------ | -------------------------------------------------------------------------- |
12-
| `AZURE_LOCATION` | string | ` ` *(empty)* | Sets the Azure region for resource deployment. |
12+
| `AZURE_LOCATION` | string | ` ` | Sets the Azure region for resource deployment. |
1313
| `AZURE_ENV_NAME` | string | `env_name` | Sets the environment name prefix for all Azure resources. |
1414
| `AZURE_CONTENT_UNDERSTANDING_LOCATION` | string | `swedencentral` | Specifies the region for content understanding resources. |
1515
| `AZURE_SECONDARY_LOCATION` | string | `eastus2` | Specifies a secondary Azure region. |
@@ -21,7 +21,9 @@ By default this template will use the environment name as the prefix to prevent
2121
| `AZURE_OPENAI_EMBEDDING_MODEL` | string | `text-embedding-ada-002` | Sets the name of the embedding model to use. |
2222
| `AZURE_ENV_IMAGETAG` | string | `latest` | Sets the image tag (`latest`, `dev`, `hotfix`, etc.). |
2323
| `AZURE_OPENAI_EMBEDDING_MODEL_CAPACITY` | integer | `80` | Sets the capacity for the embedding model deployment. |
24-
| `AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID` | string | ` ` *(empty)* | Reuses an existing Log Analytics Workspace instead of creating a new one. |
24+
| `AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID` | string | `<Existing Workspace Id>` | Reuses an existing Log Analytics Workspace instead of creating a new one. |
25+
| `USE_LOCAL_BUILD` | string | `false` | Indicates whether to use a local container build for deployment. |
26+
| `AZURE_EXISTING_AI_PROJECT_RESOURCE_ID` | string | `<Existing AI Project resource Id>` | Reuses an existing AIFoundry and AIFoundryProject instead of creating a new one. |
2527

2628

2729

documents/DeploymentGuide.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ When you start the deployment, most parameters will have **default values**, but
120120
| **Embedding Model Capacity** | Set the capacity for **embedding models** (in thousands). | 80k |
121121
| **Image Tag** | Docker image tag to deploy. Common values: `latest`, `dev`, `hotfix`. | latest |
122122
| **Existing Log Analytics Workspace** | To reuse an existing Log Analytics Workspace ID. | *(empty)* |
123+
| **Use Local Build** | Boolean flag to determine if local container builds should be used. | false |
123124

124125

125126

infra/abbreviations.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
"speechService": "spch-",
2020
"translator": "trsl-",
2121
"aiHub": "aih-",
22-
"aiHubProject": "aihp-"
22+
"aiHubProject": "aihp-",
23+
"aiFoundry": "aif-",
24+
"aiFoundryProject": "aifp-"
2325
},
2426
"analytics": {
2527
"analysisServicesServer": "as",

0 commit comments

Comments
 (0)