@@ -16,6 +16,7 @@ import (
1616 "time"
1717
1818 "github.com/grafana/k6build"
19+ "github.com/grafana/k6build/pkg/api"
1920 "github.com/grafana/k6build/pkg/catalog"
2021 "github.com/grafana/k6build/pkg/lock"
2122 "github.com/grafana/k6build/pkg/store"
@@ -171,23 +172,27 @@ func (b *Builder) Build( //nolint:funlen
171172 // Try to get the object, if not found, try to acquire a build lock.
172173 // If the build lock is not acquired, assume some other builder is building the binary.
173174 // Sleep and retry.
175+ // If nocache is set, skip the cache lookup and go straight to building.
176+ noCache := api .NoCache (ctx )
174177 var artifactObject store.Object
175178 for {
176- artifactObject , err = b .store .Get (ctx , id )
177- if err == nil {
178- b .metrics .storeHitsCounter .Inc ()
179-
180- return k6build.Artifact {
181- ID : id ,
182- Checksum : artifactObject .Checksum ,
183- URL : artifactObject .URL ,
184- Dependencies : resolvedVersions (resolved ),
185- Platform : platform ,
186- }, nil
187- }
188-
189- if ! errors .Is (err , store .ErrObjectNotFound ) {
190- return k6build.Artifact {}, k6build .NewWrappedError (k6build .ErrAccessingArtifact , err )
179+ if ! noCache {
180+ artifactObject , err = b .store .Get (ctx , id )
181+ if err == nil {
182+ b .metrics .storeHitsCounter .Inc ()
183+
184+ return k6build.Artifact {
185+ ID : id ,
186+ Checksum : artifactObject .Checksum ,
187+ URL : artifactObject .URL ,
188+ Dependencies : resolvedVersions (resolved ),
189+ Platform : platform ,
190+ }, nil
191+ }
192+
193+ if ! errors .Is (err , store .ErrObjectNotFound ) {
194+ return k6build.Artifact {}, k6build .NewWrappedError (k6build .ErrAccessingArtifact , err )
195+ }
191196 }
192197
193198 acquired , unlock , err := b .lock .Try (ctx , id )
0 commit comments