From 36e5370a7d9dca9b28f3d3480d90376e9c14be05 Mon Sep 17 00:00:00 2001 From: Garret Wassermann Date: Fri, 15 Oct 2021 02:20:40 -0400 Subject: [PATCH] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 62 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..cc39374a --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,62 @@ +# Python Django +# Test a Django project on multiple versions of Python. +# Add steps that analyze code, save build artifacts, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/python + +trigger: +- master + +pool: + vmImage: ubuntu-latest +strategy: + matrix: + Python36: + PYTHON_VERSION: '3.6' + Python37: + PYTHON_VERSION: '3.7' + Python38: + PYTHON_VERSION: '3.8' + Python39: + PYTHON_VERSION: '3.9' + Python310: + PYTHON_VERSION: '3.10' + maxParallel: 5 + +steps: +- task: UsePythonVersion@0 + inputs: + versionSpec: '$(PYTHON_VERSION)' + architecture: 'x64' + +- task: PythonScript@0 + displayName: 'Export project path' + inputs: + scriptSource: 'inline' + script: | + """Search all subdirectories for `manage.py`.""" + from glob import iglob + from os import path + # Python >= 3.5 + manage_py = next(iglob(path.join('**', 'manage.py'), recursive=True), None) + if not manage_py: + raise SystemExit('Could not find a Django project') + project_location = path.dirname(path.abspath(manage_py)) + print('Found Django project in', project_location) + print('##vso[task.setvariable variable=projectRoot]{}'.format(project_location)) + +- script: | + python -m pip install --upgrade pip setuptools wheel + pip install -r requirements.txt + pip install unittest-xml-reporting + displayName: 'Install prerequisites' + +- script: | + pushd '$(projectRoot)' + python manage.py test --testrunner xmlrunner.extra.djangotestrunner.XMLTestRunner --no-input + displayName: 'Run tests' + +- task: PublishTestResults@2 + inputs: + testResultsFiles: "**/TEST-*.xml" + testRunTitle: 'Python $(PYTHON_VERSION)' + condition: succeededOrFailed()