Skip to content

Commit 6d46ef2

Browse files
Merge branch 'dev' into dependabotchanges
2 parents a7be154 + fda3e2e commit 6d46ef2

32 files changed

+1823
-985
lines changed

.flake8

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[flake8]
2+
max-line-length = 88
3+
extend-ignore = E501
4+
exclude = venv, frontend
5+
ignore = E203, W503

.github/CODEOWNERS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Lines starting with '#' are comments.
2+
# Each line is a file pattern followed by one or more owners.
3+
4+
# These owners will be the default owners for everything in the repo.
5+
* @toherman-msft @hunterjam @Avijit-Microsoft @Roopan-Microsoft @Prajwal-Microsoft

.github/dependabot.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,20 @@
55

66
version: 2
77
updates:
8-
- package-ecosystem: "pip" # See documentation for possible values
9-
directory: "/" # Location of package manifests
8+
- package-ecosystem: "npm" # for frontend dependencies
9+
directory: "/frontend"
1010
schedule:
11-
interval: "weekly"
11+
interval: "monthly"
12+
commit-message:
13+
prefix: "build"
14+
target-branch: "dependabotchanges"
15+
open-pull-requests-limit: 10
16+
17+
- package-ecosystem: "pip" # for backend dependencies
18+
directory: "/"
19+
schedule:
20+
interval: "monthly"
21+
commit-message:
22+
prefix: "build"
23+
target-branch: "dependabotchanges"
24+
open-pull-requests-limit: 10

.github/pull_request_template.md

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,40 @@
1-
### Motivation and Context
2-
3-
<!-- Thank you for your contribution to this repo!
4-
Please help reviewers and future users, providing the following information:
5-
1. Why is this change required?
6-
2. What problem does it solve?
7-
3. What scenario does it contribute to?
8-
4. If it fixes an open issue, please link to the issue here.
9-
5. Does this solve an issue or add a feature that *all* users of this sample app can benefit from? Contributions will only be accepted that apply across all users of this app.
10-
-->
1+
## Purpose
2+
<!-- Describe the intention of the changes being proposed. What problem does it solve or functionality does it add? -->
3+
* ...
114

12-
### Description
5+
## Does this introduce a breaking change?
6+
<!-- Mark one with an "x". -->
137

14-
<!-- Describe your changes, the overall approach, the underlying design.
15-
These notes will help understanding how your code works. Thanks! -->
8+
- [ ] Yes
9+
- [ ] No
1610

11+
<!-- Please prefix your PR title with one of the following:
12+
* `feat`: A new feature
13+
* `fix`: A bug fix
14+
* `docs`: Documentation only changes
15+
* `style`: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
16+
* `refactor`: A code change that neither fixes a bug nor adds a feature
17+
* `perf`: A code change that improves performance
18+
* `test`: Adding missing tests or correcting existing tests
19+
* `build`: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
20+
* `ci`: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
21+
* `chore`: Other changes that don't modify src or test files
22+
* `revert`: Reverts a previous commit
23+
* !: A breaking change is indicated with a `!` after the listed prefixes above, e.g. `feat!`, `fix!`, `refactor!`, etc.
24+
-->
1725

18-
### Contribution Checklist
26+
## Golden Path Validation
27+
- [ ] I have tested the primary workflows (the "golden path") to ensure they function correctly without errors.
1928

20-
<!-- Before submitting this PR, please make sure: -->
29+
## Deployment Validation
30+
- [ ] I have validated the deployment process successfully and all services are running as expected with this change.
2131

32+
## What to Check
33+
Verify that the following are valid
2234
- [ ] I have built and tested the code locally and in a deployed app
2335
- [ ] For frontend changes, I have pulled the latest code from main, built the frontend, and committed all static files.
2436
- [ ] This is a change for all users of this app. No code or asset is specific to my use case or my organization.
25-
- [ ] I didn't break any existing functionality :smile:
37+
38+
39+
## Other Information
40+
<!-- Add any other helpful information that may be needed here.. -->

