mesh/merge-gate out of date: judged against trunk bff5b7f0e4f8, the trunk is now 372faebf2824; judged again on a recheck or when it is merged
mesh/repo-check out of date: judged against trunk bff5b7f0e4f8, the trunk is now 372faebf2824; judged again on a recheck or when it is merged
mesh/delivery-group group feat/350-one-build-per-change checking: composed check out of date: novox/mesh-controller@cd49b50c4075 was judged against trunk bff5b…
mesh/delivery superseded: a newer head of the same pull request
A merge built every moved module a second time although its check had judged the same tree (issue 649). The check now builds into the scratch namespace under a reuse key (source fingerprint plus the builder's own digest), and the walk of the trunk commit copies a build of the same key by digest instead of building, saying per module why when it cannot (novox/hq ADR 0350).
88 lines
3.1 KiB
Go
88 lines
3.1 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"os"
|
|
"strconv"
|
|
|
|
"github.com/novox/mesh-controller/internal/builder"
|
|
"github.com/novox/mesh-controller/internal/inventory"
|
|
)
|
|
|
|
// A pull request's check builds go when it closes (novox/hq ADR 0350 §5): the build seat keeps them in the artifact
|
|
// store's scratch namespace for the walk of its merge to take. **Let go of where the moment is heard**: the
|
|
// controller ends the walk answering a merge — after that walk took what it reuses — and the delivery's owner, which
|
|
// hears the forge say a pull request closed unmerged, asks the `forget-checks` verb; both let go through the store,
|
|
// as the controller's own collection does. The build seat's holders let go of anything a week old on their own,
|
|
// so a word lost here leaves a week's builds, never more.
|
|
|
|
// checkBuildsIn is the scratch namespace as the controller reaches the artifact store.
|
|
func checkBuildsIn(ctx context.Context, inv *inventory.Inventory) (builder.Scratch, error) {
|
|
shelf, err := inv.Catalogue(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
address, err := artifactStoreAddress(ctx, inv, shelf, "")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if address == "" {
|
|
return nil, errors.New("the artifact store is not on the mesh's network")
|
|
}
|
|
return builder.Registry{Address: address}, nil
|
|
}
|
|
|
|
// forgetChecks lets go of a pull request's check builds and answers what it did.
|
|
var forgetChecks = func(ctx context.Context, inv *inventory.Inventory, pull builder.PullRef) (string, error) {
|
|
scratch, err := checkBuildsIn(ctx, inv)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
n, err := scratch.Forget(ctx, pull)
|
|
if err != nil {
|
|
return "", fmt.Errorf("%s: %d check(s)' builds let go of, and not all: %w", pull, n, err)
|
|
}
|
|
return fmt.Sprintf("%s: %d check(s)' builds let go of", pull, n), nil
|
|
}
|
|
|
|
// forgetChecksOfWalk lets go, on the save that ends a walk, of the check builds of every pull request whose merge
|
|
// it answers: the walk took what it reuses. Said, never fatal.
|
|
func forgetChecksOfWalk(ctx context.Context, inv *inventory.Inventory, p inventory.Plan) {
|
|
if p.WalkSaid != inventory.WalkEnded || p.Delivery == nil {
|
|
return
|
|
}
|
|
for _, pull := range reuseAskOf(&p).Pulls {
|
|
said, err := forgetChecks(ctx, inv, builder.PullRef{Owner: pull.Owner, Repo: pull.Repo, Number: pull.Number})
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "%s: its check builds stay until the week's sweep: %v\n", p.ID, err)
|
|
continue
|
|
}
|
|
fmt.Printf("%s: %s\n", p.ID, said)
|
|
}
|
|
}
|
|
|
|
// forgetChecksCommand is `forget-checks <owner> <repo> <number>`: the verb the delivery's owner asks when the forge
|
|
// says a pull request closed unmerged (novox/hq ADR 0350 §5).
|
|
func forgetChecksCommand(ctx context.Context, args []string) error {
|
|
if len(args) != 3 {
|
|
return errors.New("forget-checks <owner> <repo> <number>")
|
|
}
|
|
number, err := strconv.Atoi(args[2])
|
|
if err != nil || number <= 0 {
|
|
return fmt.Errorf("%q is not a pull request's number", args[2])
|
|
}
|
|
open, err := openStores(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer open.Close()
|
|
said, err := forgetChecks(ctx, open.inventory, builder.PullRef{Owner: args[0], Repo: args[1], Number: number})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Println(said)
|
|
return nil
|
|
}
|