From f30ad079d4a2b05a02e0a80e507a507476b620b1 Mon Sep 17 00:00:00 2001 From: Krzysztof <35111684+kjurkiew@users.noreply.github.com> Date: Sat, 8 Mar 2025 13:27:25 +0100 Subject: [PATCH 01/12] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..374614aae --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,37 @@ +# 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: + Python38: + python.version: '3.8' + Python39: + python.version: '3.9' + Python310: + python.version: '3.10' + Python311: + python.version: '3.11' + +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: | + pip install pytest pytest-azurepipelines + pytest + displayName: 'pytest' From f3664b8d3f76fcd4ea13d3bc31a163979adb38c5 Mon Sep 17 00:00:00 2001 From: Krzysztof <35111684+kjurkiew@users.noreply.github.com> Date: Sat, 8 Mar 2025 14:25:07 +0100 Subject: [PATCH 02/12] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 374614aae..9578bb6a0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,6 +7,7 @@ trigger: - main pool: + name: 'default' vmImage: ubuntu-latest strategy: From 87ebdba1aa9aaa62a404f08db5bfb7e532205c5e Mon Sep 17 00:00:00 2001 From: Krzysztof <35111684+kjurkiew@users.noreply.github.com> Date: Sat, 8 Mar 2025 14:54:19 +0100 Subject: [PATCH 03/12] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9578bb6a0..225116aa3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -14,12 +14,12 @@ strategy: matrix: Python38: python.version: '3.8' - Python39: - python.version: '3.9' - Python310: - python.version: '3.10' - Python311: - python.version: '3.11' +# Python39: +# python.version: '3.9' +# Python310: +# python.version: '3.10' +# Python311: +# python.version: '3.11' steps: - task: UsePythonVersion@0 From 589d1401f98d89e2f36e9c2e21f47e07488a6447 Mon Sep 17 00:00:00 2001 From: Krzysztof <35111684+kjurkiew@users.noreply.github.com> Date: Sun, 9 Mar 2025 09:21:09 +0100 Subject: [PATCH 04/12] Update README.md Added status badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 068a76fd5..368373024 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Build Status](https://dev.azure.com/azr12202412/FabrikamFiber/_apis/build/status%2Fkjurkiew.python-sample-vscode-flask-tutorial?branchName=main)](https://dev.azure.com/azr12202412/FabrikamFiber/_build/latest?definitionId=1&branchName=main) # Python/Flask Tutorial for Visual Studio Code * This sample contains the completed program from the tutorial, make sure to visit the link: [Using Flask in Visual Studio Code](https://code.visualstudio.com/docs/python/tutorial-flask). Intermediate steps are not included. From 820b51b5805ffe07df9941d1d3a4f176c33a6fc3 Mon Sep 17 00:00:00 2001 From: Krzysztof <35111684+kjurkiew@users.noreply.github.com> Date: Sun, 9 Mar 2025 09:38:35 +0100 Subject: [PATCH 05/12] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines-1.yml | 19 +++++++++++++++++++ 1 file changed, 19 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..f53e97b6b --- /dev/null +++ b/azure-pipelines-1.yml @@ -0,0 +1,19 @@ +# Starter pipeline +# Start with a minimal pipeline that you can customize to build and deploy your code. +# Add steps that build, run tests, deploy, and more: +# https://aka.ms/yaml + +trigger: +- main + +pool: + vmImage: ubuntu-latest + +steps: +- script: echo Hello, world! + displayName: 'Run a one-line script' + +- script: | + echo Add other tasks to build, test, and deploy your project. + echo See https://aka.ms/yaml + displayName: 'Run a multi-line script' From 6735c0cd4c8fe31ebeaa7971799dae94e870d463 Mon Sep 17 00:00:00 2001 From: Krzysztof <35111684+kjurkiew@users.noreply.github.com> Date: Sun, 9 Mar 2025 09:42:04 +0100 Subject: [PATCH 06/12] Update azure-pipelines-1.yml for Azure Pipelines --- azure-pipelines-1.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/azure-pipelines-1.yml b/azure-pipelines-1.yml index f53e97b6b..57c69056e 100644 --- a/azure-pipelines-1.yml +++ b/azure-pipelines-1.yml @@ -6,8 +6,10 @@ trigger: - main + pool: vmImage: ubuntu-latest + name: 'default' steps: - script: echo Hello, world! From e1d532c898146a528f00959a8116e9f0c0ac68d1 Mon Sep 17 00:00:00 2001 From: Krzysztof <35111684+kjurkiew@users.noreply.github.com> Date: Sun, 9 Mar 2025 10:02:22 +0100 Subject: [PATCH 07/12] Update azure-pipelines-1.yml for Azure Pipelines --- azure-pipelines-1.yml | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/azure-pipelines-1.yml b/azure-pipelines-1.yml index 57c69056e..a5b533d64 100644 --- a/azure-pipelines-1.yml +++ b/azure-pipelines-1.yml @@ -6,16 +6,43 @@ trigger: - main - pool: - vmImage: ubuntu-latest name: 'default' +strategy: + matrix: + Python38: + python.version: '3.8' + Python39: + python.version: '3.9' +# Python312: + # python.version: '3.12' + steps: -- script: echo Hello, world! - displayName: 'Run a one-line script' + - 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' + - task: ArchiveFiles@2 + displayName: 'Archive files' + inputs: + rootFolderOrFile: $(System.DefaultWorkingDirectory) + includeRootFolder: false + archiveType: zip + archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId)-$(python.version).zip + replaceExistingArchive: true + - task: PublishBuildArtifacts@1 + inputs: + PathtoPublish: '$(Build.ArtifactStagingDirectory)' + ArtifactName: 'drop' + publishLocation: 'Container' -- script: | - echo Add other tasks to build, test, and deploy your project. - echo See https://aka.ms/yaml - displayName: 'Run a multi-line script' + - script: | + pip install pytest pytest-azurepipelines + pytest + displayName: 'pytest' \ No newline at end of file From 669e48f14f21f35267ebd4f742fdb08f7a63f212 Mon Sep 17 00:00:00 2001 From: Krzysztof <35111684+kjurkiew@users.noreply.github.com> Date: Sun, 9 Mar 2025 10:11:24 +0100 Subject: [PATCH 08/12] Update azure-pipelines-1.yml for Azure Pipelines --- azure-pipelines-1.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines-1.yml b/azure-pipelines-1.yml index a5b533d64..2be3d3677 100644 --- a/azure-pipelines-1.yml +++ b/azure-pipelines-1.yml @@ -15,8 +15,8 @@ strategy: python.version: '3.8' Python39: python.version: '3.9' -# Python312: - # python.version: '3.12' + Python310: + python.version: '3.10' steps: - task: UsePythonVersion@0 From 195879d6e14795bf080eac5db309581cfe1cf964 Mon Sep 17 00:00:00 2001 From: Krzysztof <35111684+kjurkiew@users.noreply.github.com> Date: Sun, 9 Mar 2025 13:33:52 +0100 Subject: [PATCH 09/12] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines-2.yml | 86 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 azure-pipelines-2.yml diff --git a/azure-pipelines-2.yml b/azure-pipelines-2.yml new file mode 100644 index 000000000..7265f7510 --- /dev/null +++ b/azure-pipelines-2.yml @@ -0,0 +1,86 @@ +# 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: 'a5dd3b02-393d-484d-9f87-6d882d1248e5' + + # Web app name + webAppName: 'pythonsamplevscodeflaskappkj' + + # Agent VM image name + vmImageName: 'ubuntu-latest' + + # Environment name + environmentName: 'pythonsamplevscodeflaskappkj' + + # Project root folder. Point to the folder containing manage.py file. + projectRoot: $(System.DefaultWorkingDirectory) + + pythonVersion: '3.11' + +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 : pythonsamplevscodeflaskappkj' + inputs: + azureSubscription: $(azureServiceConnectionId) + appName: $(webAppName) + package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip \ No newline at end of file From ed3304c079b29a8ed474f0b8abdffad4c71ec3e3 Mon Sep 17 00:00:00 2001 From: Krzysztof <35111684+kjurkiew@users.noreply.github.com> Date: Sun, 9 Mar 2025 13:37:02 +0100 Subject: [PATCH 10/12] Update azure-pipelines-2.yml for Azure Pipelines --- azure-pipelines-2.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines-2.yml b/azure-pipelines-2.yml index 7265f7510..729a8fce3 100644 --- a/azure-pipelines-2.yml +++ b/azure-pipelines-2.yml @@ -5,7 +5,8 @@ trigger: - main - +pool: + name: 'default' variables: # Azure Resource Manager connection created during pipeline creation azureServiceConnectionId: 'a5dd3b02-393d-484d-9f87-6d882d1248e5' From dddf1fe87ade0b28541c2c436bddda08c5a814ac Mon Sep 17 00:00:00 2001 From: Krzysztof <35111684+kjurkiew@users.noreply.github.com> Date: Sun, 9 Mar 2025 13:38:40 +0100 Subject: [PATCH 11/12] Update azure-pipelines-2.yml for Azure Pipelines --- azure-pipelines-2.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/azure-pipelines-2.yml b/azure-pipelines-2.yml index 729a8fce3..c6ca71266 100644 --- a/azure-pipelines-2.yml +++ b/azure-pipelines-2.yml @@ -5,8 +5,7 @@ trigger: - main -pool: - name: 'default' + variables: # Azure Resource Manager connection created during pipeline creation azureServiceConnectionId: 'a5dd3b02-393d-484d-9f87-6d882d1248e5' @@ -32,6 +31,7 @@ stages: - job: BuildJob pool: vmImage: $(vmImageName) + name: 'default' steps: - task: UsePythonVersion@0 inputs: @@ -68,6 +68,7 @@ stages: - deployment: DeploymentJob pool: vmImage: $(vmImageName) + name: 'default' environment: $(environmentName) strategy: runOnce: From 435d56260a2e7d62469b05a818380b45158535e6 Mon Sep 17 00:00:00 2001 From: Krzysztof <35111684+kjurkiew@users.noreply.github.com> Date: Sun, 9 Mar 2025 13:48:22 +0100 Subject: [PATCH 12/12] Update azure-pipelines-2.yml for Azure Pipelines --- azure-pipelines-2.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/azure-pipelines-2.yml b/azure-pipelines-2.yml index c6ca71266..e38ffbb88 100644 --- a/azure-pipelines-2.yml +++ b/azure-pipelines-2.yml @@ -17,12 +17,12 @@ variables: vmImageName: 'ubuntu-latest' # Environment name - environmentName: 'pythonsamplevscodeflaskappkj' + environmentName: 'pythonsamplevscodeflaskappbz' # Project root folder. Point to the folder containing manage.py file. projectRoot: $(System.DefaultWorkingDirectory) - pythonVersion: '3.11' + pythonVersion: '3.9' stages: - stage: Build @@ -30,7 +30,7 @@ stages: jobs: - job: BuildJob pool: - vmImage: $(vmImageName) + #vmImage: $(vmImageName) name: 'default' steps: - task: UsePythonVersion@0 @@ -67,7 +67,7 @@ stages: jobs: - deployment: DeploymentJob pool: - vmImage: $(vmImageName) + #vmImage: $(vmImageName) name: 'default' environment: $(environmentName) strategy: