Merge ~cjwatson/turnip:publish-swift-build-label into turnip:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 3ad69ed9f339480bd4774ac0764d83bc3423ec8a
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/turnip:publish-swift-build-label
Merge into: turnip:master
Diff against target: 48 lines (+11/-1)
2 files modified
Makefile (+1/-1)
publish-to-swift (+10/-0)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+387744@code.launchpad.net

Commit message

Publish last-successful-build-label.txt to Swift

Description of the change

This makes it easier for the Mojo spec to find the most recently-built revision, since it can't necessarily enumerate files in the Swift container.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) wrote :

nice!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/Makefile b/Makefile
2index d10a9b2..7ad822e 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -125,7 +125,7 @@ publish-tarball: build-tarball
6 [ ! -e ~/.config/swift/turnip ] || . ~/.config/swift/turnip; \
7 ./publish-to-swift --debug \
8 $(SWIFT_CONTAINER_NAME) $(SWIFT_OBJECT_PATH) \
9- $(TARBALL_BUILD_PATH)
10+ $(TARBALL_BUILD_PATH) turnip=$(TARBALL_BUILD_LABEL)
11
12 .PHONY: build check clean dist lint run-api run-pack test
13 .PHONY: build-tarball publish-tarball
14diff --git a/publish-to-swift b/publish-to-swift
15index e5cfd59..5a86fe7 100755
16--- a/publish-to-swift
17+++ b/publish-to-swift
18@@ -7,6 +7,7 @@ import os
19 import re
20 import subprocess
21 import sys
22+import tempfile
23
24
25 def ensure_container_privs(container_name):
26@@ -75,6 +76,7 @@ def main():
27 parser.add_argument("container_name")
28 parser.add_argument("swift_object_path")
29 parser.add_argument("local_path")
30+ parser.add_argument("build_label")
31 args = parser.parse_args()
32
33 if args.debug:
34@@ -118,6 +120,14 @@ def main():
35 args.container_name, args.swift_object_path, args.local_path,
36 overwrite=overwrite)
37
38+ with tempfile.TemporaryDirectory() as tmpdir:
39+ filename = "last-successful-build-label.txt"
40+ with open(os.path.join(tmpdir, filename), "w") as f:
41+ f.write(args.build_label)
42+ publish_file_to_swift(
43+ args.container_name, filename, os.path.join(tmpdir, filename),
44+ overwrite=True)
45+
46
47 if __name__ == "__main__":
48 main()

Subscribers

People subscribed via source and target branches