Skip to content

Commit d10d707

Browse files
committed
Use workflow ID in wheel upload
1 parent d796e87 commit d10d707

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

.builders/tests/test_upload.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def test_upload_built_no_conflict(setup_targets_dir, setup_fake_bucket, workflow
136136

137137
bucket_files = [f.name for f in bucket.list_blobs()]
138138
assert (
139-
f'built/without-collision/without_collision-3.14.1-{workflow_id}-cp311-cp311-manylinux2010_x86_64.whl'
139+
f'built/without-collision/without_collision-3.14.1-{workflow_id}WID-cp311-cp311-manylinux2010_x86_64.whl'
140140
in bucket_files
141141
)
142142

@@ -204,7 +204,7 @@ def test_upload_built_existing_different_sha_does_upload(
204204
assert uploads == {'existing-1.1.1-cp311-cp311-manylinux2010_x86_64.whl'}
205205

206206
bucket_files = {f.name for f in bucket.list_blobs()}
207-
assert f'built/existing/existing-1.1.1-{workflow_id}-cp311-cp311-manylinux2010_x86_64.whl' in bucket_files
207+
assert f'built/existing/existing-1.1.1-{workflow_id}WID-cp311-cp311-manylinux2010_x86_64.whl' in bucket_files
208208

209209

210210
def test_upload_built_existing_sha_match_does_not_upload_multiple_existing_builds(
@@ -282,7 +282,7 @@ def test_upload_built_existing_different_sha_does_upload_multiple_existing_build
282282
assert uploads == {'existing-1.1.1-cp311-cp311-manylinux2010_x86_64.whl'}
283283

284284
bucket_files = {f.name for f in bucket.list_blobs()}
285-
assert f'built/existing/existing-1.1.1-{workflow_id}-cp311-cp311-manylinux2010_x86_64.whl' in bucket_files
285+
assert f'built/existing/existing-1.1.1-{workflow_id}WID-cp311-cp311-manylinux2010_x86_64.whl' in bucket_files
286286

287287

288288
def test_build_tag_use_workflow_id(
@@ -322,4 +322,4 @@ def test_build_tag_use_workflow_id(
322322
assert uploads == {'existing-1.1.1-cp311-cp311-manylinux2010_x86_64.whl'}
323323

324324
bucket_files = {f.name for f in bucket.list_blobs()}
325-
assert f'built/existing/existing-1.1.1-{workflow_id}-cp311-cp311-manylinux2010_x86_64.whl' in bucket_files
325+
assert f'built/existing/existing-1.1.1-{workflow_id}WID-cp311-cp311-manylinux2010_x86_64.whl' in bucket_files

.builders/upload.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ def display_message_block(message: str) -> None:
5858
print(divider)
5959

6060

61+
def timestamp_build_number() -> int:
62+
"""Produce a numeric timestamp to use as build numbers"""
63+
return int(time.strftime('%Y%m%d%H%M%S'))
64+
65+
6166
def hash_file(path: Path) -> str:
6267
"""Calculate the hash of the file pointed at by `path`"""
6368
with path.open('rb') as f:
@@ -90,7 +95,7 @@ def _build_number_of_wheel_blob(wheel_path: Blob) -> int:
9095
return int(build_number[0]) if build_number else -1
9196

9297

93-
def upload(targets_dir, workflow_id):
98+
def upload(targets_dir):
9499
client = storage.Client()
95100
bucket = client.bucket(BUCKET_NAME)
96101
artifact_types: set[str] = set()
@@ -143,7 +148,8 @@ def upload(targets_dir, workflow_id):
143148
'with the same hash')
144149
continue
145150

146-
artifact_name = f'{name}-{version}-{workflow_id}-{python_tag}-{abi_tag}-{platform_tag}.whl'
151+
build_number = timestamp_build_number()
152+
artifact_name = f'{name}-{version}-{build_number}-{python_tag}-{abi_tag}-{platform_tag}.whl'
147153
artifact = bucket.blob(f'{artifact_type}/{project_name}/{artifact_name}')
148154

149155
print(f'{padding}Artifact: {artifact_name}')
@@ -207,6 +213,5 @@ def upload(targets_dir, workflow_id):
207213
if __name__ == '__main__':
208214
parser = argparse.ArgumentParser(prog='builder', allow_abbrev=False)
209215
parser.add_argument('targets_dir')
210-
parser.add_argument('workflow_id')
211216
args = parser.parse_args()
212-
upload(args.targets_dir, args.workflow_id)
217+
upload(args.targets_dir)

0 commit comments

Comments
 (0)