Skip to content

Commit

Permalink
don't precompile early in CI during build
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Dec 16, 2022
1 parent 45a4160 commit 476b368
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ for f in (:develop, :add, :rm, :up, :pin, :free, :test, :build, :status, :why)
pkgs = deepcopy(pkgs) # don't mutate input
foreach(handle_package_input!, pkgs)
ret = $f(ctx, pkgs; kwargs...)
$(f in (:add, :up, :pin, :free, :build)) && Pkg._auto_precompile(ctx)
$(f in (:add, :up, :pin, :free)) && Pkg._auto_precompile(ctx)
# don't precompile early in CI during build because the native cached code will be regenerated for the test setup
$(f == :build) && !(tryparse(Bool, get(ENV, "CI", "")) === true) && Pkg._auto_precompile(ctx)
$(f in (:up, :pin, :free, :rm)) && Pkg._auto_gc(ctx)
return ret
end
Expand Down
8 changes: 6 additions & 2 deletions test/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ end
@info "Auto precompilation enabled"
Pkg.develop(Pkg.PackageSpec(path="packages/Dep4"))
Pkg.develop(Pkg.PackageSpec(path="packages/NoVersion")) # a package with no version number
Pkg.build(io=iob) # should trigger auto-precomp
withenv("CI" => "false") do
Pkg.build(io=iob) # should trigger auto-precomp when not on CI
end
@test occursin("Precompiling", String(take!(iob)))
Pkg.precompile(io=iob)
@test !occursin("Precompiling", String(take!(iob))) # test that the previous precompile was a no-op
Expand All @@ -153,7 +155,9 @@ end

ENV["JULIA_PKG_PRECOMPILE_AUTO"]=1
Pkg.develop(Pkg.PackageSpec(path="packages/BrokenDep"))
Pkg.build(io=iob) # should trigger auto-precomp and soft-error
withenv("CI" => "false") do
Pkg.build(io=iob) # should trigger auto-precomp and soft-error when not on CI
end
@test occursin("Precompiling", String(take!(iob)))
broken_packages = Pkg.API.pkgs_precompile_suspended
@test length(broken_packages) == 1
Expand Down

0 comments on commit 476b368

Please sign in to comment.