Skip to content

Commit

Permalink
Improve CI feedback when directory is missing (#10608)
Browse files Browse the repository at this point in the history
* Improve CI feedback when directory is missing

As motivated by https://github.com/enso-org/enso/actions/runs/10006095519/job/27658100782?pr=10577#step:7:2277

* update codeowners

* nit
  • Loading branch information
hubertp authored Oct 9, 2024
1 parent 7c51240 commit 7f5c0e6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
5 changes: 4 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ Cargo.toml
/tools/build-performance/ @kazcw @Akirathan

# Scala Libraries
/lib/scala/ @4e6 @jaroslavtulach @hubertp
/lib/scala/ @4e6 @jaroslavtulach @hubertp @Akirathan

# Java libraries
/lib/java/ @4e6 @jaroslavtulach @hubertp @Akirathan

# GUI
/app/gui2/ @Frizi @farmaazon @vitvakatu @kazcw @AdRiley
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,9 @@ class VcsManagerTest
.setBare(false)
.call()

path.toPath.resolve(".git").toFile.delete() shouldBe true
val gitPath = path.toPath.resolve(".git")
val deleted = gitPath.toFile.delete()
(deleted || !gitPath.toFile.exists()) shouldBe true

val client = getInitialisedWsClient()
jgit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ class ProjectManager {
*/
def findProject(path: Path): Try[Option[Project]] =
tryFindingProject(path.toAbsolutePath.normalize).map(Some(_)).recover {
case PackageManager.PackageNotFound() => None
case PackageManager.PackageNotFound(_) => None
}

private def tryFindingProject(root: Path): Try[Project] =
packageManager
.loadPackage(root.toFile)
.map(new Project(_))
.recoverWith {
case PackageManager.PackageNotFound() if root.getParent != null =>
case PackageManager.PackageNotFound(_) if root.getParent != null =>
tryFindingProject(root.getParent)
case otherError => Failure(otherError)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ private class DefaultPackageRepository(
Using(file.newBufferedReader) { reader =>
StringUtils.join(reader.lines().iterator(), "\n")
}
else Failure(PackageManager.PackageNotFound())
else Failure(PackageManager.PackageNotFound("manifest"))
}

override def shutdown(): Unit = {
Expand Down
20 changes: 10 additions & 10 deletions lib/scala/pkg/src/main/scala/org/enso/pkg/Package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -326,19 +326,16 @@ class PackageManager[F](implicit val fileSystem: FileSystem[F]) {
*/
def loadPackage(root: F): Try[Package[F]] = {
val result =
if (!root.exists) Failure(PackageManager.PackageNotFound())
if (!root.exists) Failure(PackageManager.PackageNotFound("root"))
else {
def readConfig(file: F): Try[Config] =
if (file.exists)
Using(file.newBufferedReader)(Config.fromYaml).flatten
else Failure(PackageManager.PackageNotFound())

val configFile = root.getChild(Package.configFileName)
if (configFile.exists) {
for {
result <- readConfig(configFile)
result <- Using(configFile.newBufferedReader)(
Config.fromYaml
).flatten
} yield new Package(root, result, fileSystem)
} else Failure(PackageManager.PackageNotFound())
} else Failure(PackageManager.PackageNotFound("config"))
}
result.recoverWith {
case packageLoadingException: PackageManager.PackageLoadingException =>
Expand Down Expand Up @@ -570,8 +567,11 @@ object PackageManager {
}

/** The error indicating that the requested package does not exist. */
case class PackageNotFound()
extends PackageLoadingException(s"The package file does not exist.", null)
case class PackageNotFound(kind: String)
extends PackageLoadingException(
s"The $kind package file does not exist.",
null
)

/** The error indicating that the package exists, but cannot be loaded. */
case class PackageLoadingFailure(message: String, cause: Throwable)
Expand Down

0 comments on commit 7f5c0e6

Please sign in to comment.