Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
523 changes: 348 additions & 175 deletions .github/workflows/deploy.yml

Large diffs are not rendered by default.

82 changes: 61 additions & 21 deletions .github/workflows/test-automation.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
name: Test Automation Content Processing

on:
push:
branches:
- main
- dev
paths:
- 'tests/e2e-test/**'
schedule:
- cron: '0 13 * * *' # Runs at 1 PM UTC
workflow_dispatch:
workflow_call:
inputs:
CP_WEB_URL:
required: true
type: string
CP_RG:
required: true
type: string
CP_CONTAINERAPP_PREFIX:
required: true
type: string

env:
url: ${{ vars.CP_WEB_URL }}
url: ${{ inputs.CP_WEB_URL }}
CP_RG: ${{ inputs.CP_RG }}
CP_CONTAINERAPP_PREFIX: ${{ inputs.CP_CONTAINERAPP_PREFIX }}
accelerator_name: "Content Processing"


jobs:
test:

Expand All @@ -27,21 +32,21 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Azure CLI Login
uses: azure/login@v2
with:
creds: '{"clientId":"${{ secrets.AZURE_MAINTENANCE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_MAINTENANCE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}'
- name: Login to Azure
run: |
az login --service-principal -u ${{ secrets.AZURE_MAINTENANCE_CLIENT_ID }} -p ${{ secrets.AZURE_MAINTENANCE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
az account set --subscription ${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}

- name: Start Container App
id: start-container-app
uses: azure/cli@v2
with:
azcliversion: 'latest'
inlineScript: |
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"
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"
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"
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"
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"
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"

- name: Install dependencies
run: |
Expand All @@ -51,6 +56,41 @@ jobs:
- name: Ensure browsers are installed
run: python -m playwright install --with-deps chromium

- name: Validate URL
run: |
if [ -z "${{ env.url }}" ]; then
echo "ERROR: No URL provided for testing"
exit 1

fi

echo "Testing URL: ${{ env.url }}"


- name: Wait for Application to be Ready
run: |
echo "Waiting for application to be ready at ${{ env.url }} "
max_attempts=10
attempt=1

while [ $attempt -le $max_attempts ]; do
echo "Attempt $attempt: Checking if application is ready..."
if curl -f -s "${{ env.url }}" > /dev/null; then
echo "Application is ready!"
break

fi

if [ $attempt -eq $max_attempts ]; then
echo "Application is not ready after $max_attempts attempts"
exit 1
fi

echo "Application not ready, waiting 30 seconds..."
sleep 30
attempt=$((attempt + 1))
done

- name: Run tests(1)
id: test1
run: |
Expand Down Expand Up @@ -127,7 +167,7 @@ jobs:
with:
azcliversion: 'latest'
inlineScript: |
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"
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"
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"
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"
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"
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"
az logout
1 change: 1 addition & 0 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,4 @@ output CONTAINER_API_APP_FQDN string = containerApps.outputs.containweAppApiEndP
output CONTAINER_APP_USER_IDENTITY_ID string = containerAppEnv.outputs.containerRegistryReaderId
output CONTAINER_APP_USER_PRINCIPAL_ID string = containerAppEnv.outputs.containerRegistryReaderPrincipalId
output AZURE_ENV_IMAGETAG string = imageTag
output SOLUTION_NAME string = solutionPrefix
6 changes: 5 additions & 1 deletion infra/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"_generator": {
"name": "bicep",
"version": "0.36.1.42791",
"templateHash": "4455095207947106270"
"templateHash": "2054400867460750387"
}
},
"parameters": {
Expand Down Expand Up @@ -3875,6 +3875,10 @@
"AZURE_ENV_IMAGETAG": {
"type": "string",
"value": "[parameters('imageTag')]"
},
"SOLUTION_NAME": {
"type": "string",
"value": "[variables('solutionPrefix')]"
}
}
}
2 changes: 1 addition & 1 deletion infra/scripts/checkquota.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ echo "✅ Azure subscription set successfully."

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

VALID_REGION=""
Expand Down
3 changes: 2 additions & 1 deletion infra/scripts/docker-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ function Build-And-Push-Image {

if($CONTAINER_APP_NAME)
{
$timestamp = Get-Date -Format "yyyyMMddHHmmss"
Write-Host "Updating the Container app registry server & image"
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
az containerapp update --name $CONTAINER_APP_NAME --resource-group $AZURE_RESOURCE_GROUP --image $IMAGE_URI --only-show-errors
az containerapp update --name $CONTAINER_APP_NAME --resource-group $AZURE_RESOURCE_GROUP --image $IMAGE_URI --set-env-vars REFRESH_TIMESTAMP=$timestamp --only-show-errors
Write-Host "Updated the registry for Container: $CONTAINER_APP_NAME"
}
}
Expand Down
1 change: 1 addition & 0 deletions infra/scripts/docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ build_and_push_image() {
--name "$CONTAINER_APP" \
--resource-group "$AZURE_RESOURCE_GROUP" \
--image "$IMAGE_URI" \
--set-env-vars REFRESH_TIMESTAMP=$(date +%Y%m%d%H%M%S) \
--only-show-errors

echo "Updated registry for container app: $CONTAINER_APP"
Expand Down
3 changes: 3 additions & 0 deletions src/ContentProcessorAPI/samples/schemas/register_schema.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fi
# Assign arguments to variables
API_ENDPOINT_URL=$1
SCHEMA_INFO_JSON=$2
GITHUB_OUTPUT_FILE=${GITHUB_OUTPUT:-/tmp/schema_output.txt}

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