Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new azure-quantum package release pipeline #526

Merged
merged 26 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e98da71
Add publish pipeline
xinyi-joffre Nov 14, 2023
6cb368b
Update job names
xinyi-joffre Nov 14, 2023
aaa0dea
Install wheel
xinyi-joffre Nov 14, 2023
7e3a4f3
Fix install wheel command
xinyi-joffre Nov 14, 2023
72f5a7a
Fix upload artifact for qdk
xinyi-joffre Nov 14, 2023
bb5437a
Update github links and set min python require to 3.7
xinyi-joffre Nov 14, 2023
555c770
Set python version
xinyi-joffre Nov 14, 2023
b5d7140
Handle version
xinyi-joffre Nov 14, 2023
7f5c0a5
Fix parameter to variable mapping
xinyi-joffre Nov 14, 2023
082bdc8
Add unit testing
xinyi-joffre Nov 14, 2023
e858797
Fix variable
xinyi-joffre Nov 14, 2023
497b81d
Comment out ESRP task
xinyi-joffre Nov 14, 2023
c33c706
Fix path for pytest
xinyi-joffre Nov 14, 2023
c036ad4
Ensure all requirements are installed
xinyi-joffre Nov 14, 2023
d8d9612
No longer run tests for qdk package
xinyi-joffre Nov 14, 2023
53393e1
Lock qsharp version to <1.0
xinyi-joffre Nov 15, 2023
15d6076
Remove duplicate copy step
xinyi-joffre Nov 15, 2023
62f7c1e
Fix copy source location
xinyi-joffre Nov 15, 2023
f00b5e2
Add Github and ESRP Releases
xinyi-joffre Nov 15, 2023
6df4cf6
Remove extra brace
xinyi-joffre Nov 15, 2023
f02c9f9
Fix yaml
xinyi-joffre Nov 15, 2023
f964190
Fix parameter eval check
xinyi-joffre Nov 15, 2023
119fdd3
Add Oauth connector
xinyi-joffre Nov 15, 2023
679ff6a
Fix listing wheels
xinyi-joffre Nov 15, 2023
8ebb48e
Add PYTHON_VERSION to publish step
xinyi-joffre Nov 16, 2023
3e4f6f3
Merge branch 'main' into xinyi/add-release-pipeline
xinyi-joffre Nov 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
221 changes: 221 additions & 0 deletions .ado/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
trigger: none
pr: none

parameters:
- name: Build_Type
type: string
values:
- dev
- rc
- stable
default: 'dev'
- name: Patch_Number
type: number
default: 0
- name: Deploy_Azure_Quantum_Package
type: boolean
default: True
- name: Deploy_QDK_Package
type: boolean
default: False
- name: Create_GitHub_Release
type: boolean
default: False
- name: Publish_PyPi_Packages
type: boolean
default: False

variables:
- name: OwnerPersonalAlias
value: 'billti'

jobs:
- job: "Build_Azure_Quantum_Python"
pool:
vmImage: 'windows-latest'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.11'

- script: |
pip install wheel
displayName: Install wheel

- script: |
pip freeze
displayName: List installed packages

- script: |
python set_version.py
env:
BUILD_TYPE: ${{ parameters.Build_Type }}
PATCH_NUMBER: ${{ parameters.Patch_Number }}
displayName: Set version

- script: |
cd $(Build.SourcesDirectory)/azure-quantum
python setup.py sdist --dist-dir=target/wheels
python setup.py bdist_wheel --dist-dir=target/wheels
displayName: Build azure-quantum package

- publish: $(Build.SourcesDirectory)/azure-quantum/target/wheels/
artifact: azure-quantum-wheels
displayName: Upload azure-quantum artifacts

- job: "Test_Azure_Quantum_Python"
pool:
vmImage: 'windows-latest'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.11'

- script: |
pip install pytest pytest-azurepipelines pytest-cov
displayName: Install pytest dependencies

- script: |
pip freeze
displayName: List installed packages

- script: |
cd $(Build.SourcesDirectory)/azure-quantum
pip install .[all]
pytest --cov-report term --cov=azure.quantum --junitxml test-output-azure-quantum.xml $(Build.SourcesDirectory)/azure-quantum
displayName: Run azure-quantum unit tests

- task: PublishTestResults@2
displayName: 'Publish tests results (python)'
condition: succeededOrFailed()
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/test-*.xml'
testRunTitle: 'Azure Quantum Python Tests'

- job: "Build_QDK_Python"
pool:
vmImage: 'windows-latest'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.11'

- script: |
pip install wheel
displayName: Install wheel

- script: |
pip freeze
displayName: List installed packages

- script: |
python set_version.py
env:
BUILD_TYPE: ${{ parameters.Build_Type }}
PATCH_NUMBER: ${{ parameters.Patch_Number }}
displayName: Set version

- script: |
cd $(System.DefaultWorkingDirectory)/qdk
python setup.py sdist --dist-dir=target/wheels
python setup.py bdist_wheel --dist-dir=target/wheels
displayName: Build qdk package

- publish: $(System.DefaultWorkingDirectory)/qdk/target/wheels/
artifact: qdk-wheels
displayName: Upload qdk-wheels artifacts

