Skip to content

Commit 9679718

Browse files
authored
Add time stamp to release/prerelease workflow (#9789)
* Add time stamp to 'pod repo push'.
1 parent ced8b55 commit 9679718

File tree

1 file changed

+34
-2
lines changed
  • scripts/create_spec_repo/Sources/SpecRepoBuilder

1 file changed

+34
-2
lines changed

scripts/create_spec_repo/Sources/SpecRepoBuilder/main.swift

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import ArgumentParser
1818
import Foundation
19+
1920
private enum Constants {}
2021

2122
extension Constants {
@@ -35,6 +36,23 @@ extension Constants {
3536
static let umbrellaPodFlags = Constants.flags + ["--use-json"]
3637
}
3738

39+
public extension Date {
40+
func dateTimeString() -> String {
41+
let formatter = DateFormatter()
42+
formatter.dateStyle = .short
43+
formatter.timeStyle = .medium
44+
return formatter.string(from: self)
45+
}
46+
47+
func formattedDurationSince(_ date: Date) -> String {
48+
let formatter = DateComponentsFormatter()
49+
formatter.unitsStyle = .abbreviated
50+
formatter.allowedUnits = [.hour, .minute, .second]
51+
let secondsSinceDate = date.timeIntervalSince(self)
52+
return formatter.string(from: secondsSinceDate) ?? "\(round(secondsSinceDate)) sec"
53+
}
54+
}
55+
3856
// SpecFiles is a wraper of dict mapping from required pods to their path. This
3957
// will also contain a sequence of installing podspecs.
4058
class SpecFiles {
@@ -356,7 +374,19 @@ struct SpecRepoBuilder: ParsableCommand {
356374

357375
var exitCode: Int32 = 0
358376
var failedPods: [String] = []
377+
let startDate = Date()
378+
var minutes = 0
359379
for pod in specFileDict.depInstallOrder {
380+
var timer: DispatchSourceTimer = {
381+
let t = DispatchSource.makeTimerSource()
382+
t.schedule(deadline: .now(), repeating: 60)
383+
t.setEventHandler(handler: {
384+
print("Tests have run \(minutes) min(s).")
385+
minutes += 1
386+
})
387+
return t
388+
}()
389+
timer.resume()
360390
var podExitCode: Int32 = 0
361391
print("----------\(pod)-----------")
362392
switch pod {
@@ -380,11 +410,13 @@ struct SpecRepoBuilder: ParsableCommand {
380410
failedPods.append(pod)
381411
print("Failed pod - \(pod)")
382412
}
413+
timer.cancel()
414+
let finishDate = Date()
415+
print("\(pod) is finished at: \(finishDate.dateTimeString()). " +
416+
"Duration: \(startDate.formattedDurationSince(finishDate))")
383417
}
384418
if exitCode != 0 {
385419
Self.exit(withError: SpecRepoBuilderError.failedToPush(pods: failedPods))
386420
}
387421
}
388422
}
389-
390-
SpecRepoBuilder.main()

0 commit comments

Comments
 (0)