From 5c525edcaa7da2b2076a6eca6c5bc19aa93fc437 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Sun, 5 Apr 2020 00:06:40 -0400 Subject: [PATCH] Redo test structure for azure Signed-off-by: Dan Ryan --- .azure-pipelines/steps/create-virtualenv.yml | 45 ------------- .../steps/install-dependencies.yml | 27 +++++++- .azure-pipelines/steps/reinstall-pythons.yml | 34 ---------- .azure-pipelines/steps/run-tests-linux.yml | 17 ++++- .azure-pipelines/steps/run-tests-windows.yml | 66 ++++++++++++------- .azure-pipelines/steps/run-tests.yml | 8 +-- azure-pipelines.yml | 34 +--------- 7 files changed, 89 insertions(+), 142 deletions(-) delete mode 100644 .azure-pipelines/steps/create-virtualenv.yml delete mode 100644 .azure-pipelines/steps/reinstall-pythons.yml diff --git a/.azure-pipelines/steps/create-virtualenv.yml b/.azure-pipelines/steps/create-virtualenv.yml deleted file mode 100644 index 3ad3a496..00000000 --- a/.azure-pipelines/steps/create-virtualenv.yml +++ /dev/null @@ -1,45 +0,0 @@ -parameters: - python_version: '' - -steps: - -- script: | - echo "##vso[task.setvariable variable=LANG]C.UTF-8" - echo "##vso[task.setvariable variable=PIP_PROCESS_DEPENDENCY_LINKS]1" - displayName: Set Environment Variables - -- ${{ if eq(parameters.vmImage, 'windows-latest') }}: - - powershell: | - pip install certifi - $env:PYTHON_PATH=$(python -c "import sys; print(sys.executable)") - $env:CERTIFI_CONTENT=$(python -m certifi) - echo "##vso[task.setvariable variable=GIT_SSL_CAINFO]$env:CERTIFI_CONTENT" - echo "##vso[task.setvariable variable=PY_EXE]$env:PYTHON_PATH" - displayName: Set Python Path - env: - PYTHONWARNINGS: 'ignore:DEPRECATION' -- ${{ if ne(parameters.vmImage, 'windows-latest') }}: - - bash: | - pip install certifi - PYTHON_PATH=$(python -c 'import sys; print(sys.executable)') - CERTIFI_CONTENT=$(python -m certifi) - echo "##vso[task.setvariable variable=GIT_SSL_CAINFO]$CERTIFI_CONTENT" - echo "##vso[task.setvariable variable=PY_EXE]$PYTHON_PATH" - displayName: Set Python Path - env: - PYTHONWARNINGS: 'ignore:DEPRECATION' - -- script: | - echo "Python path: $(PY_EXE)" - echo "GIT_SSL_CAINFO: $(GIT_SSL_CAINFO)" - echo "PIPENV PYTHON VERSION: $(python.version)" - echo "python_version: ${{ parameters.python_version }}" - git submodule sync - git submodule update --init --recursive - $(PY_EXE) -m pip install "virtualenv<20" - $(PY_EXE) -m pipenv install --deploy --dev --python="$(PY_EXE)" - env: - PIPENV_DEFAULT_PYTHON_VERSION: ${{ parameters.python_version }} - PYTHONWARNINGS: 'ignore:DEPRECATION' - PIPENV_NOSPIN: '1' - displayName: Make Virtualenv diff --git a/.azure-pipelines/steps/install-dependencies.yml b/.azure-pipelines/steps/install-dependencies.yml index 4e179d2a..c537447d 100644 --- a/.azure-pipelines/steps/install-dependencies.yml +++ b/.azure-pipelines/steps/install-dependencies.yml @@ -1,5 +1,30 @@ +parameters: + python_version: '' + steps: -- script: 'python -m pip install --upgrade pip setuptools wheel --upgrade-strategy=eager && python -m pip install -e . --upgrade' + +- script: | + echo "##vso[task.setvariable variable=LANG]C.UTF-8" + echo "##vso[task.setvariable variable=PIP_PROCESS_DEPENDENCY_LINKS]1" + displayName: Set Environment Variables + +- script: | + echo "Python path: $(PY_EXE)" + echo "GIT_SSL_CAINFO: $(GIT_SSL_CAINFO)" + echo "PIPENV PYTHON VERSION: $(python.version)" + echo "python_version: ${{ parameters.python_version }}" + git submodule sync + git submodule update --init --recursive + $(PY_EXE) -m pip install --upgrade --upgrade-strategy=eager pip setuptools wheel + $(PY_EXE) -m pip install "virtualenv<20" + $(PY_EXE) -m pipenv install --deploy --dev --python="$(PY_EXE)" + env: + PIPENV_DEFAULT_PYTHON_VERSION: ${{ parameters.python_version }} + PYTHONWARNINGS: 'ignore:DEPRECATION' + PIPENV_NOSPIN: '1' + displayName: Make Virtualenv + +- script: 'python -m pip install -e . --upgrade' displayName: Upgrade Pip & Install Pipenv env: PYTHONWARNINGS: 'ignore:DEPRECATION' diff --git a/.azure-pipelines/steps/reinstall-pythons.yml b/.azure-pipelines/steps/reinstall-pythons.yml deleted file mode 100644 index 79647925..00000000 --- a/.azure-pipelines/steps/reinstall-pythons.yml +++ /dev/null @@ -1,34 +0,0 @@ -steps: - - script: | - # When you paste this, please make sure the indentation is preserved - # Fail out if any setups fail - set -e - - # Delete old Pythons - rm -rf $AGENT_TOOLSDIRECTORY/Python/2.7.16 - rm -rf $AGENT_TOOLSDIRECTORY/Python/3.5.7 - rm -rf $AGENT_TOOLSDIRECTORY/Python/3.7.3 - [ -e $AGENT_TOOLSDIRECTORY/Python/3.7.2 ] && [ -e $AGENT_TOOLSDIRECTORY/Python/3.5.5 ] && [ -e $AGENT_TOOLSDIRECTORY/Python/2.7.15 ] && exit 0 - # Download new Pythons - azcopy --recursive \ - --source https://vstsagenttools.blob.core.windows.net/tools/hostedtoolcache/linux/Python/2.7.15 \ - --destination $AGENT_TOOLSDIRECTORY/Python/2.7.15 - - azcopy --recursive \ - --source https://vstsagenttools.blob.core.windows.net/tools/hostedtoolcache/linux/Python/3.5.5 \ - --destination $AGENT_TOOLSDIRECTORY/Python/3.5.5 - - azcopy --recursive \ - --source https://vstsagenttools.blob.core.windows.net/tools/hostedtoolcache/linux/Python/3.7.2 \ - --destination $AGENT_TOOLSDIRECTORY/Python/3.7.2 - - # Install new Pythons - original_directory=$PWD - setups=$(find $AGENT_TOOLSDIRECTORY/Python -name setup.sh) - for setup in $setups; do - chmod +x $setup; - cd $(dirname $setup); - ./$(basename $setup); - cd $original_directory; - done; - displayName: 'Workaround: roll back Python versions' diff --git a/.azure-pipelines/steps/run-tests-linux.yml b/.azure-pipelines/steps/run-tests-linux.yml index a786f873..dbb13f94 100644 --- a/.azure-pipelines/steps/run-tests-linux.yml +++ b/.azure-pipelines/steps/run-tests-linux.yml @@ -2,11 +2,26 @@ parameters: python_version: '' steps: + +- bash: | + pip install certifi + PYTHON_PATH=$(python -c 'import sys; print(sys.executable)') + CERTIFI_CONTENT=$(python -m certifi) + echo "##vso[task.setvariable variable=GIT_SSL_CAINFO]$CERTIFI_CONTENT" + echo "##vso[task.setvariable variable=PY_EXE]$PYTHON_PATH" + displayName: Set Python Path + env: + PYTHONWARNINGS: 'ignore:DEPRECATION' + +- template: install-dependencies.yml + parameters: + python_version: ${{ parameters.python_version }} + - script: | # Fix Git SSL errors echo "Using pipenv python version: $(PIPENV_DEFAULT_PYTHON_VERSION)" git submodule sync && git submodule update --init --recursive - pipenv run pytest -n 4 --junitxml=test-results.xml + pipenv run pytest -n 4 --junitxml=junit/test-results.xml displayName: Run integration tests env: PYTHONWARNINGS: ignore:DEPRECATION diff --git a/.azure-pipelines/steps/run-tests-windows.yml b/.azure-pipelines/steps/run-tests-windows.yml index 376a83d5..14b645a1 100644 --- a/.azure-pipelines/steps/run-tests-windows.yml +++ b/.azure-pipelines/steps/run-tests-windows.yml @@ -3,42 +3,64 @@ parameters: python_architecture: '' steps: - - task: UsePythonVersion@0 + - task: PowerShell@2 inputs: - versionSpec: ${{ parameters.python_version }} - architecture: ${{ parameters.python_architecture }} - addToPath: true - displayName: Use Python ${{ parameters.python_version }} - - - script: | - echo '##vso[task.setvariable variable=PIPENV_DEFAULT_PYTHON_VERSION]'${{ parameters.python_version }} - env: - PYTHON_VERSION: ${{ parameters.python_version }} - - - template: install-dependencies.yml - - - template: create-virtualenv.yml - parameters: - python_version: ${{ parameters.python_version }} + filePath: .azure-pipelines/scripts/New-RAMDisk.ps1 + arguments: "-Drive R -Size 2GB" + displayName: Setup RAMDisk - powershell: | - subst T: "$env:TEMP" - Write-Host "##vso[task.setvariable variable=TEMP]T:\" - Write-Host "##vso[task.setvariable variable=TMP]T:\" + mkdir R:\Temp + $acl = Get-Acl "R:\Temp" + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule( + "Everyone", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow" + ) + $acl.AddAccessRule($rule) + Set-Acl "R:\Temp" $acl + displayName: Set RAMDisk Permissions + + - powershell: | + Write-Host "##vso[task.setvariable variable=TEMP]R:\" + Write-Host "##vso[task.setvariable variable=TMP]R:\" + Write-Host "##vso[task.setvariable variable=WORKON_HOME]R:\virtualenvs" Write-Host "##vso[task.setvariable variable=PIPENV_DEFAULT_PYTHON_VERSION]$env:PYTHON_VERSION" Write-Host "##vso[task.setvariable variable=PIPENV_NOSPIN]1" displayName: Fix Temp Variable env: PYTHON_VERSION: ${{ parameters.python_version }} + - powershell: | + pip install certifi + $env:PYTHON_PATH=$(python -c "import sys; print(sys.executable)") + $env:CERTIFI_CONTENT=$(python -m certifi) + echo "##vso[task.setvariable variable=GIT_SSL_CAINFO]$env:CERTIFI_CONTENT" + echo "##vso[task.setvariable variable=PY_EXE]$env:PYTHON_PATH" + displayName: Set Python Path + env: + PYTHONWARNINGS: 'ignore:DEPRECATION' + + - template: install-dependencies.yml + parameters: + python_version: ${{ parameters.python_version }} + - powershell: | git submodule sync git submodule update --init --recursive - Write-Host "Running Command: pipenv run pytest -n 4 --junitxml=test-results.xml --timeout 300 tests/" - pipenv run pytest -n 4 --junitxml=test-results.xml --timeout 300 tests/ + Write-Host "Running Command: pipenv run pytest -n 4 --junitxml=junit/test-results.xml --timeout 300 tests/" + $env:TEMP = "R:\Temp" + pipenv run pytest -ra -n 4 --timeout=300 --junit-xml=junit/test-results.xml tests/ failOnStderr: false displayName: Run integration tests env: PYTHONWARNINGS: 'ignore:DEPRECATION' - PIPENV_NOSPIN: '1' + PIPENV_NOSPIN: 1 GIT_SSH_COMMAND: ssh -o StrictHostKeyChecking=accept-new -o CheckHostIP=no + + + +- task: PublishTestResults@2 + displayName: Publish Test Results + inputs: + testResultsFiles: junit/*.xml + testRunTitle: 'Python $(python.version)' + condition: succeededOrFailed() diff --git a/.azure-pipelines/steps/run-tests.yml b/.azure-pipelines/steps/run-tests.yml index ce4b5016..41cb72fa 100644 --- a/.azure-pipelines/steps/run-tests.yml +++ b/.azure-pipelines/steps/run-tests.yml @@ -6,17 +6,11 @@ steps: addToPath: true displayName: Use Python $(python.version) -- template: install-dependencies.yml - - script: | echo '##vso[task.setvariable variable=PIPENV_DEFAULT_PYTHON_VERSION]'$(python.version) env: PYTHON_VERSION: $(python.version) -- template: create-virtualenv.yml - parameters: - python_version: $(python.version) - - ${{ if eq(parameters.vmImage, 'windows-latest') }}: - template: run-tests-windows.yml parameters: @@ -29,6 +23,6 @@ steps: - task: PublishTestResults@2 displayName: Publish Test Results inputs: - testResultsFiles: '**/test-results.xml' + testResultsFiles: '**/junit/*.xml' testRunTitle: 'Python $(python.version)' condition: succeededOrFailed() diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a0f30c18..c7943d4a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -69,7 +69,7 @@ jobs: parameters: vmImage: 'Ubuntu-latest' -- job: TestWindows1 +- job: TestWindows timeoutInMinutes: 0 pool: vmImage: windows-latest @@ -89,39 +89,9 @@ jobs: python.architecture: x64 maxParallel: 8 steps: - - template: .azure-pipelines/steps/run-tests-windows.yml + - template: .azure-pipelines/steps/run-tests.yml parameters: vmImage: windows-latest - python_version: $(python.version) - python_architecture: $(python.architecture) - # pytest_markers: "lock or dotvenv or markers or project or utils or patched or core or cli" - -# - job: TestWindows2 -# timeoutInMinutes: 0 -# pool: -# vmImage: windows-latest -# strategy: -# matrix: -# Python27: -# python.version: '2.7' -# python.architecture: x64 -# Python36: -# python.version: '3.6' -# python.architecture: x64 -# Python37: -# python.version: '3.7' -# python.architecture: x64 -# Python38: -# python.version: '3.8' -# python.architecture: x64 -# maxParallel: 8 -# steps: -# - template: .azure-pipelines/steps/run-tests-windows.yml -# parameters: -# vmImage: windows-latest -# python_version: $(python.version) -# python_architecture: $(python.architecture) -# pytest_markers: "urls or multiprocessing or local or sequential or run or outdated or basic or code or uninstall" - job: TestMacOS pool: