qiskit/.azure/test-windows.yml

109 lines
3.5 KiB
YAML

parameters:
- name: "pythonVersion"
type: string
displayName: "Versions of Python to test"
- name: "installOptionals"
type: boolean
default: false
jobs:
- job: "Windows_Tests_Python${{ replace(parameters.pythonVersion, '.', '') }}"
displayName: "Test Windows Python ${{ parameters.pythonVersion }}"
pool: {vmImage: 'windows-latest'}
variables:
QISKIT_SUPPRESS_PACKAGING_WARNINGS: Y
QISKIT_TEST_CAPTURE_STREAMS: 1
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '${{ parameters.pythonVersion }}'
displayName: 'Use Python ${{ parameters.pythonVersion }}'
- task: Cache@2
inputs:
key: 'stestr | "$(Agent.OS)" | "${{ parameters.pythonVersion }}" | "$(Build.BuildNumber)"'
restoreKeys: |
stestr | "$(Agent.OS)" | "${{ parameters.pythonVersion }}"
stestr | "$(Agent.OS)"
stestr
path: .stestr
displayName: Cache stestr
- bash: |
set -e
python -m pip install --upgrade pip setuptools wheel virtualenv
virtualenv test-job
source test-job/Scripts/activate
python -m pip install -U pip setuptools wheel
python -m pip install -U \
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
-e .
# Build and install both qiskit and qiskit-terra so that any optionals
# depending on `qiskit` will resolve correctly.
pip check
displayName: 'Install dependencies'
- ${{ if eq(parameters.installOptionals, true) }}:
- bash: |
set -e
source test-job/Scripts/activate
pip install -c constraints.txt -r requirements-optional.txt
pip check
displayName: "Install optional packages"
- bash: |
set -e
chcp.com 65001
source test-job/Scripts/activate
python tools/report_numpy_state.py
export PYTHONHASHSEED=$(python -S -c "import random; print(random.randint(1, 1024))")
echo "PYTHONHASHSEED=$PYTHONHASHSEED"
stestr run
env:
LANG: 'C.UTF-8'
PYTHONIOENCODING: 'utf-8:backslashreplace'
QISKIT_PARALLEL: FALSE
RUST_BACKTRACE: 1
displayName: 'Run tests'
- bash: |
set -e
chcp.com 65001
source test-job/Scripts/activate
python -m pip install -U junitxml
mkdir -p junit
stestr last --subunit | python tools/subunit_to_junit.py -o junit/test-results.xml
pushd .stestr
ls | grep -P "^\d" | xargs -d "\n" rm -f
popd
condition: succeededOrFailed()
env:
LANG: 'C.UTF-8'
PYTHONIOENCODING: 'utf-8:backslashreplace'
displayName: 'Generate results'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: '**/test-*.xml'
testRunTitle: 'Test results for Windows Python ${{ parameters.pythonVersion }}'
- task: CopyFiles@2
condition: failed()
displayName: 'Copy images'
inputs:
contents: '**/*.png'
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
condition: failed()
displayName: 'Publish images'
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'drop_windows'