Skip to content

Commit 0bb7129

Browse files
Merge pull request microsoft#210 from microsoft/dev
fix: merging dev changes to main
2 parents e019c6b + 256d645 commit 0bb7129

8 files changed

Lines changed: 422 additions & 199 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 348 additions & 175 deletions
Large diffs are not rendered by default.

.github/workflows/test-automation.yml

Lines changed: 61 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
name: Test Automation Content Processing
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+
CP_WEB_URL:
7+
required: true
8+
type: string
9+
CP_RG:
10+
required: true
11+
type: string
12+
CP_CONTAINERAPP_PREFIX:
13+
required: true
14+
type: string
1315

1416
env:
15-
url: ${{ vars.CP_WEB_URL }}
17+
url: ${{ inputs.CP_WEB_URL }}
18+
CP_RG: ${{ inputs.CP_RG }}
19+
CP_CONTAINERAPP_PREFIX: ${{ inputs.CP_CONTAINERAPP_PREFIX }}
1620
accelerator_name: "Content Processing"
1721

22+
1823
jobs:
1924
test:
2025

@@ -27,21 +32,21 @@ jobs:
2732
uses: actions/setup-python@v4
2833
with:
2934
python-version: '3.12'
30-
31-
- name: Azure CLI Login
32-
uses: azure/login@v2
33-
with:
34-
creds: '{"clientId":"${{ secrets.AZURE_MAINTENANCE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_MAINTENANCE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}'
35+
36+
- name: Login to Azure
37+
run: |
38+
az login --service-principal -u ${{ secrets.AZURE_MAINTENANCE_CLIENT_ID }} -p ${{ secrets.AZURE_MAINTENANCE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
39+
az account set --subscription ${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}
3540
3641
- name: Start Container App
3742
id: start-container-app
3843
uses: azure/cli@v2
3944
with:
4045
azcliversion: 'latest'
4146
inlineScript: |
42-
az rest -m post -u "/subscriptions/${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CP_RG }}/providers/Microsoft.App/containerApps/${{ vars.CP_CONTAINERAPP_PREFIX }}-app/start?api-version=2025-01-01"
43-
az rest -m post -u "/subscriptions/${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CP_RG }}/providers/Microsoft.App/containerApps/${{ vars.CP_CONTAINERAPP_PREFIX }}-api/start?api-version=2025-01-01"
44-
az rest -m post -u "/subscriptions/${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CP_RG }}/providers/Microsoft.App/containerApps/${{ vars.CP_CONTAINERAPP_PREFIX }}-web/start?api-version=2025-01-01"
47+
az rest -m post -u "/subscriptions/${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}/resourceGroups/${{ env.CP_RG }}/providers/Microsoft.App/containerApps/${{ env.CP_CONTAINERAPP_PREFIX }}-app/start?api-version=2025-01-01"
48+
az rest -m post -u "/subscriptions/${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}/resourceGroups/${{ env.CP_RG }}/providers/Microsoft.App/containerApps/${{ env.CP_CONTAINERAPP_PREFIX }}-api/start?api-version=2025-01-01"
49+
az rest -m post -u "/subscriptions/${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}/resourceGroups/${{ env.CP_RG }}/providers/Microsoft.App/containerApps/${{ env.CP_CONTAINERAPP_PREFIX }}-web/start?api-version=2025-01-01"
4550
4651
- name: Install dependencies
4752
run: |
@@ -51,6 +56,41 @@ jobs:
5156
- name: Ensure browsers are installed
5257
run: python -m playwright install --with-deps chromium
5358

59+
- name: Validate URL
60+
run: |
61+
if [ -z "${{ env.url }}" ]; then
62+
echo "ERROR: No URL provided for testing"
63+
exit 1
64+
65+
fi
66+
67+
echo "Testing URL: ${{ env.url }}"
68+
69+
70+
- name: Wait for Application to be Ready
71+
run: |
72+
echo "Waiting for application to be ready at ${{ env.url }} "
73+
max_attempts=10
74+
attempt=1
75+
76+
while [ $attempt -le $max_attempts ]; do
77+
echo "Attempt $attempt: Checking if application is ready..."
78+
if curl -f -s "${{ env.url }}" > /dev/null; then
79+
echo "Application is ready!"
80+
break
81+
82+
fi
83+
84+
if [ $attempt -eq $max_attempts ]; then
85+
echo "Application is not ready after $max_attempts attempts"
86+
exit 1
87+
fi
88+
89+
echo "Application not ready, waiting 30 seconds..."
90+
sleep 30
91+
attempt=$((attempt + 1))
92+
done
93+
5494
- name: Run tests(1)
5595
id: test1
5696
run: |
@@ -127,7 +167,7 @@ jobs:
127167
with:
128168
azcliversion: 'latest'
129169
inlineScript: |
130-
az rest -m post -u "/subscriptions/${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CP_RG }}/providers/Microsoft.App/containerApps/${{ vars.CP_CONTAINERAPP_PREFIX }}-app/stop?api-version=2025-01-01"
131-
az rest -m post -u "/subscriptions/${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CP_RG }}/providers/Microsoft.App/containerApps/${{ vars.CP_CONTAINERAPP_PREFIX }}-api/stop?api-version=2025-01-01"
132-
az rest -m post -u "/subscriptions/${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CP_RG }}/providers/Microsoft.App/containerApps/${{ vars.CP_CONTAINERAPP_PREFIX }}-web/stop?api-version=2025-01-01"
170+
az rest -m post -u "/subscriptions/${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}/resourceGroups/${{ env.CP_RG }}/providers/Microsoft.App/containerApps/${{ env.CP_CONTAINERAPP_PREFIX }}-app/stop?api-version=2025-01-01"
171+
az rest -m post -u "/subscriptions/${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}/resourceGroups/${{ env.CP_RG }}/providers/Microsoft.App/containerApps/${{ env.CP_CONTAINERAPP_PREFIX }}-api/stop?api-version=2025-01-01"
172+
az rest -m post -u "/subscriptions/${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}/resourceGroups/${{ env.CP_RG }}/providers/Microsoft.App/containerApps/${{ env.CP_CONTAINERAPP_PREFIX }}-web/stop?api-version=2025-01-01"
133173
az logout

infra/main.bicep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,4 @@ output CONTAINER_API_APP_FQDN string = containerApps.outputs.containweAppApiEndP
254254
output CONTAINER_APP_USER_IDENTITY_ID string = containerAppEnv.outputs.containerRegistryReaderId
255255
output CONTAINER_APP_USER_PRINCIPAL_ID string = containerAppEnv.outputs.containerRegistryReaderPrincipalId
256256
output AZURE_ENV_IMAGETAG string = imageTag
257+
output SOLUTION_NAME string = solutionPrefix

infra/main.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"_generator": {
66
"name": "bicep",
77
"version": "0.36.1.42791",
8-
"templateHash": "4455095207947106270"
8+
"templateHash": "2054400867460750387"
99
}
1010
},
1111
"parameters": {
@@ -3875,6 +3875,10 @@
38753875
"AZURE_ENV_IMAGETAG": {
38763876
"type": "string",
38773877
"value": "[parameters('imageTag')]"
3878+
},
3879+
"SOLUTION_NAME": {
3880+
"type": "string",
3881+
"value": "[variables('solutionPrefix')]"
38783882
}
38793883
}
38803884
}

