Skip to content

Commit f8edddf

Browse files
authored
{CI} Add artifact publishing for built wheels in CI pipeline (Azure#9067)
1 parent 4438de4 commit f8edddf

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

azure-pipelines.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ jobs:
118118
env:
119119
ADO_PULL_REQUEST_LATEST_COMMIT: HEAD
120120
ADO_PULL_REQUEST_TARGET_BRANCH: $(System.PullRequest.TargetBranch)
121+
WHEELS_OUTPUT_DIR: $(Build.ArtifactStagingDirectory)/wheels-$(python.version)
122+
123+
- task: PublishPipelineArtifact@1
124+
displayName: 'Publish wheels artifacts from tests'
125+
inputs:
126+
targetPath: '$(Build.ArtifactStagingDirectory)/wheels-$(python.version)'
127+
artifact: 'wheels-$(python.version)'
128+
publishLocation: 'pipeline'
121129

122130
- job: AzdevStyleModifiedExtensions
123131
displayName: "azdev style on Modified Extensions"

scripts/ci/test_source.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@ def test_source_wheels():
9999
check_output(['python', 'setup.py', 'bdist_wheel', '-q', '-d', built_whl_dir], cwd=s)
100100
except CalledProcessError as err:
101101
raise("Unable to build extension {} : {}".format(s, err))
102+
# Export built wheels so CI can publish them as artifacts
103+
wheels_out_dir = os.environ.get('WHEELS_OUTPUT_DIR')
104+
if wheels_out_dir:
105+
try:
106+
os.makedirs(wheels_out_dir, exist_ok=True)
107+
for fname in os.listdir(built_whl_dir):
108+
src_path = os.path.join(built_whl_dir, fname)
109+
if os.path.isfile(src_path):
110+
shutil.copy2(src_path, os.path.join(wheels_out_dir, fname))
111+
logger.warning(f'Exported wheels to: {wheels_out_dir}')
112+
except Exception as ex:
113+
logger.exception(f'Failed to export wheels to {wheels_out_dir}: {ex}')
102114
shutil.rmtree(built_whl_dir)
103115

104116

0 commit comments

Comments
 (0)