Skip to content

Commit

Permalink
JuliaVersionNumber to allow using "nightly"
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jun 11, 2020
1 parent f859488 commit cbcb960
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/bot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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").
Expand Down Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions src/bot/botutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions test/bot/bot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -420,4 +420,6 @@ bottestdir = GoodPath(@__DIR__)

# just in case
cd(snoopcompiledir)

include("botutils.jl")
end
8 changes: 8 additions & 0 deletions test/bot/botutils.jl
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit cbcb960

Please sign in to comment.