infra/scripts/checkquota.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ echo "✅ Azure subscription set successfully."
3131

3232
# Define models and their minimum required capacities
3333
declare -A MIN_CAPACITY=(
34-
["OpenAI.Standard.gpt-4o"]=$GPT_MIN_CAPACITY
34+
["OpenAI.GlobalStandard.gpt-4o"]=$GPT_MIN_CAPACITY
3535
)
3636

3737
VALID_REGION=""

infra/scripts/docker-build.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ function Build-And-Push-Image {
3939

4040
if($CONTAINER_APP_NAME)
4141
{
42+
$timestamp = Get-Date -Format "yyyyMMddHHmmss"
4243
Write-Host "Updating the Container app registry server & image"
4344
az containerapp registry set --name $CONTAINER_APP_NAME --resource-group $AZURE_RESOURCE_GROUP --server "$ACR_NAME.azurecr.io" --identity $CONTAINER_APP_USER_IDENTITY_ID --only-show-errors
44-
az containerapp update --name $CONTAINER_APP_NAME --resource-group $AZURE_RESOURCE_GROUP --image $IMAGE_URI --only-show-errors
45+
az containerapp update --name $CONTAINER_APP_NAME --resource-group $AZURE_RESOURCE_GROUP --image $IMAGE_URI --set-env-vars REFRESH_TIMESTAMP=$timestamp --only-show-errors
4546
Write-Host "Updated the registry for Container: $CONTAINER_APP_NAME"
4647
}
4748
}

infra/scripts/docker-build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ build_and_push_image() {
100100
--name "$CONTAINER_APP" \
101101
--resource-group "$AZURE_RESOURCE_GROUP" \
102102
--image "$IMAGE_URI" \
103+
--set-env-vars REFRESH_TIMESTAMP=$(date +%Y%m%d%H%M%S) \
103104
--only-show-errors
104105

105106
echo "Updated registry for container app: $CONTAINER_APP"

src/ContentProcessorAPI/samples/schemas/register_schema.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fi
99
# Assign arguments to variables
1010
API_ENDPOINT_URL=$1
1111
SCHEMA_INFO_JSON=$2
12+
GITHUB_OUTPUT_FILE=${GITHUB_OUTPUT:-/tmp/schema_output.txt}
1213

1314
# Validate if the JSON file exists
1415
if [ ! -f "$SCHEMA_INFO_JSON" ]; then
@@ -49,9 +50,11 @@ jq -c '.[]' "$SCHEMA_INFO_JSON" | while read -r schema_entry; do
4950
# Print the API response
5051
if [ "$HTTP_STATUS" -eq 200 ]; then
5152
# Extract Id and Description from the response JSON
53+
SAFE_NAME=$(echo "$CLASS_NAME" | tr '[:upper:]' '[:lower:]' | tr -cd 'a-z0-9_')
5254
ID=$(echo "$RESPONSE_BODY" | jq -r '.Id')
5355
DESC=$(echo "$RESPONSE_BODY" | jq -r '.Description')
5456
echo "$DESC's Schema Id - $ID"
57+
echo "${SAFE_NAME}_schema_id=$ID" >> "$GITHUB_OUTPUT_FILE"
5558
else
5659
echo "Failed to upload '$SCHEMA_FILE'. HTTP Status: $HTTP_STATUS"
5760
echo "Error Response: $RESPONSE_BODY"

0 commit comments

Comments
 (0)