Skip to content

Commit

Permalink
Define QuantumPropagators.VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
goerz committed Dec 14, 2023
1 parent d30a08a commit f5ac1b7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,35 @@ jobs:
run: wget https://raw.githubusercontent.com/JuliaQuantumControl/JuliaQuantumControl/master/typos.toml
- name: Spell Check
uses: crate-ci/typos@master
- name: Version Check
shell: julia {0}
run: |
using Pkg
VERSION = VersionNumber(Pkg.TOML.parsefile("Project.toml")["version"])
BRANCH = ENV["GITHUB_REF_NAME"]
if ENV["GITHUB_EVENT_NAME"] == "pull_request"
# For pull_request events, return the head (aka., "from") branch,
# not the base (aka., "to") branch.
BRANCH = ENV["GITHUB_HEAD_REF"]
end
if startswith(BRANCH, "release-")
if (length(VERSION.prerelease) == length(VERSION.build))
println("Version $VERSION on release branch OK")
else
@error "Invalid version $VERSION on release branch"
exit(1)
end
elseif (ENV["GITHUB_REF_TYPE"] == "branch") && (BRANCH != "master")
if ("dev" in VERSION.prerelease) || ("dev" in VERSION.build)
println("Version $VERSION OK with dev-suffix on $BRANCH")
else
@error "Invalid version $VERSION on branch $BRANCH: must contain dev suffix"
exit(1)
end
else
println("Version $VERSION OK on $BRANCH")
end
exit(0)
- name: Get codestyle settings
run: wget https://raw.githubusercontent.com/JuliaQuantumControl/JuliaQuantumControl/master/.JuliaFormatter.toml
- name: Install JuliaFormatter and format
Expand Down
10 changes: 10 additions & 0 deletions src/QuantumPropagators.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
module QuantumPropagators


const VERSION = let
project = joinpath(dirname(dirname(pathof(QuantumPropagators))), "Project.toml")
Base.include_dependency(project) # Retrigger precompilation when Project.toml changes
toml = read(project, String)
m = match(r"(*ANYCRLF)^version\s*=\s\"(.*)\"$"m, toml)
VersionNumber(m[1])
end


include("arnoldi.jl") # submodule Arnoldi
include("specrad.jl") # submodule SpectralRange
include("cheby.jl") # submodule Cheby
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ using SafeTestsets
# Note: comment outer @testset to stop after first @safetestset failure
@time @testset verbose = true "QuantumPropagators" begin

@test v"0.1.0" < QuantumPropagators.VERSION < v"1.0.0"

println("\n* Doctests:")
@time @safetestset "Doctests" begin
using QuantumPropagators, Test, Documenter
Expand Down

0 comments on commit f5ac1b7

Please sign in to comment.