aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/mbf
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/mbf')
-rw-r--r--cmd/mbf/internal/ci/ci.go37
-rw-r--r--cmd/mbf/main.go23
2 files changed, 60 insertions, 0 deletions
diff --git a/cmd/mbf/internal/ci/ci.go b/cmd/mbf/internal/ci/ci.go
index 5c993a1b..b1ee6a8c 100644
--- a/cmd/mbf/internal/ci/ci.go
+++ b/cmd/mbf/internal/ci/ci.go
@@ -450,6 +450,10 @@ const (
// endpointDist accepts a Path.writeSource stream and produces a
// distribution for the submitted source.
endpointDist = "/dist"
+
+ // endpointRace is like endpointDist, but the resulting distribution is
+ // instrumented with the data race detector.
+ endpointRace = "/race"
)
// MakeDist creates a hakurei distribution using the CI service.
@@ -465,6 +469,19 @@ func (p Path) MakeDist(
return p.fetch(ctx, id, output)
}
+// MakeDistRace creates a hakurei distribution (race) using the CI service.
+func (p Path) MakeDistRace(
+ ctx context.Context,
+ w io.Writer,
+ output, source, version string,
+) error {
+ id, err := p.writeSource(ctx, w, endpointRace, source, version)
+ if err != nil {
+ return err
+ }
+ return p.fetch(ctx, id, output)
+}
+
// Serve services CI workload dispatched to c.
func Serve(ctx context.Context, msg message.Msg, c *pkg.Cache) error {
const shutdownTimeout = 15 * time.Second
@@ -495,6 +512,26 @@ func Serve(ctx context.Context, msg message.Msg, c *pkg.Cache) error {
)
}
})
+ mux.HandleFunc("POST "+endpointRace, func(w http.ResponseWriter, r *http.Request) {
+ s, err := readSource(w, r)
+ if err != nil {
+ msg.Verbose(err)
+ return
+ }
+ defer putS(s)
+
+ _, a := s.Std().MustLoad(rosa.H("hakurei-dist-race"))
+ if err = cure(c, a, w); err != nil {
+ msg.Verbose(err)
+ return
+ }
+ if msg.IsVerbose() {
+ msg.Verbosef(
+ "satisfied distribution %s (race)",
+ pkg.Encode(c.Ident(a).Value()),
+ )
+ }
+ })
if r, err := os.OpenRoot(p.String()); err != nil {
return err
diff --git a/cmd/mbf/main.go b/cmd/mbf/main.go
index 5dd4e8a0..dd5ee624 100644
--- a/cmd/mbf/main.go
+++ b/cmd/mbf/main.go
@@ -548,6 +548,29 @@ func main() {
"Write the resulting distribution to the named directory",
)
}
+ {
+ var flagOutput string
+ _ci.NewCommand(
+ "race",
+ "Request distribution tarball (race) for the specified source directory",
+ func(args []string) error {
+ if len(args) != 2 {
+ return errors.New("race requires 2 arguments")
+ }
+
+ return ci.Path(cm.base).MakeDistRace(
+ ctx,
+ os.Stdout,
+ flagOutput,
+ args[0], args[1],
+ )
+ },
+ ).Flag(
+ &flagOutput,
+ "o", command.StringFlag("."),
+ "Write the resulting distribution to the named directory",
+ )
+ }
c.NewCommand(
"keygen",