Skip to content

Commit 9be8eef

Browse files
committed
Do not install packages in parallel (#108)
bors r+
1 parent be24711 commit 9be8eef

File tree

2 files changed

+36
-29
lines changed

2 files changed

+36
-29
lines changed

docs/literate.jl

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
# Retrieve filename of literate script
1+
# Retrieve name of example and output directory
22
if length(ARGS) != 2
3-
error("please specify the literate script and the output directory")
3+
error("please specify the name of the example and the output directory")
44
end
5-
const SCRIPTJL = ARGS[1]
5+
const EXAMPLE = ARGS[1]
66
const OUTDIR = ARGS[2]
77

88
# Activate environment
9+
# Note that each example's Project.toml must include Literate as a dependency
910
using Pkg: Pkg
10-
Pkg.activate(dirname(SCRIPTJL))
11+
const EXAMPLEPATH = joinpath(@__DIR__, "..", "examples", EXAMPLE)
12+
Pkg.activate(EXAMPLEPATH)
1113
Pkg.instantiate()
1214
using Literate: Literate
1315

@@ -38,19 +40,10 @@ function preprocess(content)
3840
end
3941

4042
# Convert to markdown and notebook
43+
const SCRIPTJL = joinpath(EXAMPLEPATH, "script.jl")
4144
Literate.markdown(
42-
SCRIPTJL,
43-
OUTDIR;
44-
name=basename(dirname(SCRIPTJL)),
45-
documenter=false,
46-
execute=true,
47-
preprocess=preprocess,
45+
SCRIPTJL, OUTDIR; name=EXAMPLE, documenter=false, execute=true, preprocess=preprocess
4846
)
4947
Literate.notebook(
50-
SCRIPTJL,
51-
OUTDIR;
52-
name=basename(dirname(SCRIPTJL)),
53-
documenter=false,
54-
execute=true,
55-
preprocess=preprocess,
48+
SCRIPTJL, OUTDIR; name=EXAMPLE, documenter=false, execute=true, preprocess=preprocess
5649
)

docs/make.jl

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,36 @@
1+
### Process examples
12
# Always rerun examples
23
const EXAMPLES_OUT = joinpath(@__DIR__, "src", "examples")
34
ispath(EXAMPLES_OUT) && rm(EXAMPLES_OUT; recursive=true)
45
mkpath(EXAMPLES_OUT)
56

7+
# Install and precompile all packages
8+
# Workaround for https://github.com/JuliaLang/Pkg.jl/issues/2219
9+
examples = filter!(isdir, readdir(joinpath(@__DIR__, "..", "examples"); join=true))
10+
let script = "using Pkg; Pkg.activate(ARGS[1]); Pkg.instantiate()"
11+
for example in examples
12+
if !success(`$(Base.julia_cmd()) -e $script $example`)
13+
error(
14+
"project environment of example ",
15+
basename(example),
16+
" could not be instantiated",
17+
)
18+
end
19+
end
20+
end
621
# Run examples asynchronously
7-
const EXAMPLES_SRC = joinpath(@__DIR__, "..", "examples")
8-
const LITERATEJL = joinpath(@__DIR__, "literate.jl")
9-
processes = map(filter!(isdir, readdir(EXAMPLES_SRC; join=true))) do example
10-
scriptjl = joinpath(example, "script.jl")
11-
return run(
12-
pipeline(
13-
`$(Base.julia_cmd()) $LITERATEJL $scriptjl $EXAMPLES_OUT`;
14-
stdin=devnull,
15-
stdout=devnull,
16-
stderr=stderr,
17-
);
18-
wait=false,
19-
)::Base.Process
22+
processes = let literatejl = joinpath(@__DIR__, "literate.jl")
23+
map(examples) do example
24+
return run(
25+
pipeline(
26+
`$(Base.julia_cmd()) $literatejl $(basename(example)) $EXAMPLES_OUT`;
27+
stdin=devnull,
28+
stdout=devnull,
29+
stderr=stderr,
30+
);
31+
wait=false,
32+
)::Base.Process
33+
end
2034
end
2135

2236
# Check that all examples were run successfully

0 commit comments

Comments
 (0)