This project demonstrates how to build GitHub repository from scratch and creating a scaffolding that will assist in performing both Continuous integration and Continuous Delivery. Some of the other actions include
- Creating Github Actions along with a Makefile, requirement.txt file
- Application code to perform initial lint, test and install cycle.
- And lastly integrating the project with Azure Pipelines to enable Continuous Delivery to Azure App Service.
A short demo of the project is included here.
Fine below flow of the project
In this spreedsheet, I have included a quarterly and yearly plan. also included is a estimated week by week deliverables with an estimated time of difficulity for each task.
In the trello board i have included a simple board based flow as below
- To Do,
- In Progress and
- Done
I created a GitHub Repo then created a ssh-keys in my Azure Cloud Shell environment after which i clone the newly created repo into Azure Cloud Shell, screenshot below
pip install --upgrade pip &&\
pip install -r requirements.txt
test:
python -m pytest -vv test_hello.py
lint:
pylint --disable=R,C hello.py
all: install lint test
pylint
pytest
Flask==2.0.3
pandas==0.24.2
scikit-learn==0.20.3
jinja2==3.0
python3 -m venv ~/.CI-CDpipeline
source ~/.CI-CDpipeline/bin/activate
(.CI-CDpipeline) lawal@Azure:~/CI-CDpipeline$ make all
Testing it locally to check the prediction by running python app.py and running ./make_prediction.sh to see the prediction locally
This is to create a gitHub Actions to test the project upon change events in GitHub. This is a necessary step to performing Continuous Integration remotely.
Enable Github Actions and replace yml code with below:
name: Python application test with Github Actions
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.5
uses: actions/setup-python@v1
with:
python-version: 3.5
- name: Install dependencies
run: |
make install
- name: Lint with pylint
run: |
make lint
- name: Test with pytest
run: |
make test
Lastly i put the changes to GitHub and verify both lint
and test
See screenshot below
Final step in the project is to set Continuous Delivery using Azure technologies. This will involve setting up Azure Pipelines to deploy the Flask starter code to Azure App Services.
Deploy the web app to azure using az webapp up -n
(.CI-CDpipeline) lawal@Azure:~/CI-CDpipeline$ az webapp up -n azurecicdpipeline
Check if the app is up and running by opening the URL containing the webapp name provided in the previous step: https://azurecicdpipleline.azurewebsites.net/
Edit file 'make_predict_azure_app.sh' and replace '< yourappname >' with your webapp name (e.g. azurecicdpipeline).
Test the remote webapp:
(.CI-CDpipeline) lawal@Azure:~/CI-CDpipeline$ az webapp log tail
Performance validation of the webapp can be performed via a load test using locust. Replace '< yourappname >' in the provided configuration and call locust:
Using the parameters above locust will use 20 users with a spawn rate of 5 users per second and run for 20 seconds:
(.CI-CDpipeline) lawal@Azure:~/CI-CDpipeline$ locust -f locustfile.py --headless -u 20 -r 5 -t 20s
- Goto Azure DevOps Organizations, create a new project called CICDAzuredev
- Ensure you set up a new service connection via Azure Resource Manager and Pipeline
- Goto organizations setting > new service connection (under pipeline) > Azure Resource Manager
- Next, select Pipeline and create a new one
- Create the GitHub Integration
- Configure python to Linux Web app on Azure
- Set up the continuous delivery workflow
From now on every change to your code will trigger the CI/CD pipeline and update your webapp accordingly:
See below example of resent work after deployment
From Azure CLI do Git pull and Push so that everything will be up to date
- Further improvement on the user interface of the application to make it user friendly.
- Users can eastly use a click button for prediction
Video demonstration here