Skip to content

Commit ab4e974

Browse files
Merge branch 'main' into PSL-US-7770-UnitTest
2 parents 435a41a + f66c2dd commit ab4e974

File tree

88 files changed

+7304
-1122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+7304
-1122
lines changed

Diff for: .github/workflows/CAdeploy.yml

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: CI-Validate Deployment-Client Advisor
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'ClientAdvisor/**'
9+
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout Code
16+
uses: actions/checkout@v3
17+
18+
- name: Setup Azure CLI
19+
run: |
20+
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
21+
az --version # Verify installation
22+
23+
- name: Login to Azure
24+
run: |
25+
az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
26+
27+
- name: Install Bicep CLI
28+
run: az bicep install
29+
30+
- name: Generate Resource Group Name
31+
id: generate_rg_name
32+
run: |
33+
echo "Generating a unique resource group name..."
34+
TIMESTAMP=$(date +%Y%m%d%H%M%S)
35+
COMMON_PART="pslautomationCli"
36+
UNIQUE_RG_NAME="${COMMON_PART}${TIMESTAMP}"
37+
echo "RESOURCE_GROUP_NAME=${UNIQUE_RG_NAME}" >> $GITHUB_ENV
38+
echo "Generated RESOURCE_GROUP_PREFIX: ${UNIQUE_RG_NAME}"
39+
40+
- name: Check and Create Resource Group
41+
id: check_create_rg
42+
run: |
43+
echo "RESOURCE_GROUP: ${{ env.RESOURCE_GROUP_NAME }}"
44+
set -e
45+
echo "Checking if resource group exists..."
46+
rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
47+
if [ "$rg_exists" = "false" ]; then
48+
echo "Resource group does not exist. Creating..."
49+
az group create --name ${{ env.RESOURCE_GROUP_NAME }} --location uksouth || { echo "Error creating resource group"; exit 1; }
50+
else
51+
echo "Resource group already exists."
52+
fi
53+
54+
- name: Generate Unique Solution Prefix
55+
id: generate_solution_prefix
56+
run: |
57+
set -e
58+
COMMON_PART="pslc"
59+
TIMESTAMP=$(date +%s)
60+
UPDATED_TIMESTAMP=$(echo $TIMESTAMP | tail -c 3)
61+
UNIQUE_SOLUTION_PREFIX="${COMMON_PART}${UPDATED_TIMESTAMP}"
62+
echo "SOLUTION_PREFIX=${UNIQUE_SOLUTION_PREFIX}" >> $GITHUB_ENV
63+
echo "Generated SOLUTION_PREFIX: ${UNIQUE_SOLUTION_PREFIX}"
64+
65+
- name: Deploy Bicep Template
66+
id: deploy
67+
run: |
68+
set -e
69+
az deployment group create \
70+
--resource-group ${{ env.RESOURCE_GROUP_NAME }} \
71+
--template-file ClientAdvisor/Deployment/bicep/main.bicep \
72+
--parameters solutionPrefix=${{ env.SOLUTION_PREFIX }} cosmosLocation=eastus2
73+
74+
- name: Update PowerBI URL
75+
if: success()
76+
run: |
77+
set -e
78+
79+
COMMON_PART="-app-service"
80+
application_name="${{ env.SOLUTION_PREFIX }}${COMMON_PART}"
81+
echo "Updating application: $application_name"
82+
83+
# Log the Power BI URL being set
84+
echo "Setting Power BI URL: ${{ vars.VITE_POWERBI_EMBED_URL }}"
85+
86+
# Update the application settings
87+
az webapp config appsettings set --name "$application_name" --resource-group "${{ env.RESOURCE_GROUP_NAME }}" --settings VITE_POWERBI_EMBED_URL="${{ vars.VITE_POWERBI_EMBED_URL }}"
88+
89+
# Restart the web app
90+
az webapp restart --resource-group "${{ env.RESOURCE_GROUP_NAME }}" --name "$application_name"
91+
92+
echo "Power BI URL updated successfully for application: $application_name."
93+
94+
- name: Delete Bicep Deployment
95+
if: success()
96+
run: |
97+
set -e
98+
echo "Checking if resource group exists..."
99+
rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
100+
if [ "$rg_exists" = "true" ]; then
101+
echo "Resource group exist. Cleaning..."
102+
az group delete \
103+
--name ${{ env.RESOURCE_GROUP_NAME }} \
104+
--yes \
105+
--no-wait
106+
echo "Resource group deleted... ${{ env.RESOURCE_GROUP_NAME }}"
107+
else
108+
echo "Resource group does not exists."
109+
fi
110+
111+
- name: Send Notification on Failure
112+
if: failure()
113+
run: |
114+
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
115+
116+
# Construct the email body
117+
EMAIL_BODY=$(cat <<EOF
118+
{
119+
"body": "<p>Dear Team,</p><p>We would like to inform you that the Client Advisor 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>"
120+
}
121+
EOF
122+
)
123+
124+
# Send the notification
125+
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
126+
-H "Content-Type: application/json" \
127+
-d "$EMAIL_BODY" || echo "Failed to send notification"
128+

