Skip to content

Commit

Permalink
Add ttl param to checkPublishedArtifact (commit got lost in previous …
Browse files Browse the repository at this point in the history
…commit) (#1454)

This completes #1453

Pull request: #1454
  • Loading branch information
lefou authored Mar 8, 2024
1 parent 8a463ab commit dfd8e47
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import mill.scalalib.publish._
import mill.scalalib.api.ZincWorkerUtil._
import mill.testrunner.TestRunner


val ghOrg = "com-lihaoyi"
val ghRepo = "Ammonite"
val masterBranch = "main"
Expand Down Expand Up @@ -1031,26 +1030,31 @@ def publishSonatype(
* {{{
* mill checkPublishedArtifacts --artifacts __.publishSelfDependency --version {version} --ttl "1 sec"
* }}}
* See also https://github.com/com-lihaoyi/Ammonite/pull/1453
* See also https://github.com/com-lihaoyi/Ammonite/pull/1453
*/
def checkPublishedArtifacts(artifacts: Tasks[Artifact], version: String, ttl: String = "1 hour") = T.command {
val coords = T.sequence(artifacts.value)()
val next = new AtomicInteger(0)
val fut = coords.map { coord =>
Future {
val dep = s"${coord.group}:${coord.id}:${version}"
println(s"[${next.incrementAndGet()}/${coords.size}] Checking ${dep}")
val res = os.proc("cs", "complete-dep", dep, "-l", ttl)
.call().out.text().trim()
// println(res)
Option.when(!res.contains(version))(dep)
}(ExecutionContext.global)
def checkPublishedArtifacts(artifacts: Tasks[Artifact], version: String, ttl: String = "1 hour") =
T.command {
val coords = T.sequence(artifacts.value)()
val next = new AtomicInteger(0)
val fut = coords.map { coord =>
Future {
val dep = s"${coord.group}:${coord.id}:${version}"
println(s"[${next.incrementAndGet()}/${coords.size}] Checking ${dep}")
val res = os.proc("cs", "complete-dep", dep, "-l", ttl)
.call().out.text().trim()
// println(res)
Option.when(!res.contains(version))(dep)
}(ExecutionContext.global)
}
val missing = fut.map(Await.result(_, duration.Duration.Inf)).flatten
if (missing.isEmpty) {
Result.Success(s"All artifacts published for version ${version}")
} else {
val msg =
if (missing.size == coords.size) s"All artifacts missing for version ${version}"
else s"Missing ${missing.size} of ${coords.size} published artifacts: ${
missing.mkString("\n- ", "\n- ", "")
}"
Result.Failure(msg)
}
}
val missing = fut.map(Await.result(_, duration.Duration.Inf)).flatten
val msg = if (missing.size == coords.size) s"All artifacts missing for version ${version}"
else s"Missing ${missing.size} of ${coords.size} published artifacts: ${
missing.mkString("\n- ", "\n- ", "")
}"
if(missing.isEmpty) Result.Success(s"All artifacts published for version ${version}")
else Result.Failure(msg)
}

0 comments on commit dfd8e47

Please sign in to comment.