Dependents now wait for the baseline gate to pass on the base branch instead of a specific branch merging.
83 lines
3.1 KiB
Go
83 lines
3.1 KiB
Go
package workflow
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"os/exec"
|
|
"strings"
|
|
)
|
|
|
|
// gateEnvironmentCause returns why a failed gate command is an environment
|
|
// failure the repair agent cannot fix, or "" for an ordinary code failure.
|
|
// Two signals count: the command could not start, or its output contains one
|
|
// of a fixed set of missing-infrastructure messages.
|
|
func gateEnvironmentCause(out string, runErr error) string {
|
|
if execErr, ok := errors.AsType[*exec.Error](runErr); ok {
|
|
return "the gate command could not be started (" + execErr.Error() + ")"
|
|
}
|
|
lower := strings.ToLower(out)
|
|
for _, m := range gateEnvironmentMarkers {
|
|
if strings.Contains(lower, m.marker) {
|
|
return m.cause
|
|
}
|
|
}
|
|
return ""
|
|
}
|
|
|
|
// gateEnvironmentMarkers pairs an output fragment a missing host resource
|
|
// produces with the cause it names. Markers are matched case-insensitively
|
|
// against the gate's combined output.
|
|
var gateEnvironmentMarkers = []struct {
|
|
marker string
|
|
cause string
|
|
}{
|
|
{
|
|
marker: "is docker running?",
|
|
cause: "the Docker daemon required by the test harness is unavailable",
|
|
},
|
|
{
|
|
marker: "cannot connect to the docker daemon",
|
|
cause: "the Docker daemon is unavailable",
|
|
},
|
|
{
|
|
marker: "rootless docker not found",
|
|
cause: "the Docker daemon is unavailable",
|
|
},
|
|
{
|
|
marker: "failed to create docker provider",
|
|
cause: "the Docker daemon is unavailable",
|
|
},
|
|
{
|
|
marker: "docker: command not found",
|
|
cause: "the docker CLI is not installed",
|
|
},
|
|
}
|
|
|
|
// baselineEnvironmentError is the park reason when a gate failed for an
|
|
// environment cause: it names the cause and keeps the gate output an operator
|
|
// needs to confirm it. The stage returns this without dispatching a builder.
|
|
func baselineEnvironmentError(argv []string, out, cause string) error {
|
|
return fmt.Errorf("baseline red -- %s cannot run in this environment: %s\n\ngate output:\n%s",
|
|
strings.Join(argv, " "), cause, clipTail(out, baselineParkOutputBytes))
|
|
}
|
|
|
|
// baselineSharedError is the park reason for a task that did not repair the
|
|
// baseline because another task owns that repair.
|
|
func baselineSharedError(argv []string, out string, claim BaselineClaim) error {
|
|
verdict := fmt.Sprintf("task %d repaired it in a pull request; retry once the baseline gate passes on the base branch", claim.Task)
|
|
if claim.Failure != "" {
|
|
verdict = fmt.Sprintf("task %d could not repair it: %s", claim.Task, claim.Failure)
|
|
}
|
|
return fmt.Errorf("baseline red -- %s fails at this revision and %s\n\ngate output:\n%s",
|
|
strings.Join(argv, " "), verdict, clipTail(out, baselineParkOutputBytes))
|
|
}
|
|
|
|
// baselineFixFailedError is the park reason for every failure after the
|
|
// baseline repair agent was dispatched. A failure that names only the agent --
|
|
// a provider 402, say -- and drops the gate output leaves the operator with no
|
|
// way to see why the gate was red in the first place.
|
|
func baselineFixFailedError(argv []string, out, cause string) error {
|
|
return fmt.Errorf("baseline red -- %s fails and the baseline-fix builder did not repair it: %s\n\ngate output:\n%s",
|
|
strings.Join(argv, " "), cause, clipTail(out, baselineParkOutputBytes))
|
|
}
|