Skip to content

Commit 4bd55c0

Browse files
Add tests for imports and license checking
1 parent ab3364c commit 4bd55c0

5 files changed

Lines changed: 91 additions & 11 deletions

File tree

.github/workflows/CI.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,37 @@ jobs:
5151

5252
- uses: julia-actions/cache@d10a6fd8f31b12404a54613ebad242900567f2b9 # v2.1.0
5353

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

56-
- uses: julia-actions/julia-runtest@678da69444cd5f13d7e674a90cb4f534639a14f9 # v1.11.2
79+
- name: Tests
80+
uses: julia-actions/julia-runtest@678da69444cd5f13d7e674a90cb4f534639a14f9 # v1.11.2
81+
82+
#
83+
# License Cleanup:
84+
#
85+
- name: Remove LicenseSpring cache
86+
run: julia --startup-file=no --project=scripts scripts/remove_license_cache.jl
87+
if: always()

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: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ using Test
33

44
@testset "PumasProductManager" begin
55
# NOTE: update whenever new versions are released.
6-
expected_versions = [
7-
"DeepPumas@0.8.0",
8-
"DeepPumas@0.8.1",
9-
"Pumas@2.6.0",
10-
"Pumas@2.6.1",
11-
]
6+
expected_versions = ["DeepPumas@0.8.0", "DeepPumas@0.8.1", "Pumas@2.6.0", "Pumas@2.6.1"]
127

138
@testset "Version listing" begin
149
io = IOBuffer()
@@ -38,16 +33,21 @@ using Test
3833
end
3934

4035
for each in expected_versions
41-
dirs = [
42-
joinpath(DEPOT_PATH[1], "environments", each),
43-
joinpath(dir, each),
44-
]
36+
dirs =
37+
[joinpath(DEPOT_PATH[1], "environments", each), joinpath(dir, each)]
4538
for folder in dirs
4639
contents = readdir(folder)
4740
@test "Project.toml" in contents
4841
@test "Manifest.toml" in contents
4942
end
5043
end
44+
45+
for each in expected_versions
46+
product, _ = split(each, "@"; limit = 2)
47+
file = joinpath(@__DIR__, "$product.jl")
48+
cmd = `julia $channel $file`
49+
@test contains(readchomp(cmd), ":success")
50+
end
5151
end
5252
end
5353
finally

0 commit comments

Comments
 (0)