depends_on Meta-Argument
The depends_on meta-argument in Togomak establishes dependencies between stages, ensuring they execute in the specified order.
Usage
You can use the depends_on meta-argument in module blocks and in all stage blocks. It requires a list of references to other resources
or child modules in the same calling module.
This list cannot include arbitrary expressions because the depends_on
value must be known before togomak knows resource relationships and thus before it can safely evaluate expressions.
We recommend always including a comment that explains why using depends_on is necessary.
stage "example" {
  script = "echo hello world"
  depends_on = [stage.dependency1, stage.dependency2]
}Case Study
The following is a summarized version of github.com/srevinsaju/togomak's togomak.hcl pipeline:
stage "fmt" {
  script = "go fmt github.com/srevinsaju/togomak/v1/..."
  lifecycle {
    phase = ["default", "validate"]
  }
}
 
stage "vet" {
  script = "go vet github.com/srevinsaju/togomak/v1/..."
  lifecycle {
    phase = ["default", "validate"]
  }
}
 
stage "build" {
  depends_on = [stage.fmt, stage.vet]
  script     = "go build -v -o ./cmd/togomak/togomak github.com/srevinsaju/togomak/v1/cmd/togomak"
  lifecycle {
    phase = ["default", "build"]
  }
}
 
stage "install" {
  depends_on = [stage.build]
  script     = "go install github.com/srevinsaju/togomak/v1/cmd/togomak"
  lifecycle {
    phase = ["default", "install"]
}In the above code, the stage.build will only execute after stage.fmt and stage.validate both run.
stage.fmt and stage.validate will run concurrently. Meanwhile, stage.install will run only after
all three: stage.fmt, stage.validate and stage.build stages complete successfully.