aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/mbf/internal/ci
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-10-01 22:24:09 +0900
committerOphestra <cat@gensokyo.uk>2026-10-01 22:24:09 +0900
commit4b19686109b0962ea68dfe58feafffe3bac9c202 (patch)
tree706d986f74c012eb414f03c268bec057b3c5ba86 /cmd/mbf/internal/ci
parent8fea10f7d05648900ce1d9abb899402298382e7d (diff)
cmd/dist: optionally build with race instrument
This is mostly useful for the integration test suites. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/mbf/internal/ci')
-rw-r--r--cmd/mbf/internal/ci/ci.go37
1 files changed, 37 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