diff --git a/src/bot.jl b/src/bot.jl index ec0fa89dc..0cdf570a3 100644 --- a/src/bot.jl +++ b/src/bot.jl @@ -35,7 +35,7 @@ Example: `else_os = "linux"` - `version`: A vector of of versions to give the list of versions that you want to generate precompile signatures for. -Example: `version = [v"1.1", v"1.4.1"]` +Example: `version = [v"1.1", v"1.4.1", "nightly"]` It is assumed that the generated precompile signatures are valid for patch versions of Julia (e.g. giving v"1.4.2" assumses v"1.4.0" to v"1.4.9"). @@ -94,13 +94,20 @@ function BotConfig( exhaustive::Bool = false, os::Union{Vector{String}, Nothing} = nothing, else_os::Union{String, Nothing} = nothing, - version::Union{Vector{VersionNumber}, Nothing} = nothing, - else_version::Union{VersionNumber, Nothing} = nothing, + version::Union{Vector{<:Union{VersionNumber,String}}, Nothing} = nothing, + else_version::Union{VersionNumber, String, Nothing} = nothing, package_path::AbstractString = pathof_noload(package_name), precompiles_rootpath::AbstractString = "$(dirname(dirname(package_path)))/deps/SnoopCompile/precompile", subst::AbstractVector = Vector{Pair{UStrings, UStrings}}(), tmin::AbstractFloat = 0.0, ) + + if !isnothing(version) + version = JuliaVersionNumber.(version) + end + if !isnothing(else_version) + else_version = JuliaVersionNumber(else_version) + end return BotConfig(package_name, blacklist, exhaustive, os, else_os, version, else_version, GoodPath(package_path), GoodPath(precompiles_rootpath), subst, tmin) end diff --git a/src/bot/botutils.jl b/src/bot/botutils.jl index 33ec50be6..00e37eeaa 100644 --- a/src/bot/botutils.jl +++ b/src/bot/botutils.jl @@ -280,3 +280,35 @@ julia> VersionFloat(v"1.4.2") ``` """ VersionFloat(v::VersionNumber) = join(split(string(v),'.')[1:2],'.') + +# https://github.com/JuliaLang/julia/pull/36223: +""" + JuliaVersionNumber(v::String) + JuliaVersionNumber(v::VersionNumber) +returns the Julia version number by following the same specifications as VersionNumber. +`JuliaVersionNumber` will fetch the latest nightly version number if `"nightly"` or `"latest"` is given as the input. +# Examples +```julia +julia> JuliaVersionNumber("nightly") +v"1.6.0-DEV" +``` +```jldoctest +julia> JuliaVersionNumber("1.2.3") +v"1.2.3" +julia> JuliaVersionNumber(v"1.2.3") +v"1.2.3" +``` +""" +JuliaVersionNumber(v::VersionNumber) = v +function JuliaVersionNumber(v::String) + if in(v, ["nightly", "latest"]) + version_path = download( + "https://raw.githubusercontent.com/JuliaLang/julia/master/VERSION", + joinpath(tempdir(), "VERSION.txt"), + ) + version_str = replace(Base.read(version_path, String), "\n" => "") + return VersionNumber(version_str) + else + return VersionNumber(v) + end +end diff --git a/test/bot/bot.jl b/test/bot/bot.jl index e4da1b16b..871a18af8 100644 --- a/test/bot/bot.jl +++ b/test/bot/bot.jl @@ -420,4 +420,6 @@ bottestdir = GoodPath(@__DIR__) # just in case cd(snoopcompiledir) + + include("botutils.jl") end diff --git a/test/bot/botutils.jl b/test/bot/botutils.jl new file mode 100644 index 000000000..d7614dfe9 --- /dev/null +++ b/test/bot/botutils.jl @@ -0,0 +1,8 @@ +# JuliaVersionNumber + +# https://github.com/JuliaLang/julia/pull/36223: +# @test SnoopCompile.JuliaVersionNumber("nightly") == + # VersionNumber(replace(Base.read("VERSION", String), "\n" => "")) +# @test thispatch(SnoopCompile.JuliaVersionNumber("nightly")) == thispatch(VERSION) +@test SnoopCompile.JuliaVersionNumber("1.2.3") == v"1.2.3" +@test SnoopCompile.JuliaVersionNumber(v"1.2.3") == v"1.2.3"