-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresolve.jl
93 lines (86 loc) · 2.59 KB
/
resolve.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using Pkg: Pkg
function recurse_projects(
f,
path=".";
io=stdout,
top=true,
exclude=("test", "docs", "deps", "user", ".conda", ".CondaPkg", ".git"),
top_proj=Base.active_project(),
kwargs...,
)
path = realpath(path)
@sync for subpath in readdir(path)
fullpath = joinpath(path, subpath)
if endswith(fullpath, "Project.toml")
f(path, fullpath; io, kwargs...)
elseif isdir(fullpath)
if !startswith(fullpath, ".") && all(!endswith(fullpath, e) for e in exclude)
recurse_projects(f, fullpath; io, top=false, top_proj, kwargs...)
end
end
end
top && Pkg.activate(top_proj)
end
function _update_project(path, fullpath; precomp, inst, doupdate, io=stdout)
projpath = dirname(joinpath(path, fullpath))
Pkg.activate(projpath; io)
if doupdate
prev_offline_status = Pkg.OFFLINE_MODE[]
Pkg.offline(false)
Pkg.update()
Pkg.offline(prev_offline_status)
else
Pkg.resolve(; io)
end
if precomp
Pkg.precompile(; io)
end
if inst
Pkg.instantiate(; io)
end
end
function update_projects(path="."; io=stdout, doupdate=false, inst=false, precomp=false)
recurse_projects(_update_project, path; io, doupdate, inst, precomp)
end
function _project_name!(path, fullpath; io, projects)
projpath = dirname(joinpath(path, fullpath))
Pkg.activate(projpath; io)
name = Pkg.project().name
isnothing(name) || push!(projects, name)
end
function projects_name(path="."; io=stdout)
projects = Set{String}()
recurse_projects(_project_name!, path; io, projects)
projects
end
function purge_compilecache(path="."; io=stdout)
names = projects_name(path; io)
compiled = joinpath(
homedir(), ".julia", "compiled", "v$(Int(VERSION.major)).$(Int(VERSION.minor))"
)
@info "Purging compiled cache" dir = compiled n = length(names)
sleep(0)
for name in names
pkg_path = joinpath(compiled, name)
if isdir(pkg_path)
rm(pkg_path; recursive=true)
end
end
end
@doc "List of directories to put into tests.yml julia process coverage action"
function coverage_directories(sep=",")
names = projects_name(; io=devnull)
buf = IOBuffer()
try
for name in sort!([n for n in names])
if name ∈ ("Zarr", "PlanarDev", "Cli", "PlanarInteractive", "Temporal")
continue
else
write(buf, joinpath(name, "src"), sep)
end
end
String(take!(buf))
finally
close(buf)
end
end