Skip to content

Commit

Permalink
Reapply "refactor: reduce Reservoir build fetch attempts & warnings (#…
Browse files Browse the repository at this point in the history
…5600)"

This reverts commit 1cf7623.
  • Loading branch information
kim-em committed Oct 4, 2024
1 parent 3c14e9d commit 01d414a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
15 changes: 10 additions & 5 deletions src/lake/Lake/Build/Package.lean
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def Package.maybeFetchBuildCache (self : Package) : FetchM (BuildJob Bool) := do
let shouldFetch :=
(← getTryCache) &&
(self.preferReleaseBuild || -- GitHub release
(!self.scope.isEmpty && !(← getElanToolchain).isEmpty)) -- Reservoir
!(self.scope.isEmpty -- no Reservoir
|| (← getElanToolchain).isEmpty
|| (← self.buildDir.pathExists)))
if shouldFetch then
self.optBuildCache.fetch
else
Expand All @@ -65,9 +67,12 @@ def Package.maybeFetchBuildCacheWithWarning (self : Package) := do
let job ← self.maybeFetchBuildCache
job.bindSync fun success t => do
unless success do
let details ← self.optFacetDetails <| if self.preferReleaseBuild then
optGitHubReleaseFacet else optReservoirBarrelFacet
logWarning s!"building from source; failed to fetch cloud build{details}"
if self.preferReleaseBuild then
let details ← self.optFacetDetails optGitHubReleaseFacet
logWarning s!"building from source; failed to fetch GitHub release{details}"
else
let details ← self.optFacetDetails optReservoirBarrelFacet
logVerbose s!"building from source; failed to fetch Reservoir build{details}"
return ((), t)

@[deprecated maybeFetchBuildCacheWithWarning (since := "2024-09-27")]
Expand Down Expand Up @@ -173,7 +178,7 @@ def Package.optBarrelFacetConfig : PackageFacetConfig optReservoirBarrelFacet :=

/-- The `PackageFacetConfig` for the builtin `reservoirBarrelFacet`. -/
def Package.barrelFacetConfig : PackageFacetConfig reservoirBarrelFacet :=
mkBuildArchiveFacetConfig optReservoirBarrelFacet "Reservoir barrel"
mkBuildArchiveFacetConfig optReservoirBarrelFacet "Reservoir build"

/-- The `PackageFacetConfig` for the builtin `optGitHubReleaseFacet`. -/
def Package.optGitHubReleaseFacetConfig : PackageFacetConfig optGitHubReleaseFacet :=
Expand Down
2 changes: 1 addition & 1 deletion src/lake/tests/noRelease/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ EOF
# Test that an indirect fetch on the release does not cause the build to fail
$LAKE build Test | diff -u --strip-trailing-cr <(cat << EOF
⚠ [2/5] Ran dep:extraDep
warning: building from source; failed to fetch cloud build (run with '-v' for details)
warning: building from source; failed to fetch GitHub release (run with '-v' for details)
✔ [4/5] Built Test
Build completed successfully.
EOF
Expand Down
9 changes: 6 additions & 3 deletions src/lake/tests/online/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ $LAKE -v -f git.toml build @Cli:extraDep |

./clean.sh
$LAKE -f barrel.lean update
# Test that narrels are not fetched without a toolchain
# Test that barrels are not fetched after the build directory is created.
mkdir -p .lake/packages/Cli/.lake/build
($LAKE -v -f barrel.lean build @Cli:extraDep) |
grep --color "Cli:optBarrel" && exit 1 || true
rmdir .lake/packages/Cli/.lake/build
# Test that barrels are not fetched without a toolchain
(ELAN_TOOLCHAIN= $LAKE -v -f barrel.lean build @Cli:extraDep) |
grep --color "Cli:optBarrel" && exit 1 || true
($LAKE -v -f barrel.lean build @Cli:barrel && exit 1 || true) |
Expand All @@ -28,8 +33,6 @@ $LAKE -v -f barrel.lean build @Cli:extraDep |
grep --color "Cli:optBarrel"
$LAKE -f barrel.lean build @Cli:extraDep |
grep --color "Cli:optBarrel" && exit 1 || true
$LAKE -f barrel.lean build @Cli:extraDep |
grep --color "(run with '-v' for details)"
# Test cache toggle
(LAKE_NO_CACHE=1 $LAKE -v -f barrel.lean build @Cli:extraDep) |
grep --color "Cli:optBarrel" && exit 1 || true
Expand Down

0 comments on commit 01d414a

Please sign in to comment.