From 1dc76368c22d7a7ed9f4561d70d8cca2f9dbefbf Mon Sep 17 00:00:00 2001 From: Angie Surf Date: Wed, 16 Dec 2020 03:28:08 +0000 Subject: [PATCH 1/6] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 87 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..2e76690af --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,87 @@ +# Python to Linux Web App on Azure +# Build your Python project and deploy it to Azure as a Linux Web App. +# Change python version to one thats appropriate for your application. +# https://docs.microsoft.com/azure/devops/pipelines/languages/python + +trigger: +- main + +variables: + # Azure Resource Manager connection created during pipeline creation + azureServiceConnectionId: 'c423dcd5-a239-4cc7-af01-9729ec5c9125' + + # Web app name + webAppName: 'python-sample-vscode-flask-tutorial-mv' + + # Agent VM image name + vmImageName: 'ubuntu-latest' + + # Environment name + environmentName: 'python-sample-vscode-flask-tutorial-mv' + + # Project root folder. Point to the folder containing manage.py file. + projectRoot: $(System.DefaultWorkingDirectory) + + # Python version: 3.7 + pythonVersion: '3.7' + +stages: +- stage: Build + displayName: Build stage + jobs: + - job: BuildJob + pool: + vmImage: $(vmImageName) + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(pythonVersion)' + displayName: 'Use Python $(pythonVersion)' + + - script: | + python -m venv antenv + source antenv/bin/activate + python -m pip install --upgrade pip + pip install setup + pip install -r requirements.txt + workingDirectory: $(projectRoot) + displayName: "Install requirements" + + - task: ArchiveFiles@2 + displayName: 'Archive files' + inputs: + rootFolderOrFile: '$(projectRoot)' + includeRootFolder: false + archiveType: zip + archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip + replaceExistingArchive: true + + - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip + displayName: 'Upload package' + artifact: drop + +- stage: Deploy + displayName: 'Deploy Web App' + dependsOn: Build + condition: succeeded() + jobs: + - deployment: DeploymentJob + pool: + vmImage: $(vmImageName) + environment: $(environmentName) + strategy: + runOnce: + deploy: + steps: + + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(pythonVersion)' + displayName: 'Use Python version' + + - task: AzureWebApp@1 + displayName: 'Deploy Azure Web App : python-sample-vscode-flask-tutorial-mv' + inputs: + azureSubscription: $(azureServiceConnectionId) + appName: $(webAppName) + package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip \ No newline at end of file From e6441370a5f0ac481d6a6b8056020893ce2f9f76 Mon Sep 17 00:00:00 2001 From: Angie Surf Date: Wed, 16 Dec 2020 03:35:54 +0000 Subject: [PATCH 2/6] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2e76690af..393729906 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -84,4 +84,30 @@ stages: inputs: azureSubscription: $(azureServiceConnectionId) appName: $(webAppName) - package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip \ No newline at end of file + package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip + jobs: + - deployment: DeploymentJob + pool: + vmImage: $(vmImageName) + environment: $(environmentName) + strategy: + runOnce: + deploy: + steps: + + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(pythonVersion)' + displayName: 'Use Python version' + + - task: AzureWebApp@1 + displayName: 'Deploy Azure Web App : {{ webAppName }}' + inputs: + azureSubscription: $(azureServiceConnectionId) + appName: $(webAppName) + package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip + + # The following parameter is specific to the Flask example code. You may + # or may not need a startup command for your app. + + startUpCommand: 'gunicorn --bind=0.0.0.0 --workers=4 startup:app' \ No newline at end of file From 1cd27039e26caf33337fa54e462b72335388e54d Mon Sep 17 00:00:00 2001 From: Angie Surf Date: Wed, 16 Dec 2020 03:36:59 +0000 Subject: [PATCH 3/6] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 393729906..b822975fe 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -85,28 +85,6 @@ stages: azureSubscription: $(azureServiceConnectionId) appName: $(webAppName) package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip - jobs: - - deployment: DeploymentJob - pool: - vmImage: $(vmImageName) - environment: $(environmentName) - strategy: - runOnce: - deploy: - steps: - - - task: UsePythonVersion@0 - inputs: - versionSpec: '$(pythonVersion)' - displayName: 'Use Python version' - - - task: AzureWebApp@1 - displayName: 'Deploy Azure Web App : {{ webAppName }}' - inputs: - azureSubscription: $(azureServiceConnectionId) - appName: $(webAppName) - package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip - # The following parameter is specific to the Flask example code. You may # or may not need a startup command for your app. From 93c8a9214565f727676306e526ac5bf7e2b5742a Mon Sep 17 00:00:00 2001 From: Angie Surf Date: Wed, 16 Dec 2020 03:37:41 +0000 Subject: [PATCH 4/6] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b822975fe..dcb8994ab 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -88,4 +88,4 @@ stages: # The following parameter is specific to the Flask example code. You may # or may not need a startup command for your app. - startUpCommand: 'gunicorn --bind=0.0.0.0 --workers=4 startup:app' \ No newline at end of file + startUpCommand: 'gunicorn --bind=0.0.0.0 --workers=4 startup:app' \ No newline at end of file From e669956e0c0b69a497089d1c0f289e717fc0e104 Mon Sep 17 00:00:00 2001 From: Angie Surf Date: Wed, 16 Dec 2020 04:01:17 +0000 Subject: [PATCH 5/6] Set up CI with Azure Pipelines python [skip ci] --- azure-pipelines-1.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 azure-pipelines-1.yml diff --git a/azure-pipelines-1.yml b/azure-pipelines-1.yml new file mode 100644 index 000000000..64d7b4058 --- /dev/null +++ b/azure-pipelines-1.yml @@ -0,0 +1,38 @@ +# Python package +# Create and test a Python package on multiple Python versions. +# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/python + +trigger: +- main + +pool: + vmImage: 'ubuntu-latest' +strategy: + matrix: + Python27: + python.version: '2.7' + Python35: + python.version: '3.5' + Python36: + python.version: '3.6' + Python37: + python.version: '3.7' + +steps: +- task: UsePythonVersion@0 + inputs: + versionSpec: '$(python.version)' + displayName: 'Use Python $(python.version)' + +- script: | + python -m pip install --upgrade pip + pip install -r requirements.txt + displayName: 'Install dependencies' + +- script: python src/example.py + +- script: | + pip install pytest pytest-azurepipelines + pytest + displayName: 'pytest' From 4b3667b0c80cf8d2d848ed471a6bd8a0622ee4b9 Mon Sep 17 00:00:00 2001 From: Angie Surf Date: Wed, 16 Dec 2020 04:08:14 +0000 Subject: [PATCH 6/6] Update azure-pipelines-1.yml for Azure Pipelines --- azure-pipelines-1.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/azure-pipelines-1.yml b/azure-pipelines-1.yml index 64d7b4058..ab4319cbc 100644 --- a/azure-pipelines-1.yml +++ b/azure-pipelines-1.yml @@ -30,8 +30,6 @@ steps: pip install -r requirements.txt displayName: 'Install dependencies' -- script: python src/example.py - - script: | pip install pytest pytest-azurepipelines pytest