From b69364fe17b1619c62fecc5f650880ec3d637dc6 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Mon, 3 Apr 2023 08:55:27 +0200 Subject: [PATCH] Add azure pipelines (#4453) * Set up CI with Azure Pipelines [skip ci] * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * move ci file * Update testing_ci.yml for Azure Pipelines * update to use pytest * update settings path * unittests again * Update testing_ci.yml for Azure Pipelines * remove html report * add backup dir * fix name * also install dev reqs * fix name * Add poppler * add poppler utils * Add ignore flag --- .devops/testing_ci.yml | 71 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .devops/testing_ci.yml diff --git a/.devops/testing_ci.yml b/.devops/testing_ci.yml new file mode 100644 index 0000000000..67d12d6503 --- /dev/null +++ b/.devops/testing_ci.yml @@ -0,0 +1,71 @@ +# 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: + Python39: + PYTHON_VERSION: '3.9' + maxParallel: 3 + +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 -r requirements-dev.txt + pip install unittest-xml-reporting coverage invoke + sudo apt-get install poppler-utils + sudo apt-get install libpoppler-dev + displayName: 'Install prerequisites' + +- script: | + pushd '$(projectRoot)' + invoke update + coverage run manage.py test --testrunner xmlrunner.extra.djangotestrunner.XMLTestRunner --no-input + coverage xml -i + displayName: 'Run tests' + env: + INVENTREE_DB_ENGINE: sqlite3 + INVENTREE_DB_NAME: inventree + INVENTREE_MEDIA_ROOT: ./media + INVENTREE_STATIC_ROOT: ./static + INVENTREE_BACKUP_DIR: ./backup + INVENTREE_PLUGINS_ENABLED: true + +- task: PublishTestResults@2 + inputs: + testResultsFiles: "**/TEST-*.xml" + testRunTitle: 'Python $(PYTHON_VERSION)' + condition: succeededOrFailed() + +- task: PublishCodeCoverageResults@1 + inputs: + codeCoverageTool: Cobertura + summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'