.github/workflows/deploy.yml

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
name: CI-Validate Deployment
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
schedule:
8+
- cron: '0 6,18 * * *' # Runs at 6:00 AM and 6:00 PM GMT
9+
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Code
15+
uses: actions/checkout@v3
16+
17+
- name: Setup Azure CLI
18+
run: |
19+
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
20+
az --version # Verify installation
21+
22+
- name: Login to Azure
23+
run: |
24+
az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
25+
26+
- name: Install Bicep CLI
27+
run: az bicep install
28+
29+
- name: Generate Resource Group Name
30+
id: generate_rg_name
31+
run: |
32+
echo "Generating a unique resource group name..."
33+
TIMESTAMP=$(date +%Y%m%d%H%M%S)
34+
COMMON_PART="pslautomationRes"
35+
UNIQUE_RG_NAME="${COMMON_PART}${TIMESTAMP}"
36+
echo "RESOURCE_GROUP_NAME=${UNIQUE_RG_NAME}" >> $GITHUB_ENV
37+
echo "Generated Resource_GROUP_PREFIX: ${UNIQUE_RG_NAME}"
38+
39+
- name: Check and Create Resource Group
40+
id: check_create_rg
41+
run: |
42+
set -e
43+
echo "Checking if resource group exists..."
44+
rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
45+
if [ "$rg_exists" = "false" ]; then
46+
echo "Resource group does not exist. Creating..."
47+
az group create --name ${{ env.RESOURCE_GROUP_NAME }} --location northcentralus || { echo "Error creating resource group"; exit 1; }
48+
else
49+
echo "Resource group already exists."
50+
fi
51+
52+
- name: Generate Unique Solution Prefix
53+
id: generate_solution_prefix
54+
run: |
55+
set -e
56+
COMMON_PART="pslr"
57+
TIMESTAMP=$(date +%s)
58+
UPDATED_TIMESTAMP=$(echo $TIMESTAMP | tail -c 3)
59+
UNIQUE_SOLUTION_PREFIX="${COMMON_PART}${UPDATED_TIMESTAMP}"
60+
echo "SOLUTION_PREFIX=${UNIQUE_SOLUTION_PREFIX}" >> $GITHUB_ENV
61+
echo "Generated SOLUTION_PREFIX: ${UNIQUE_SOLUTION_PREFIX}"
62+
63+
- name: Deploy Bicep Template
64+
id: deploy
65+
run: |
66+
set -e
67+
az deployment group create \
68+
--resource-group ${{ env.RESOURCE_GROUP_NAME }} \
69+
--template-file infrastructure/deployment.json \
70+
--parameters \
71+
HostingPlanName="${{ env.SOLUTION_PREFIX }}-plan" \
72+
ApplicationInsightsName="appins-${{ env.SOLUTION_PREFIX }}" \
73+
WebsiteName="webapp-${{ env.SOLUTION_PREFIX }}" \
74+
CosmosDBName="db-cosmos-${{ env.SOLUTION_PREFIX }}" \
75+
CosmosDBRegion="NorthCentralUS" \
76+
AzureSearchService="search-${{ env.SOLUTION_PREFIX }}" \
77+
AzureOpenAIResource="aoai-${{ env.SOLUTION_PREFIX }}" \
78+
WorkspaceName="worksp-${{ env.SOLUTION_PREFIX }}"
79+
80+
- name: Delete Bicep Deployment
81+
if: success()
82+
run: |
83+
set -e
84+
echo "Checking if resource group exists..."
85+
rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
86+
if [ "$rg_exists" = "true" ]; then
87+
echo "Resource group exists. Cleaning..."
88+
az group delete \
89+
--name ${{ env.RESOURCE_GROUP_NAME }} \
90+
--yes \
91+
--no-wait
92+
echo "Resource group deleted... ${{ env.RESOURCE_GROUP_NAME }}"
93+
else
94+
echo "Resource group does not exist."
95+
fi
96+
97+
- name: Wait for Resource Deletion to Complete
98+
run: |
99+
# List of resources to check based on SOLUTION_PREFIX
100+
resources_to_check=(
101+
"aoai-${{ env.SOLUTION_PREFIX }}"
102+
"appins-${{ env.SOLUTION_PREFIX }}"
103+
"db-cosmos-${{ env.SOLUTION_PREFIX }}"
104+
"${{ env.SOLUTION_PREFIX }}-plan"
105+
"search-${{ env.SOLUTION_PREFIX }}"
106+
"webapp-${{ env.SOLUTION_PREFIX }}"
107+
"worksp-${{ env.SOLUTION_PREFIX }}"
108+
)
109+
110+
# Get the list of resources in YAML format
111+
resource_list=$(az resource list --subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }} --output yaml)
112+
113+
# Maximum number of retries and retry intervals
114+
max_retries=3
115+
retry_intervals=(30 60 120)
116+
retries=0
117+
118+
while true; do
119+
resource_found=false
120+
# Iterate through the resources to check
121+
for resource in "${resources_to_check[@]}"; do
122+
echo "Checking resource: $resource"
123+
if echo "$resource_list" | grep -q "name: $resource"; then
124+
echo "Resource '$resource' exists in the subscription."
125+
resource_found=true
126+
else
127+
echo "Resource '$resource' does not exist in the subscription."
128+
fi
129+
done
130+
131+
# If any resource exists, retry
132+
if [ "$resource_found" = true ]; then
133+
retries=$((retries + 1))
134+
if [ "$retries" -ge "$max_retries" ]; then
135+
echo "Maximum retry attempts reached. Exiting."
136+
break
137+
else
138+
echo "Waiting for ${retry_intervals[$retries-1]} seconds before retrying..."
139+
sleep ${retry_intervals[$retries-1]}
140+
fi
141+
else
142+
echo "No resources found. Exiting."
143+
break
144+
fi
145+
done
146+
147+
- name: Purging the Resources
148+
if: success()
149+
run: |
150+
set -e
151+
# Purging resources based on solution prefix
152+
echo "Purging resources..."
153+
154+
# List of resources to purge
155+
resources_to_purge=(
156+
"aoai-${{ env.SOLUTION_PREFIX }}"
157+
"appins-${{ env.SOLUTION_PREFIX }}"
158+
"db-cosmos-${{ env.SOLUTION_PREFIX }}"
159+
"${{ env.SOLUTION_PREFIX }}-plan"
160+
"search-${{ env.SOLUTION_PREFIX }}"
161+
"webapp-${{ env.SOLUTION_PREFIX }}"
162+
"worksp-${{ env.SOLUTION_PREFIX }}"
163+
)
164+
165+
for resource in "${resources_to_purge[@]}"; do
166+
echo "Purging resource: $resource"
167+
if ! az resource delete --ids /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/providers/Microsoft.CognitiveServices/locations/uksouth/deletedAccounts/$resource --verbose; then
168+
echo "Failed to purge resource: $resource"
169+
else
170+
echo "Purged the resource: $resource"
171+
fi
172+
done
173+
174+
echo "Resource purging completed successfully"
175+
176+
- name: Send Notification on Failure
177+
if: failure()
178+
run: |
179+
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
180+
181+
EMAIL_BODY=$(cat <<EOF
182+
{
183+
"body": "<p>Dear Team,</p><p>We would like to inform you that the Research Assistant Automation process has encountered an issue and has failed to complete successfully.</p><p><strong>Build URL:</strong> ${RUN_URL}<br> ${OUTPUT}</p><p>Please investigate the matter at your earliest convenience.</p><p>Best regards,<br>Your Automation Team</p>"
184+
}
185+
EOF
186+
)
187+
188+
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
189+
-H "Content-Type: application/json" \
190+
-d "$EMAIL_BODY" || echo "Failed to send notification"

