qiskit/.azure/test-macos.yml

102 lines
3.3 KiB
YAML

parameters:
- name: "pythonVersion"
type: string
displayName: "Version of Python to test"
- name: "installOptionals"
type: boolean
default: false
jobs:
- job: "MacOS_Tests_Python${{ replace(parameters.pythonVersion, '.', '') }}"
displayName: "Test macOS Python ${{ parameters.pythonVersion }}"
pool: {vmImage: 'macOS-13'}
variables:
QISKIT_SUPPRESS_PACKAGING_WARNINGS: Y
PIP_CACHE_DIR: $(Pipeline.Workspace)/.pip
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/bin/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/bin/activate
pip install -r requirements-optional.txt -c constraints.txt
displayName: "Install optional packages"
- bash: |
set -e
source test-job/bin/activate
python tools/report_numpy_state.py
export PYTHONHASHSEED=$(python -S -c "import random; print(random.randint(1, 4294967295))")
echo "PYTHONHASHSEED=$PYTHONHASHSEED"
stestr run
env:
QISKIT_PARALLEL: FALSE
RUST_BACKTRACE: 1
displayName: "Run tests"
- bash: |
set -e
source test-job/bin/activate
python -m pip install -U junitxml
mkdir -p junit
stestr last --subunit | tools/subunit_to_junit.py -o junit/test-results.xml
pushd .stestr
ls | grep -e '^[[:digit:]]' | xargs -n1 rm -f
popd
displayName: "Generate results"
condition: succeededOrFailed()
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: '**/test-*.xml'
testRunTitle: 'Test results for macOS Python ${{ parameters.pythonVersion }}'
- task: CopyFiles@2
inputs:
contents: '**/*.png'
targetFolder: $(Build.ArtifactStagingDirectory)
displayName: 'Copy images on test failure'
condition: failed()
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'drop_macos'
displayName: 'Publish images on test failure'
condition: failed()