|
| 1 | +# azure pipelines build and test DPF-Post |
| 2 | + |
| 3 | +variables: |
| 4 | + ALLOW_PLOTTING: true |
| 5 | + package_name: ansys-dpf-post |
| 6 | + SHELLOPTS: 'errexit:pipefail' |
| 7 | + |
| 8 | +trigger: |
| 9 | + branches: |
| 10 | + include: |
| 11 | + - '*' |
| 12 | + exclude: |
| 13 | + - gh-pages |
| 14 | + tags: |
| 15 | + include: |
| 16 | + - '*' |
| 17 | + |
| 18 | +pr: |
| 19 | + branches: |
| 20 | + exclude: |
| 21 | + - '*' |
| 22 | + |
| 23 | +jobs: |
| 24 | +- job: Windows |
| 25 | + variables: |
| 26 | + python.version: '3.8' |
| 27 | + DISPLAY: ':99.0' |
| 28 | + PYANSYS_OFF_SCREEN: True |
| 29 | + DPF_PORT: 32772 |
| 30 | + DPF_START_SERVER: False |
| 31 | + pool: |
| 32 | + vmImage: 'windows-2019' |
| 33 | + |
| 34 | + steps: |
| 35 | + - powershell: | |
| 36 | + powershell .ci/install_opengl.ps1 |
| 37 | + .ci/setup_headless_display.sh |
| 38 | + pip install -r .ci/requirements_test_xvfb.txt |
| 39 | + python .ci/display_test.py |
| 40 | + displayName: Install and start a virtual framebuffer |
| 41 | +
|
| 42 | + - task: UsePythonVersion@0 |
| 43 | + inputs: |
| 44 | + versionSpec: $(python.version) |
| 45 | + addToPath: true |
| 46 | + |
| 47 | + - task: PipAuthenticate@1 |
| 48 | + inputs: |
| 49 | + artifactFeeds: 'pyansys' |
| 50 | + onlyAddExtraIndex: true |
| 51 | + |
| 52 | + - script: | |
| 53 | + pip install -r requirements_build.txt |
| 54 | + python setup.py bdist_wheel |
| 55 | + pip install --find-links=dist ansys_dpf_post |
| 56 | + cd tests |
| 57 | + python -c "from ansys.dpf import post; print(post.Report(gpu=False))" |
| 58 | + displayName: Install ansys-dpf-post |
| 59 | +
|
| 60 | + - task: UniversalPackages@0 |
| 61 | + inputs: |
| 62 | + command: 'download' |
| 63 | + downloadDirectory: '$(System.DefaultWorkingDirectory)' |
| 64 | + feedsToUse: 'internal' |
| 65 | + vstsFeed: '705e121a-9631-49f5-8aaf-c7142856f923' |
| 66 | + vstsFeedPackage: 'f913c1d3-1fe4-404c-8c28-15a234e56803' |
| 67 | + vstsPackageVersion: '21.1.4' |
| 68 | + |
| 69 | + - script: | |
| 70 | + @echo on |
| 71 | + dir $(System.DefaultWorkingDirectory) |
| 72 | + set THISDIR=$(System.DefaultWorkingDirectory) |
| 73 | + set PATH=%THISDIR%\server\v211\tp\IntelMKL\2020.0.166\winx64\;%THISDIR%\server\v211\tp\hdf5\1.8.14\winx64\;%THISDIR%\server\v211\tp\CFFSDK\lib\winx64;%THISDIR%\res_files\;%PATH% |
| 74 | + cd %THISDIR%\server\v211\aisol\bin\winx64 |
| 75 | + START /B Ans.Dpf.Grpc.exe --address 127.0.0.1 --port %DPF_PORT% > log.txt 2>&1 |
| 76 | + python -c "from ansys.dpf import core; core.connect_to_server(port=$(DPF_PORT)); print('Python Connected')" |
| 77 | + displayName: Start DPF Server |
| 78 | +
|
| 79 | + - script: | |
| 80 | + pip install -r requirements_test.txt |
| 81 | + cd tests |
| 82 | + pytest -v --junitxml=junit/test-results.xml --cov ansys.dpf.post --cov-report=xml |
| 83 | + displayName: Test Post API |
| 84 | +
|
| 85 | + - script: | |
| 86 | + type $(System.DefaultWorkingDirectory)\server\v211\aisol\bin\winx64\log.txt |
| 87 | + displayName: 'Show DPF Server Logs' |
| 88 | + condition: always() |
| 89 | +
|
| 90 | +- job: Linux |
| 91 | + variables: |
| 92 | + python.version: '3.7' # due to VTK 8.1.2 requirement for docbuild |
| 93 | + DISPLAY: ':99.0' |
| 94 | + PYANSYS_OFF_SCREEN: True |
| 95 | + DPF_PORT: 32772 |
| 96 | + DPF_START_SERVER: False |
| 97 | + DPF_IMAGE: docker.pkg.github.com/pyansys/dpf-core/dpf:v2021.1 |
| 98 | + DPF_DOCKER: True |
| 99 | + pool: |
| 100 | + vmImage: 'ubuntu-20.04' |
| 101 | + steps: |
| 102 | + - task: UsePythonVersion@0 |
| 103 | + inputs: |
| 104 | + versionSpec: '$(python.version)' |
| 105 | + displayName: 'Use Python $(python.version)' |
| 106 | + |
| 107 | + - script: | |
| 108 | + ls -lh .ci |
| 109 | + chmod +x .ci/setup_headless_display.sh |
| 110 | + .ci/setup_headless_display.sh |
| 111 | + pip install -r .ci/requirements_test_xvfb.txt |
| 112 | + python .ci/display_test.py |
| 113 | + displayName: Install and start a virtual framebuffer |
| 114 | +
|
| 115 | + - script: | |
| 116 | + pip install -r requirements_build.txt |
| 117 | + python setup.py bdist_wheel |
| 118 | + pip install --find-links=dist ansys_dpf_post |
| 119 | + cd tests |
| 120 | + python -c "from ansys.dpf import post; print(post.Report())" |
| 121 | + displayName: Install ansys-dpf-post |
| 122 | +
|
| 123 | + # this step is necessary as we're running in docker and the |
| 124 | + # examples directory must be local to the docker enviornment |
| 125 | + - script: | |
| 126 | + EXAMPLES_DIR=$(python -c "from ansys.dpf.core import examples; import os; print(os.path.dirname(examples.__file__))") |
| 127 | + mkdir -p ansys/dpf/core |
| 128 | + cp -r $EXAMPLES_DIR ansys/dpf/core |
| 129 | + displayName: Copy ansys.dpf.core examples to local directory |
| 130 | +
|
| 131 | + - script: | |
| 132 | + set -ex |
| 133 | + echo $(PAT) | docker login -u $(GH_USERNAME) --password-stdin docker.pkg.github.com |
| 134 | + docker pull $(DPF_IMAGE) |
| 135 | + docker run --restart always --name dpf -v `pwd`:/dpf -v /tmp:/dpf/_cache -p $(DPF_PORT):50054 $(DPF_IMAGE) > log.txt & |
| 136 | + grep -q 'server started on ip' <(timeout 60 tail -f log.txt) |
| 137 | + python -c "from ansys.dpf import core as dpf; dpf.connect_to_server(port=$(DPF_PORT)); print('Python Connected')" |
| 138 | + displayName: Pull, launch, and validate DPF service |
| 139 | +
|
| 140 | + - script: | |
| 141 | + pip install -r requirements_test.txt |
| 142 | + pip install pytest-azurepipelines |
| 143 | + cd tests |
| 144 | + pytest -v --junitxml=junit/test-results.xml --cov ansys.dpf.post --cov-report=xml --cov-report=html |
| 145 | + displayName: Test Post API |
| 146 | +
|
| 147 | + - script: | |
| 148 | + pip install twine |
| 149 | + python setup.py sdist |
| 150 | + twine upload --skip-existing dist/* |
| 151 | + displayName: 'Upload to PyPi' |
| 152 | + condition: contains(variables['Build.SourceBranch'], 'refs/tags/') |
| 153 | + env: |
| 154 | + TWINE_USERNAME: __token__ |
| 155 | + TWINE_PASSWORD: $(PYPI_TOKEN) |
| 156 | + TWINE_REPOSITORY_URL: "https://upload.pypi.org/legacy/" |
0 commit comments