Skip to content

Commit 0326dde

Browse files
Expand testing to all available versions (#4)
* Expand testing to all available versions * Enable depot caching * Add tests for imports and license checking Clean precompile files and clones before and after testing
1 parent faf7ca6 commit 0326dde

6 files changed

Lines changed: 193 additions & 15 deletions

File tree

.github/workflows/CI.yml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,52 @@ jobs:
4949
with:
5050
channel: "release"
5151

52+
- uses: julia-actions/cache@d10a6fd8f31b12404a54613ebad242900567f2b9 # v2.1.0
53+
54+
- run: julia --startup-file=no --project=scripts scripts/clean_precompile_files.jl
55+
56+
#
57+
# License Setup:
58+
#
59+
60+
- name: Ensure no LicenseSpring cache
61+
run: julia --startup-file=no --project=scripts scripts/remove_license_cache.jl
62+
63+
- name: Create Pumas license file
64+
run: echo "${LICENSESPRING_KEY:?}" > ~/.julia/PumasLicense.txt
65+
shell: bash
66+
env:
67+
LICENSESPRING_KEY: ${{ secrets.LICENSESPRING_KEY }}
68+
69+
- name: Create DeepPumas license file
70+
run: echo "${LICENSESPRING_KEY:?}" > ~/.julia/DeepPumasLicense.txt
71+
shell: bash
72+
env:
73+
LICENSESPRING_KEY: ${{ secrets.LICENSESPRING_KEY_DEEPPUMAS }}
74+
75+
#
76+
# Testing:
77+
#
78+
5279
- uses: julia-actions/julia-buildpkg@e3eb439fad4f9aba7da2667e7510e4a46ebc46e1 # v1.7.0
5380

54-
- uses: julia-actions/julia-runtest@678da69444cd5f13d7e674a90cb4f534639a14f9 # v1.11.2
81+
- name: Tests
82+
uses: julia-actions/julia-runtest@678da69444cd5f13d7e674a90cb4f534639a14f9 # v1.11.2
83+
84+
#
85+
# License Cleanup:
86+
#
87+
- run: rm -f ~/.julia/PumasLicense.txt
88+
if: always()
89+
shell: bash
90+
91+
- run: rm -f ~/.julia/DeepPumasLicense.txt
92+
if: always()
93+
shell: bash
94+
95+
- name: Remove LicenseSpring cache
96+
run: julia --startup-file=no --project=scripts scripts/remove_license_cache.jl
97+
if: always()
98+
99+
- run: julia --startup-file=no --project=scripts scripts/clean_precompile_files.jl
100+
if: always()

scripts/clean_precompile_files.jl

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
for depot in DEPOT_PATH
2+
clones = joinpath(depot, "clones")
3+
if isdir(clones)
4+
try
5+
rm(clones, force = true, recursive = true)
6+
@info "Removed clones directory" clones
7+
catch e
8+
@warn "Failed to remove clones directory" clones e
9+
end
10+
end
11+
12+
compiled = joinpath(depot, "compiled")
13+
if isdir(compiled)
14+
for version in readdir(compiled, join = true)
15+
removals = ["PumasProductManager", "Pumas", "DeepPumas"]
16+
for each in removals
17+
path = joinpath(version, each)
18+
@info "Checking compiled directory" path
19+
if isdir(path)
20+
try
21+
rm(path, force = true, recursive = true)
22+
@info "Removed compiled directory" path
23+
catch e
24+
@warn "Failed to remove compiled directory" path e
25+
end
26+
end
27+
end
28+
end
29+
else
30+
@warn "Compiled directory not found" compiled
31+
end
32+
33+
environments = joinpath(depot, "environments")
34+
if isdir(environments)
35+
for env in readdir(environments, join = true)
36+
@info "Checking environment directory" env
37+
candidates = ["PumasProductManager", "Pumas", "DeepPumas"]
38+
if any(startswith(env, candidate) for candidate in candidates)
39+
try
40+
rm(env, force = true, recursive = true)
41+
@info "Removed environment directory" env
42+
catch e
43+
@warn "Failed to remove environment directory" env e
44+
end
45+
end
46+
end
47+
else
48+
@warn "Environments directory not found" environments
49+
end
50+
end

scripts/remove_license_cache.jl

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
if get(ENV, "CI", "false") == "true"
2+
for each in readdir(Base.DEPOT_PATH[1], join = true)
3+
if endswith(each, "License.txt") && isfile(each)
4+
@info "License file found" each
5+
rm(each, force = true)
6+
@info "License file removed" each
7+
end
8+
end
9+
10+
if Sys.islinux()
11+
dir = joinpath(homedir(), ".LicenseSpring")
12+
if isdir(dir)
13+
rm(dir, force = true, recursive = true)
14+
@info "LicenseSpring cache directory removed" dir
15+
else
16+
@warn "LicenseSpring cache directory not found" dir
17+
end
18+
elseif Sys.isapple()
19+
dir = joinpath(homedir(), "Library", "Application Support", "LicenseSpring")
20+
if isdir(dir)
21+
rm(dir, force = true, recursive = true)
22+
@info "LicenseSpring cache directory removed" dir
23+
else
24+
@warn "LicenseSpring cache directory not found" dir
25+
end
26+
elseif Sys.iswindows()
27+
dir = joinpath(homedir(), "AppData", "Local", "LicenseSpring")
28+
if isdir(dir)
29+
rm(dir, force = true, recursive = true)
30+
@info "LicenseSpring cache directory removed" dir
31+
else
32+
@warn "LicenseSpring cache directory not found" dir
33+
end
34+
else
35+
error("Unsupported OS")
36+
end
37+
else
38+
@warn "This script is intended to be run only in CI"
39+
end

test/DeepPumas.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
using DeepPumas
2+
3+
@model begin end
4+
5+
@show :success

test/Pumas.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
using Pumas
2+
3+
@model begin end
4+
5+
@show :success

test/runtests.jl

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,59 @@ import PumasProductManager
22
using Test
33

44
@testset "PumasProductManager" begin
5-
io = IOBuffer()
6-
PumasProductManager.list(io)
7-
list = String(take!(io))
8-
@test contains(list, "Pumas@2.6.1")
5+
# NOTE: update whenever new versions are released.
6+
expected_versions = ["DeepPumas@0.8.0", "DeepPumas@0.8.1", "Pumas@2.6.0", "Pumas@2.6.1"]
7+
8+
@testset "Version listing" begin
9+
io = IOBuffer()
10+
PumasProductManager.list(io)
11+
list = String(take!(io))
12+
13+
for each in expected_versions
14+
@test contains(list, each)
15+
end
16+
end
17+
918
try
1019
mktempdir() do dir
11-
cd(dir) do
12-
withenv("JULIA_PKG_PRECOMPILE_AUTO" => "0") do
13-
PumasProductManager.init("Pumas@2.6.1", "pumas-2.6.1")
20+
@testset "Installation" begin
21+
cd(dir) do
22+
withenv("JULIA_PKG_PRECOMPILE_AUTO" => "1") do
23+
for each in expected_versions
24+
PumasProductManager.init(each)
25+
PumasProductManager.init(each, each)
26+
end
27+
end
1428
end
15-
end
16-
status = readchomp(`juliaup st`)
17-
@test contains(status, "Pumas@2.6.1")
1829

19-
contents = readdir(joinpath(dir, "pumas-2.6.1"))
20-
@test "Project.toml" in contents
21-
@test "Manifest.toml" in contents
30+
status = readchomp(`juliaup st`)
31+
for each in expected_versions
32+
@test contains(status, each)
33+
end
34+
35+
for each in expected_versions
36+
dirs =
37+
[joinpath(DEPOT_PATH[1], "environments", each), joinpath(dir, each)]
38+
for folder in dirs
39+
contents = readdir(folder)
40+
@test "Project.toml" in contents
41+
@test "Manifest.toml" in contents
42+
end
43+
end
44+
45+
for each in expected_versions
46+
product, _ = split(each, "@"; limit = 2)
47+
file = joinpath(@__DIR__, "$product.jl")
48+
channel = "+$each"
49+
cmd = `julia $channel $file`
50+
@test contains(readchomp(cmd), ":success")
51+
end
52+
end
2253
end
2354
finally
24-
@test success(`juliaup rm Pumas@2.6.1`)
55+
for each in expected_versions
56+
@test success(`juliaup rm $each`)
57+
end
2558
@test success(`juliaup rm PumasProductManager`)
2659
end
2760
end

0 commit comments

Comments
 (0)