Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize the project content and add/updates features #280

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -756,3 +756,7 @@ sbom-reports/

# Azure dev tunnels local installation
DevTunnels/

# Fake data for demos
app/helpers/db
UPDATES.md
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
callcenterai311
test
74 changes: 41 additions & 33 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Global Path
app_config_folder = "configs"
# Versioning
version_full ?= $(shell $(MAKE) --silent version-full)
version_small ?= $(shell $(MAKE) --silent version)
# DevTunnel configuration
# Dev tunnels configuration
tunnel_name := call-center-ai-$(shell hostname | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]')
tunnel_url ?= $(shell res=$$(devtunnel show $(tunnel_name) | grep -o 'http[s]*://[^"]*' | xargs) && echo $${res%/})
# App location
Expand All @@ -13,21 +15,23 @@ search_location := francecentral
# Sanitize variables
name_sanitized := $(shell echo $(name) | tr '[:upper:]' '[:lower:]')
# App configuration
bot_phone_number ?= $(shell cat config.yaml | yq '.communication_services.phone_number')
bot_phone_number ?= $(shell cat $(app_config_folder)/config.yaml | yq '.communication_services.phone_number')
event_subscription_name ?= $(shell echo '$(name_sanitized)-$(bot_phone_number)' | tr -dc '[:alnum:]-')
twilio_phone_number ?= $(shell cat config.yaml | yq '.sms.twilio.phone_number')
twilio_phone_number ?= $(shell cat $(app_config_folder)/config.yaml | yq '.sms.twilio.phone_number')
# Bicep outputs
app_url ?= $(shell az deployment sub show --name $(name_sanitized) | yq '.properties.outputs["appUrl"].value')
blob_storage_public_name ?= $(shell az deployment sub show --name $(name_sanitized) | yq '.properties.outputs["blobStoragePublicName"].value')
communication_id ?= $(shell az deployment sub show --name $(name_sanitized) | yq '.properties.outputs["communicationId"].value')
function_app_name ?= $(shell az deployment sub show --name $(name_sanitized) | yq '.properties.outputs["functionAppName"].value')
log_analytics_workspace_customer_id ?= $(shell az deployment sub show --name $(name_sanitized) | yq '.properties.outputs["logAnalyticsWorkspaceName"].value')
# Resource Infra deployment
enable_content_filter := false

version:
@bash ./cicd/version/version.sh -g . -c
@bash ./infra/cicd/version/version.sh -g . -c

version-full:
@bash ./cicd/version/version.sh -g . -c -m
@bash ./infra/cicd/version/version.sh -g . -c -m

brew:
@echo "➡️ Installing yq..."
Expand Down Expand Up @@ -66,12 +70,12 @@ upgrade:
python3 -m pip install --upgrade pip-tools

@echo "➡️ Compiling app requirements..."
pip-compile \
cd ./app && pip-compile \
--output-file requirements.txt \
pyproject.toml

@echo "➡️ Compiling dev requirements..."
pip-compile \
cd ./app && pip-compile \
--extra dev \
--output-file requirements-dev.txt \
pyproject.toml
Expand All @@ -81,31 +85,31 @@ upgrade:

test:
@echo "➡️ Test generic formatter (Black)..."
python3 -m black --check .
cd ./app && python3 -m black --check .

@echo "➡️ Test import formatter (isort)..."
python3 -m isort --jobs -1 --check .
cd ./app && python3 -m isort --jobs -1 --check .

@echo "➡️ Test dependencies issues (deptry)..."
python3 -m deptry .
cd ./app && python3 -m deptry .

@echo "➡️ Test code smells (Pylint)..."
python3 -m pylint .
cd ./app && python3 -m pylint .

@echo "➡️ Test types (Pyright)..."
python3 -m pyright .
cd ./app && python3 -m pyright .

@echo "➡️ Unit tests (Pytest)..."
PUBLIC_DOMAIN=dummy pytest \
cd ./app && PUBLIC_DOMAIN=dummy pytest \
--junit-xml=test-reports/$(version_full).xml \
tests/*.py

lint:
@echo "➡️ Fix with generic formatter (Black)..."
python3 -m black .
cd ./app && python3 -m black .

@echo "➡️ Fix with import formatter (isort)..."
python3 -m isort --jobs -1 .
cd ./app && python3 -m isort --jobs -1 .

tunnel:
@echo "➡️ Creating tunnel..."
Expand All @@ -118,9 +122,25 @@ tunnel:
devtunnel host $(tunnel_name)

dev:
VERSION=$(version_full) PUBLIC_DOMAIN=$(tunnel_url) func start
cd ./app && VERSION=$(version_full) PUBLIC_DOMAIN=$(tunnel_url) func start --python

deploy:
$(MAKE) deploy-bicep

@echo "💤 Wait 10 secs for output to be available..."
sleep 10

@echo "🛠️ Deploying Function App..."
func azure functionapp publish $(function_app_name) \
--build local \
--build-native-deps \
--python

@echo "🚀 Call Center AI is running on $(app_url)"

@$(MAKE) deploy-post

deploy-bicep:
@echo "👀 Current subscription:"
@az account show --query "{subscriptionId:id, subscriptionName:name, tenantId:tenantId}" --output table

Expand All @@ -134,23 +154,11 @@ deploy:
'openaiLocation=$(openai_location)' \
'searchLocation=$(search_location)' \
'version=$(version_full)' \
--template-file bicep/main.bicep \
'enableContentFilter=$(enable_content_filter)' \
--template-file infra/bicep/main.bicep \
--name $(name_sanitized)

@echo "💤 Wait 10 secs for output to be available..."
sleep 10

@echo "🛠️ Deploying Function App..."
func azure functionapp publish $(function_app_name) \
--build local \
--build-native-deps \
--python

@echo "🚀 Call Center AI is running on $(app_url)"

@$(MAKE) post-deploy name=$(name_sanitized)

post-deploy:
deploy-post:
@$(MAKE) copy-resources \
name=$(blob_storage_public_name)

Expand All @@ -170,7 +178,7 @@ destroy:
az deployment sub delete --name $(name_sanitized)

logs:
func azure functionapp logstream $(function_app_name) \
cd ./app && func azure functionapp logstream $(function_app_name) \
--browser

twilio-register:
Expand All @@ -180,7 +188,7 @@ twilio-register:

copy-resources:
@echo "📦 Copying resources to Azure storage account..."
az storage blob upload-batch \
cd ./app && az storage blob upload-batch \
--account-name $(name_sanitized) \
--destination '$$web' \
--no-progress \
Expand Down
Loading