.github/workflows/docker-build-and-push.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
types: [closed]
66
branches:
77
- main
8+
- dev
9+
- demo
810
workflow_dispatch: # Add this line to enable manual triggering
911

1012
jobs:
@@ -20,13 +22,40 @@ jobs:
2022
uses: docker/setup-buildx-action@v1
2123

2224
- name: Log in to Azure Container Registry
23-
uses: azure/docker-login@v1
25+
if: ${{ github.ref_name == 'main' }}
26+
uses: azure/docker-login@v2
2427
with:
2528
login-server: ${{ secrets.ACR_LOGIN_SERVER }}
2629
username: ${{ secrets.ACR_USERNAME }}
2730
password: ${{ secrets.ACR_PASSWORD }}
2831

32+
- name: Log in to Azure Container Registry (Dev/Demo)
33+
if: ${{ github.ref_name == 'dev' || github.ref_name == 'demo' }}
34+
uses: azure/docker-login@v2
35+
with:
36+
login-server: ${{ secrets.ACR_DEV_LOGIN_SERVER }}
37+
username: ${{ secrets.ACR_DEV_USERNAME }}
38+
password: ${{ secrets.ACR_DEV_PASSWORD }}
39+
40+
- name: Set Docker image tag
41+
id: docker_tag
42+
run: |
43+
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
44+
echo "TAG=latest" >> $GITHUB_ENV
45+
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
46+
echo "TAG=dev" >> $GITHUB_ENV
47+
elif [[ "${{ github.ref }}" == "refs/heads/demo" ]]; then
48+
echo "TAG=demo" >> $GITHUB_ENV
49+
fi
50+
2951
- name: Build and push Docker image
52+
if: ${{ github.ref_name == 'main' }}
53+
run: |
54+
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/webapp:${{ env.TAG }} -f WebApp.Dockerfile .
55+
docker push ${{ secrets.ACR_LOGIN_SERVER }}/webapp:${{ env.TAG }}
56+
57+
- name: Build and push Docker image (Dev/Demo)
58+
if: ${{ github.ref_name == 'dev' || github.ref_name == 'demo' }}
3059
run: |
31-
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/webapp:latest -f WebApp.Dockerfile .
32-
docker push ${{ secrets.ACR_LOGIN_SERVER }}/webapp:latest
60+
docker build -t ${{ secrets.ACR_DEV_LOGIN_SERVER }}/webapp:${{ env.TAG }} -f WebApp.Dockerfile .
61+
docker push ${{ secrets.ACR_DEV_LOGIN_SERVER }}/webapp:${{ env.TAG }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: "pr-title-checker"
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
merge_group:
10+
11+
permissions:
12+
pull-requests: read
13+
14+
jobs:
15+
main:
16+
name: Validate PR title
17+
runs-on: ubuntu-latest
18+
if: ${{ github.event_name != 'merge_group' }}
19+
steps:
20+
- uses: amannn/action-semantic-pull-request@v5
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)