Skip to content

Commit

Permalink
Merge pull request #135 from JuliaCI/tb/uuid
Browse files Browse the repository at this point in the history
Save the package UUID.
  • Loading branch information
maleadt authored Oct 5, 2022
2 parents bcb604a + f14575e commit 67b77d1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/evaluate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -266,17 +266,16 @@ function evaluate_test(config::Configuration, pkg::Package; kwargs...)
versioninfo()
using Pkg
using Base: UUID, PkgId
package_spec = eval(Meta.parse(ARGS[1]))
println("\nCompleted after $(elapsed(t0))")
# check if we even need to install the package
# (it might be available in the system image already)
try
# XXX: use a Base API, by UUID?
eval(:(using $(Symbol(package_spec.name))))
catch
package_id = PkgId(package_spec.uuid, package_spec.name)
if !Base.root_module_exists(package_id)
print("\n\n", '#'^80, "\n# Installation\n#\n\n")
println("Started at ", now(UTC), "\n")
t1 = time()
Expand Down Expand Up @@ -472,6 +471,7 @@ function evaluate_compiled_test(config::Configuration, pkg::Package; kwargs...)
println()
using Pkg
using Base: UUID
package_spec = eval(Meta.parse(ARGS[1]))
println("Installing PackageCompiler...")
Expand Down
9 changes: 3 additions & 6 deletions src/registry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ Read all packages from a registry and return them as a vector of Package structs
function registry_packages(config::Configuration)
packages = Package[]

# NOTE: we handle Registry check-outs ourselves, so can't use Pkg APIs
# (since they do not accept an argument to point to a custom Registry)
registry = get_registry(config)
for char in 'A':'Z', entry in readdir(joinpath(registry, string(char)))
path = joinpath(registry, string(char), entry)
isdir(path) || continue
registry_instance = Pkg.Registry.RegistryInstance(registry)
for (_, pkg) in registry_instance
# TODO: read package compat info so that we can avoid testing uninstallable packages
push!(packages, Package(name=entry))
push!(packages, Package(name=pkg.name, uuid=pkg.uuid))
end
return packages
end
Expand Down
16 changes: 15 additions & 1 deletion src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,29 @@ end
Base.@kwdef struct Package
# source of the package; forwarded to PackageSpec
name::String
uuid::Base.UUID = find_package_uuid(name)
version::Union{Nothing,VersionNumber} = nothing
url::Union{Nothing,String} = nothing
rev::Union{Nothing,String} = nothing
end

function find_package_uuid(name)
# TODO: if this is performance sensitive, build a map on first use
registries = Pkg.Registry.reachable_registries()
for reg in registries
for (_, pkg) in reg
if name == pkg.name
return pkg.uuid
end
end
end
error("Package $name not found in any reachable registry")
end

# convert a Package to a tuple that's Pkg.add'able
function package_spec_tuple(pkg::Package)
spec = (;)
for field in (:name, :version, :url, :rev)
for field in (:name, :uuid, :version, :url, :rev)
val = getfield(pkg, field)
if val !== nothing
spec = merge(spec, NamedTuple{(field,)}((val,)))
Expand Down

0 comments on commit 67b77d1

Please sign in to comment.