From 047f8f6c5dfec1502be981b2f9ddec0e1de574bd Mon Sep 17 00:00:00 2001 From: "azure-pipelines[bot]" Date: Fri, 2 Nov 2018 19:31:43 -0400 Subject: [PATCH] Backport PR #12617: Set up CI with Azure Pipelines --- azure-pipelines.yml | 53 +++++++++++++++++++ lib/matplotlib/tests/test_backend_bases.py | 5 +- lib/matplotlib/tests/test_backend_nbagg.py | 3 +- .../tests/test_backends_interactive.py | 7 +++ 4 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000000..0f1b59707c22 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,53 @@ +# 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 + +jobs: + +- job: 'Test' + pool: + vmImage: 'Ubuntu 16.04' + strategy: + matrix: + Python35: + python.version: '3.5' + Python36: + python.version: '3.6' + Python37: + python.version: '3.7' + maxParallel: 4 + + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(python.version)' + architecture: 'x64' + + - script: | + + python -m pip install --upgrade pip + pip install -r requirements/testing/travis_all.txt -r requirements/testing/travis36.txt + + displayName: 'Install dependencies' + + - script: | + + export MPLLOCALFREETYPE=1 + pip install -ve . + + displayName: "Install self" + + - script: env + displayName: 'print env' + + - script: | + env + pytest --junitxml=junit/test-results.xml -raR --maxfail=50 --timeout=300 --durations=25 --cov-report= --cov=lib -n 2 + displayName: 'pytest' + + - task: PublishTestResults@2 + inputs: + testResultsFiles: '**/test-results.xml' + testRunTitle: 'Python $(python.version)' + condition: succeededOrFailed() diff --git a/lib/matplotlib/tests/test_backend_bases.py b/lib/matplotlib/tests/test_backend_bases.py index 5310db42f956..676686b7b1da 100644 --- a/lib/matplotlib/tests/test_backend_bases.py +++ b/lib/matplotlib/tests/test_backend_bases.py @@ -3,7 +3,7 @@ import matplotlib.pyplot as plt import matplotlib.transforms as transforms import matplotlib.path as path - +import os import numpy as np import pytest @@ -56,8 +56,11 @@ def test_get_default_filename(tmpdir): @pytest.mark.backend('pdf') +@pytest.mark.skipif('SYSTEM_TEAMFOUNDATIONCOLLECTIONURI' in os.environ, + reason="this test fails an azure for unknown reasons") def test_non_gui_warning(): plt.subplots() + with pytest.warns(UserWarning) as rec: plt.show() assert len(rec) == 1 diff --git a/lib/matplotlib/tests/test_backend_nbagg.py b/lib/matplotlib/tests/test_backend_nbagg.py index f08460b892cc..fe7204af0d9b 100644 --- a/lib/matplotlib/tests/test_backend_nbagg.py +++ b/lib/matplotlib/tests/test_backend_nbagg.py @@ -13,7 +13,8 @@ def _notebook_run(nb_file): """Execute a notebook via nbconvert and collect output. :returns (parsed nb object, execution errors) """ - with tempfile.NamedTemporaryFile(suffix=".ipynb") as fout: + with tempfile.NamedTemporaryFile(suffix=".ipynb", + mode='w+t') as fout: args = ["jupyter", "nbconvert", "--to", "notebook", "--execute", "--ExecutePreprocessor.timeout=500", "--output", fout.name, nb_file] diff --git a/lib/matplotlib/tests/test_backends_interactive.py b/lib/matplotlib/tests/test_backends_interactive.py index 0cb17c9d19f2..00cbf5db91bc 100644 --- a/lib/matplotlib/tests/test_backends_interactive.py +++ b/lib/matplotlib/tests/test_backends_interactive.py @@ -1,4 +1,5 @@ import importlib +import importlib.util import os import signal import subprocess @@ -46,6 +47,7 @@ def _get_testable_interactive_backends(): # we directly invoke it from the superclass instead. _test_script = """\ import importlib +import importlib.util import sys from unittest import TestCase @@ -115,6 +117,8 @@ def test_interactive_backend(backend): pytest.fail("The subprocess returned an error.") +@pytest.mark.skipif('SYSTEM_TEAMFOUNDATIONCOLLECTIONURI' in os.environ, + reason="this test fails an azure for unknown reasons") @pytest.mark.skipif(os.name == "nt", reason="Cannot send SIGINT on Windows.") def test_webagg(): pytest.importorskip("tornado") @@ -125,6 +129,9 @@ def test_webagg(): timeout = time.perf_counter() + _test_timeout while True: try: + retcode = proc.poll() + # check that the subprocess for the server is not dead + assert retcode is None conn = urllib.request.urlopen(url) break except urllib.error.URLError: