Skip to content

Commit 825b129

Browse files
Merge branch 'main' into KM-AIFoundry
2 parents 070fc36 + c88bd65 commit 825b129

14 files changed

+415
-16
lines changed

.coveragerc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[run]
2+
omit =
3+
*/test_*.py

.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, G004, G200

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ Verify that the following are valid
3434
* ...
3535

3636
## Other Information
37+
3738
<!-- Add any other helpful information that may be needed here. -->
39+

.github/dependabot.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
version: 2
2+
updates:
3+
# GitHub Actions dependencies
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "monthly"
8+
commit-message:
9+
prefix: "build"
10+
target-branch: "dependabotchanges"
11+
open-pull-requests-limit: 30
12+
13+
- package-ecosystem: "pip"
14+
directory: "/App"
15+
schedule:
16+
interval: "monthly"
17+
commit-message:
18+
prefix: "build"
19+
target-branch: "dependabotchanges"
20+
open-pull-requests-limit: 60
21+
22+
- package-ecosystem: "npm"
23+
directory: "/App/frontend"
24+
schedule:
25+
interval: "monthly"
26+
commit-message:
27+
prefix: "build"
28+
target-branch: "dependabotchanges"
29+
open-pull-requests-limit: 60
30+
registries:
31+
- npm_public_registry # Only use public npm registry
32+
33+
registries:
34+
npm_public_registry:
35+
type: "npm-registry"
36+
url: "https://registry.npmjs.org/"
37+
token: ${{ secrets.TOKEN }}

.github/workflows/bicep_deploy.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
name: CI-Validate Deployment
1+
name: CI-Validate Deployment-CKM-V2
22
on:
33
push:
44
branches:
5-
- main
6-
schedule:
7-
- cron: '0 6,18 * * *' # Runs at 6:00 AM and 6:00 PM GMT
5+
- ckm-v2
6+
87

98
jobs:
109
deploy:
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: CI-Validate Deployment-KM-Generic
2+
on:
3+
push:
4+
branches:
5+
6+
- main
7+
- dev
8+
- demo
9+
10+
schedule:
11+
- cron: '0 6,18 * * *' # Runs at 6:00 AM and 6:00 PM GMT
12+
13+
jobs:
14+
deploy:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout Code
18+
uses: actions/checkout@v3
19+
20+
- name: Setup Azure CLI
21+
run: |
22+
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
23+
az --version # Verify installation
24+
25+
- name: Login to Azure
26+
run: |
27+
az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
28+
29+
- name: Install Bicep CLI
30+
run: az bicep install
31+
32+
- name: Generate Resource Group Name
33+
id: generate_rg_name
34+
run: |
35+
echo "Generating a unique resource group name..."
36+
TIMESTAMP=$(date +%Y%m%d%H%M%S)
37+
COMMON_PART="ci-KMGeneric"
38+
UNIQUE_RG_NAME="${COMMON_PART}${TIMESTAMP}"
39+
echo "RESOURCE_GROUP_NAME=${UNIQUE_RG_NAME}" >> $GITHUB_ENV
40+
echo "Generated Resource_GROUP_PREFIX: ${UNIQUE_RG_NAME}"
41+
42+
- name: Create Resource Group
43+
run: |
44+
az group create --name ${{ env.RESOURCE_GROUP_NAME }} --location westeurope
45+
46+
- name: Generate Unique Solution Prefix
47+
id: generate_solution_prefix
48+
run: |
49+
set -e
50+
COMMON_PART="km"
51+
TIMESTAMP=$(date +%s)
52+
UPDATED_TIMESTAMP=$(echo $TIMESTAMP | tail -c 3)
53+
UNIQUE_SOLUTION_PREFIX="${COMMON_PART}${UPDATED_TIMESTAMP}"
54+
echo "SOLUTION_PREFIX=${UNIQUE_SOLUTION_PREFIX}" >> $GITHUB_ENV
55+
echo "Generated SOLUTION_PREFIX: ${UNIQUE_SOLUTION_PREFIX}"
56+
57+
58+
- name: Determine Tag Name Based on Branch
59+
id: determine_tag
60+
run: echo "tagname=${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo' || github.head_ref || 'default' }}" >> $GITHUB_OUTPUT
61+
62+
- name: Deploy Bicep Template
63+
id: deploy
64+
run: |
65+
set -e
66+
az deployment group create \
67+
--resource-group ${{ env.RESOURCE_GROUP_NAME }} \
68+
--template-file Deployment/bicep/main.bicep \
69+
--parameters solutionPrefix=${{ env.SOLUTION_PREFIX }} otherLocation=centralus imageTag=${{ steps.determine_tag.outputs.tagname }}
70+
71+
72+
73+
- name: Send Notification on Failure
74+
if: failure()
75+
run: |
76+
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
77+
78+
# Construct the email body
79+
EMAIL_BODY=$(cat <<EOF
80+
{
81+
"body": "<p>Dear Team,</p><p>We would like to inform you that the CKMv2 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>"
82+
}
83+
EOF
84+
)
85+
86+
# Send the notification
87+
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
88+
-H "Content-Type: application/json" \
89+
-d "$EMAIL_BODY" || echo "Failed to send notification"
90+
91+
92+
- name: Delete Bicep Deployment
93+
94+
run: |
95+
set -e
96+
echo "Checking if resource group exists..."
97+
rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
98+
if [ "$rg_exists" = "true" ]; then
99+
echo "Resource group exist. Cleaning..."
100+
az group delete \
101+
--name ${{ env.RESOURCE_GROUP_NAME }} \
102+
--yes \
103+
--no-wait
104+
echo "Resource group deleted... ${{ env.RESOURCE_GROUP_NAME }}"
105+
else
106+
echo "Resource group does not exists."
107+
fi
108+

