From 7a5071c4649e4c788294f65d3e3cab4efad59986 Mon Sep 17 00:00:00 2001 From: Mike Sedelmeyer <20605812+sedelmeyer@users.noreply.github.com> Date: Sun, 28 Jun 2020 07:42:11 -0400 Subject: [PATCH 1/5] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..7d405f9ee --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,36 @@ +# 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: +- master + +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: | + pip install pytest pytest-azurepipelines + pytest + displayName: 'pytest' From fc7661daf00628ebf77a8332ba4c965a52c84967 Mon Sep 17 00:00:00 2001 From: Mike Sedelmeyer <20605812+sedelmeyer@users.noreply.github.com> Date: Sun, 28 Jun 2020 07:49:11 -0400 Subject: [PATCH 2/5] readme: add azure pipelines build badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d07d6d8ed..a91ab24e4 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ * 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. * It also contains the Dockerfile and uwsgi.ini files necessary to build a container with a production server. The resulting image works both locally and when deployed to Azure App Service. See [Deploy Python using Docker containers](https://code.visualstudio.com/docs/python/tutorial-deploy-containers). +[![Build Status](https://dev.azure.com/sedelmeyer/python-sample-vscode-flask-tutorial/_apis/build/status/sedelmeyer.python-sample-vscode-flask-tutorial?branchName=master)](https://dev.azure.com/sedelmeyer/python-sample-vscode-flask-tutorial/_build/latest?definitionId=1&branchName=master) + ## Navigation The `startup.py` file, for its part, is specifically for deploying to Azure App Service on Linux without containers. Because the app code is in its own *module* in the `hello_app` folder (which has an `__init__.py`), trying to start the Gunicorn server within App Service on Linux produces an "Attempted relative import in non-package" error. The `startup.py` file, therefore, is just a shim to import the app object from the `hello_app` module, which then allows you to use startup:app in the Gunicorn command line (see `startup.txt`). From b9a102ddee7cae90d91cec0ffc09b15051497ea9 Mon Sep 17 00:00:00 2001 From: Mike Sedelmeyer <20605812+sedelmeyer@users.noreply.github.com> Date: Sun, 28 Jun 2020 10:52:53 -0400 Subject: [PATCH 3/5] Try multi-OSes, Ubuntu and Win --- azure-pipelines.yml | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7d405f9ee..b1ae2def8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -6,24 +6,36 @@ trigger: - master -pool: - vmImage: 'ubuntu-latest' strategy: matrix: - Python27: - python.version: '2.7' - Python35: - python.version: '3.5' - Python36: + linux_py36: + vm.image: 'ubuntu-latest' + python.version: '3.6' + linux_py37: + vm.image: 'ubuntu-latest' + python.version: '3.7' + linux_py38: + vm.image: 'ubuntu-latest' + python.version: '3.8' + win_py36: + vm.image: 'vs2016-win2016' python.version: '3.6' - Python37: + win_py37: + vm.image: 'vs2016-win2016' python.version: '3.7' + win_py38: + vm.image: 'vs2016-win2016' + python.version: '3.8' + + +pool: + vmImage: $(imageName) steps: - task: UsePythonVersion@0 inputs: versionSpec: '$(python.version)' - displayName: 'Use Python $(python.version)' + displayName: 'Use $(vm.image) Python $(python.version)' - script: | python -m pip install --upgrade pip From ade6d561857513d3a49af9662864727f2acdf610 Mon Sep 17 00:00:00 2001 From: Mike Sedelmeyer <20605812+sedelmeyer@users.noreply.github.com> Date: Sun, 28 Jun 2020 10:54:15 -0400 Subject: [PATCH 4/5] fix vm.image var name --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b1ae2def8..9a03d2f78 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -29,7 +29,7 @@ strategy: pool: - vmImage: $(imageName) + vmImage: $(vm.image) steps: - task: UsePythonVersion@0 From 5ae18d305ab8b51533aad45bbf9936e0acdbda52 Mon Sep 17 00:00:00 2001 From: Mike Sedelmeyer <20605812+sedelmeyer@users.noreply.github.com> Date: Sun, 28 Jun 2020 10:55:40 -0400 Subject: [PATCH 5/5] fix windows vm.image name --- azure-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9a03d2f78..7ea8bf1ff 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -18,13 +18,13 @@ strategy: vm.image: 'ubuntu-latest' python.version: '3.8' win_py36: - vm.image: 'vs2016-win2016' + vm.image: 'vs2017-win2016' python.version: '3.6' win_py37: - vm.image: 'vs2016-win2016' + vm.image: 'vs2017-win2016' python.version: '3.7' win_py38: - vm.image: 'vs2016-win2016' + vm.image: 'vs2017-win2016' python.version: '3.8'