Skip to content

Add non-zero exit code when deps check fails #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ scala_binary(
visibility = ["//visibility:public"],
deps = [
"//src/main/scala/higherkindness/rules_scala/common/args",
"//src/main/scala/higherkindness/rules_scala/common/error",
"//src/main/scala/higherkindness/rules_scala/common/interrupt",
"//src/main/scala/higherkindness/rules_scala/common/sandbox",
"//src/main/scala/higherkindness/rules_scala/common/worker",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ package workers.deps
import common.args.ArgsUtil
import common.args.ArgsUtil.PathArgumentType
import common.args.implicits.*
import common.error.AnnexWorkerError
import common.interrupt.InterruptUtil
import common.worker.WorkerMain
import common.sandbox.SandboxUtil
import common.worker.WorkerMain
import workers.common.AnnexMapper
import workers.common.FileUtil
import java.io.{File, PrintStream}
Expand Down Expand Up @@ -163,11 +164,6 @@ object DepsRunner extends WorkerMain[Unit] {
} else {
Nil
}
labelsToRemove.foreach { depLabel =>
out.println(s"Target '$depLabel' not used, please remove it from the deps.")
out.println(s"You can use the following buildozer command:")
out.println(s"buildozer 'remove deps $depLabel' ${workRequest.label}")
}

InterruptUtil.throwIfInterrupted()
val labelsToAdd = if (workRequest.checkDirect) {
Expand All @@ -182,16 +178,26 @@ object DepsRunner extends WorkerMain[Unit] {
} else {
Nil
}
labelsToAdd.foreach { depLabel =>
out.println(s"Target '$depLabel' is used but isn't explicitly declared, please add it to the deps.")
out.println(s"You can use the following buildozer command:")
out.println(s"buildozer 'add deps $depLabel' ${workRequest.label}")
}

if (labelsToAdd.isEmpty && labelsToRemove.isEmpty) {
try Files.createFile(workRequest.successFile)
catch { case _: FileAlreadyExistsException => }
} else {
val errorMessage = new StringBuilder()
labelsToRemove.foreach { depLabel =>
errorMessage.append(s"Target '$depLabel' not used, please remove it from the deps.\n")
errorMessage.append("You can use the following buildozer command:\n")
errorMessage.append(s"buildozer 'remove deps $depLabel' ${workRequest.label}\n")
}

labelsToAdd.foreach { depLabel =>
errorMessage.append(s"Target '$depLabel' is used but isn't explicitly declared, please add it to the deps.\n")
errorMessage.append("You can use the following buildozer command:\n")
errorMessage.append(s"buildozer 'add deps $depLabel' ${workRequest.label}\n")
}
throw new AnnexWorkerError(1, errorMessage.result())
}

InterruptUtil.throwIfInterrupted()
}
}