.github/workflows/docker-build.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
- demo
9+
pull_request:
10+
types:
11+
- opened
12+
- ready_for_review
13+
- reopened
14+
- synchronize
15+
branches:
16+
- main
17+
- dev
18+
- demo
19+
workflow_dispatch:
20+
21+
jobs:
22+
build-and-push:
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v2
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v1
31+
32+
- name: Log in to Azure Container Registry
33+
if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' ) }}
34+
uses: azure/docker-login@v2
35+
with:
36+
login-server: ${{ secrets.ACR_LOGIN_SERVER }}
37+
username: ${{ secrets.ACR_USERNAME }}
38+
password: ${{ secrets.ACR_PASSWORD }}
39+
40+
- name: Get current date
41+
id: date
42+
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
43+
44+
- name: Output ACR Login Server
45+
run: |
46+
echo "ACR Login Server: ${{ secrets.ACR_LOGIN_SERVER }}"
47+
48+
- name: Determine Tag Name Based on Branch
49+
id: determine_tag
50+
run: |
51+
if [[ "${{ github.ref_name }}" == "main" ]]; then
52+
echo "tagname=latest" >> $GITHUB_OUTPUT
53+
elif [[ "${{ github.ref_name }}" == "dev" ]]; then
54+
echo "tagname=dev" >> $GITHUB_OUTPUT
55+
elif [[ "${{ github.ref_name }}" == "demo" ]]; then
56+
echo "tagname=demo" >> $GITHUB_OUTPUT
57+
else
58+
echo "tagname=default" >> $GITHUB_OUTPUT
59+
60+
fi
61+
- name: Build and Push Docker Image for WebApp
62+
uses: docker/build-push-action@v6
63+
with:
64+
context: ./App
65+
file: ./App/WebApp.Dockerfile
66+
push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' }}
67+
tags: |
68+
${{ secrets.ACR_LOGIN_SERVER }}/km-app:${{ steps.determine_tag.outputs.tagname }}
69+
${{ secrets.ACR_LOGIN_SERVER }}/km-app:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}
70+
71+
- name: Build and Push Docker Image for km-rag-function
72+
uses: docker/build-push-action@v6
73+
with:
74+
context: ./AzureFunctions/km-rag-function
75+
file: ./AzureFunctions/km-rag-function/Dockerfile
76+
push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' }}
77+
tags: |
78+
${{ secrets.ACR_LOGIN_SERVER }}/km-rag-function:${{ steps.determine_tag.outputs.tagname }}
79+
${{ secrets.ACR_LOGIN_SERVER }}/km-rag-function:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}
80+
81+
- name: Build and Push Docker Image for km-charts-function
82+
uses: docker/build-push-action@v6
83+
with:
84+
context: ./AzureFunctions/km-charts-function
85+
file: ./AzureFunctions/km-charts-function/Dockerfile
86+
push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' }}
87+
tags: |
88+
${{ secrets.ACR_LOGIN_SERVER }}/km-charts-function:${{ steps.determine_tag.outputs.tagname }}
89+
${{ secrets.ACR_LOGIN_SERVER }}/km-charts-function:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}

.github/workflows/pylint.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Pylint and Flake8
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+
14+
- name: Set up Python ${{ matrix.python-version }}
15+
uses: actions/setup-python@v3
16+
with:
17+
python-version: ${{ matrix.python-version }}
18+
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install -r App/requirements.txt
23+
pip install flake8 # Ensure flake8 is installed explicitly
24+
25+
- name: Run flake8 and pylint
26+
run: |
27+
flake8 --config=.flake8 App/backend # Specify the directory to lint

0 commit comments

Comments
 (0)