Diff for: .github/workflows/RAdeploy.yml

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: CI-Validate Deployment-Research Assistant
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'ResearchAssistant/**'
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 eastus2 || { 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 ResearchAssistant/Deployment/bicep/main.bicep \
70+
--parameters solutionPrefix=${{ env.SOLUTION_PREFIX }}
71+
72+
- name: Delete Bicep Deployment
73+
if: success()
74+
run: |
75+
set -e
76+
echo "Checking if resource group exists..."
77+
rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
78+
if [ "$rg_exists" = "true" ]; then
79+
echo "Resource group exist. Cleaning..."
80+
az group delete \
81+
--name ${{ env.RESOURCE_GROUP_NAME }} \
82+
--yes \
83+
--no-wait
84+
echo "Resource group deleted... ${{ env.RESOURCE_GROUP_NAME }}"
85+
else
86+
echo "Resource group does not exists."
87+
fi
88+
89+
- name: Send Notification on Failure
90+
if: failure()
91+
run: |
92+
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
93+
94+
# Construct the email body
95+
EMAIL_BODY=$(cat <<EOF
96+
{
97+
"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>"
98+
}
99+
EOF
100+
)
101+
102+
# Send the notification
103+
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
104+
-H "Content-Type: application/json" \
105+
-d "$EMAIL_BODY" || echo "Failed to send notification"

Diff for: .github/workflows/codeql.yml

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL Advanced"
13+
14+
on:
15+
push:
16+
branches: [ "main" ]
17+
pull_request:
18+
branches: [ "main" ]
19+
schedule:
20+
- cron: '22 13 * * 0'
21+
22+
jobs:
23+
analyze:
24+
name: Analyze (${{ matrix.language }})
25+
# Runner size impacts CodeQL analysis time. To learn more, please see:
26+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
27+
# - https://gh.io/supported-runners-and-hardware-resources
28+
# - https://gh.io/using-larger-runners (GitHub.com only)
29+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
30+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
31+
permissions:
32+
# required for all workflows
33+
security-events: write
34+
35+
# required to fetch internal or private CodeQL packs
36+
packages: read
37+
38+
# only required for workflows in private repositories
39+
actions: read
40+
contents: read
41+
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
include:
46+
- language: javascript-typescript
47+
build-mode: none
48+
- language: python
49+
build-mode: none
50+
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
51+
# Use `c-cpp` to analyze code written in C, C++ or both
52+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
53+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
54+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
55+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
56+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
57+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
58+
steps:
59+
- name: Checkout repository
60+
uses: actions/checkout@v4
61+
62+
# Initializes the CodeQL tools for scanning.
63+
- name: Initialize CodeQL
64+
uses: github/codeql-action/init@v3
65+
with:
66+
languages: ${{ matrix.language }}
67+
build-mode: ${{ matrix.build-mode }}
68+
# If you wish to specify custom queries, you can do so here or in a config file.
69+
# By default, queries listed here will override any specified in a config file.
70+
# Prefix the list here with "+" to use these queries and those in the config file.
71+
72+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
73+
# queries: security-extended,security-and-quality
74+
75+
# If the analyze step fails for one of the languages you are analyzing with
76+
# "We were unable to automatically build your code", modify the matrix above
77+
# to set the build mode to "manual" for that language. Then modify this step
78+
# to build your code.
79+
# ℹ️ Command-line programs to run using the OS shell.
80+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
81+
- if: matrix.build-mode == 'manual'
82+
shell: bash
83+
run: |
84+
echo 'If you are using a "manual" build mode for one or more of the' \
85+
'languages you are analyzing, replace this with the commands to build' \
86+
'your code, for example:'
87+
echo ' make bootstrap'
88+
echo ' make release'
89+
exit 1
90+
91+
- name: Perform CodeQL Analysis
92+
uses: github/codeql-action/analyze@v3
93+
with:
94+
category: "/language:${{matrix.language}}"

Diff for: .github/workflows/pylint.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Pylint
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: ["3.11"]
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Python ${{ matrix.python-version }}
14+
uses: actions/setup-python@v3
15+
with:
16+
python-version: ${{ matrix.python-version }}
17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
pip install -r ClientAdvisor/App/requirements.txt
21+
- name: Run flake8
22+
run: flake8 --config=ClientAdvisor/App/.flake8 ClientAdvisor/App

0 commit comments

Comments
 (0)