- job: "Approval"
dependsOn:
- "Build_Azure_Quantum_Python"
- "Build_QDK_Python"
- "Test_Azure_Quantum_Python"
pool: server
timeoutInMinutes: 1440 # job times out in 1 day
steps:
- task: ManualValidation@0
timeoutInMinutes: 1440 # task times out in 1 day
inputs:
notifyUsers: ''
instructions: 'Please verify artifacts and approve the release'
onTimeout: 'reject'

- job: "Publish_Python_Packages"
dependsOn: Approval
pool:
vmImage: 'windows-latest'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.11'

- script: |
python set_version.py
env:
BUILD_TYPE: ${{ parameters.Build_Type }}
PATCH_NUMBER: ${{ parameters.Patch_Number }}
displayName: Set version

- download: current
artifact: azure-quantum-wheels
displayName: Download azure-quantum artifacts

- download: current
artifact: qdk-wheels
displayName: Download qdk artifacts

- task: CopyFiles@2
condition: ${{ parameters.Deploy_Azure_Quantum_Package }}
displayName: Copy azure-quantum artifacts
inputs:
SourceFolder: '$(Pipeline.Workspace)/azure-quantum-wheels'
Contents: '**'
TargetFolder: '$(Build.ArtifactStagingDirectory)/target/wheels'

- task: CopyFiles@2
condition: ${{ parameters.Deploy_QDK_Package }}
displayName: Copy qdk artifacts
inputs:
SourceFolder: '$(Pipeline.Workspace)/qdk-wheels'
Contents: '**'
TargetFolder: '$(Build.ArtifactStagingDirectory)/target/wheels'

- script: |
ls $(Build.ArtifactStagingDirectory)/target/wheels/*
displayName: List Py Artifacts to publish

- task: GitHubRelease@1
condition: ${{ parameters.Create_GitHub_Release }}
displayName: Create GitHub Release
inputs:
gitHubConnection: AzureQuantumOauth
repositoryName: Microsoft/azure-quantum-python
action: create
tagSource: 'userSpecifiedTag'
tag: azure-quantum_v$(PYTHON_VERSION)
isDraft: True
isPreRelease: ${{ ne(parameters.Build_Type, 'stable') }}
target: $(Build.SourceVersion)
addChangeLog: False
assets: |
$(Build.ArtifactStagingDirectory)/target/wheels/*

- task: EsrpRelease@4
condition: ${{ parameters.Publish_PyPi_Packages }}
displayName: Publish Py Packages
inputs:
ConnectedServiceName: 'ESRP_Release'
Intent: 'PackageDistribution'
ContentType: 'PyPi'
FolderLocation: '$(Build.ArtifactStagingDirectory)/target/wheels'
Owners: '$(OwnerPersonalAlias)@microsoft.com' # NB: Group email here fails the task with non-actionable output.
Approvers: 'billti@microsoft.com'
# Auto-inserted Debugging defaults:
ServiceEndpointUrl: 'https://api.esrp.microsoft.com'
MainPublisher: 'QuantumDevelpmentKit' # ESRP Team's Correction (including the critical typo "Develpm").
DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47'
2 changes: 1 addition & 1 deletion azure-quantum/requirements-qsharp.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
qsharp>=0.28.263081
qsharp>=0.28.263081,<=1.0
3 changes: 2 additions & 1 deletion azure-quantum/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ def read_requirements(requirement_file: str) -> list[str]:
license="MIT License",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/microsoft/qdk-python",
url="https://github.com/microsoft/azure-quantum-python",
packages=setuptools.find_namespace_packages(include=["azure.*"]),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires=">=3.7",
install_requires=requirements,
extras_require=extras_require
)
5 changes: 3 additions & 2 deletions qdk/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@
license="MIT License",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/microsoft/qdk-python",
url="https://github.com/microsoft/azure-quantum-python",
packages=setuptools.find_namespace_packages(include=["qdk*"]),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires=">=3.7",
install_requires=[
'qsharp',
'qsharp<=1.0',
'jupyter_jsmol',
'networkx',
'varname',
Expand Down
35 changes: 35 additions & 0 deletions set_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python3

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

import os

major_minor = "0.29"

BUILD_TYPE = os.environ.get("BUILD_TYPE") or "dev"
PATCH_NUMBER = os.environ.get("PATCH_NUMBER")

if BUILD_TYPE not in ["dev", "rc", "stable"]:
print(f"BUILD_TYPE environment variable must be 'dev', 'rc', or 'stable'. Current value: {BUILD_TYPE}")
exit(1)

try:
patch_ver = int(PATCH_NUMBER)
except:
print(f"PATCH_NUMBER environment variable must be set to a valid integer. Current value: {PATCH_NUMBER}")
exit(1)

version_triple = "{}.{}".format(major_minor, patch_ver)

pip_suffix = {"stable": "", "rc": "rc0", "dev": "dev0"}
pip_version = "{}{}".format(version_triple, pip_suffix.get(BUILD_TYPE))

print("PYTHON_VERSION: {}".format(pip_version))

# Set PYTHON_VERSION variable for steps in same job to reference as $(PYTHON_VERSION)
print(f"##vso[task.setvariable variable=PYTHON_VERSION;]{pip_version}")

# Set build tags
print(f"##vso[build.addbuildtag]v{pip_version}")
print(f"##vso[build.addbuildtag]{BUILD_TYPE}")