Skip to content

Commit 094d57b

Browse files
Debug CI failure on plots tests (#312)
* Debug CI failure on plots tests * Only run integration tests with external packages against Julia LTS+
1 parent 8ba293e commit 094d57b

16 files changed

+464
-417
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
depwarn: "yes"
106106
- uses: julia-actions/julia-processcoverage@03114f09f119417c3242a9fb6e0b722676aedf38 # v1.2.2
107107
if: matrix.os == 'ubuntu-latest' && matrix.version == '1.11'
108-
- uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
108+
- uses: codecov/codecov-action@fdcc8476540edceab3de004e990f80d881c6cc00 # v5.5.0
109109
if: matrix.os == 'ubuntu-latest' && matrix.version == '1.11'
110110
with:
111111
verbose: true

test/testsets/display.jl

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
include("../utilities/prelude.jl")
1+
if VERSION >= v"1.10"
2+
include("../utilities/prelude.jl")
23

3-
test_example(joinpath(@__DIR__, "../examples/display.qmd")) do json
4-
cells = json["cells"]
5-
@test length(cells) == 5
4+
test_example(joinpath(@__DIR__, "../examples/display.qmd")) do json
5+
cells = json["cells"]
6+
@test length(cells) == 5
67

7-
cell = cells[4]
8-
outputs = cell["outputs"]
9-
@test length(outputs) == 2
8+
cell = cells[4]
9+
outputs = cell["outputs"]
10+
@test length(outputs) == 2
1011

11-
@test outputs[1]["output_type"] == "display_data"
12-
@test haskey(outputs[1]["data"], "image/png")
12+
@test outputs[1]["output_type"] == "display_data"
13+
@test haskey(outputs[1]["data"], "image/png")
1314

14-
@test outputs[2]["output_type"] == "display_data"
15-
@test haskey(outputs[2]["data"], "image/png")
15+
@test outputs[2]["output_type"] == "display_data"
16+
@test haskey(outputs[2]["data"], "image/png")
17+
end
1618
end
Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
include("../../utilities/prelude.jl")
1+
if VERSION >= v"1.10"
2+
include("../../utilities/prelude.jl")
23

3-
test_example(joinpath(@__DIR__, "../../examples/integrations/CairoMakie.qmd")) do json
4-
cells = json["cells"]
5-
cell = cells[6]
4+
test_example(joinpath(@__DIR__, "../../examples/integrations/CairoMakie.qmd")) do json
5+
cells = json["cells"]
6+
cell = cells[6]
67

7-
px_per_inch = 96
8+
px_per_inch = 96
89

9-
# the size metadata is just inches converted to CSS pixels, independent of pixel resolution
10-
@test cell["outputs"][1]["metadata"]["image/png"] ==
11-
Dict("width" => 4 * px_per_inch, "height" => 3 * px_per_inch)
10+
# the size metadata is just inches converted to CSS pixels, independent of pixel resolution
11+
@test cell["outputs"][1]["metadata"]["image/png"] ==
12+
Dict("width" => 4 * px_per_inch, "height" => 3 * px_per_inch)
1213

13-
pngbytes = Base64.base64decode(cell["outputs"][1]["data"]["image/png"])
14-
@test QuartoNotebookRunner.png_image_metadata(pngbytes; phys_correction = false) ==
15-
(; width = 4 * 150, height = 3 * 150)
14+
pngbytes = Base64.base64decode(cell["outputs"][1]["data"]["image/png"])
15+
@test QuartoNotebookRunner.png_image_metadata(pngbytes; phys_correction = false) ==
16+
(; width = 4 * 150, height = 3 * 150)
17+
end
1618
end
Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,48 @@
1-
include("../../utilities/prelude.jl")
2-
3-
4-
@testset "CairoMakie fig-formats" begin
5-
s = read(
6-
joinpath(@__DIR__, "../../examples/integrations/CairoMakieFigFormat.qmd"),
7-
String,
8-
)
9-
10-
env = abspath(joinpath(@__DIR__, "../../examples/integrations/CairoMakie/Project.toml"))
11-
12-
showable_mimes(::Union{Val{:png},Val{:jpeg},Val{:retina}}) = ["image/png", "text/html"]
13-
showable_mimes(::Union{Val{:pdf},Val{:svg}}) = ["image/svg+xml", "application/pdf"]
14-
not_showable_mimes(::Union{Val{:png},Val{:jpeg},Val{:retina}}) =
15-
showable_mimes(Val(:pdf))
16-
not_showable_mimes(::Union{Val{:pdf},Val{:svg}}) = ["text/html"] # png stays as a fallback that should not be chosen if svg or pdf are accepted
17-
18-
mktempdir() do dir
19-
server = QuartoNotebookRunner.Server()
20-
file = joinpath(dir, "temp.qmd")
21-
22-
@testset "$format" for format in [:png, :jpeg, :retina, :svg, :pdf]
23-
open(file, "w") do io
24-
# 1.6 doesn't support multiple patterns
25-
for pattern in [
26-
"retina" => format,
27-
"CAIROMAKIE_ENV" => repr(env),
28-
"NOT_SHOWABLE_MIMES" => repr(not_showable_mimes(Val(format))),
29-
"SHOWABLE_MIMES" => repr(showable_mimes(Val(format))),
30-
]
31-
s = replace(s, pattern)
1+
if VERSION >= v"1.10"
2+
include("../../utilities/prelude.jl")
3+
4+
5+
@testset "CairoMakie fig-formats" begin
6+
s = read(
7+
joinpath(@__DIR__, "../../examples/integrations/CairoMakieFigFormat.qmd"),
8+
String,
9+
)
10+
11+
env = abspath(
12+
joinpath(@__DIR__, "../../examples/integrations/CairoMakie/Project.toml"),
13+
)
14+
15+
showable_mimes(::Union{Val{:png},Val{:jpeg},Val{:retina}}) =
16+
["image/png", "text/html"]
17+
showable_mimes(::Union{Val{:pdf},Val{:svg}}) = ["image/svg+xml", "application/pdf"]
18+
not_showable_mimes(::Union{Val{:png},Val{:jpeg},Val{:retina}}) =
19+
showable_mimes(Val(:pdf))
20+
not_showable_mimes(::Union{Val{:pdf},Val{:svg}}) = ["text/html"] # png stays as a fallback that should not be chosen if svg or pdf are accepted
21+
22+
mktempdir() do dir
23+
server = QuartoNotebookRunner.Server()
24+
file = joinpath(dir, "temp.qmd")
25+
26+
@testset "$format" for format in [:png, :jpeg, :retina, :svg, :pdf]
27+
open(file, "w") do io
28+
# 1.6 doesn't support multiple patterns
29+
for pattern in [
30+
"retina" => format,
31+
"CAIROMAKIE_ENV" => repr(env),
32+
"NOT_SHOWABLE_MIMES" => repr(not_showable_mimes(Val(format))),
33+
"SHOWABLE_MIMES" => repr(showable_mimes(Val(format))),
34+
]
35+
s = replace(s, pattern)
36+
end
37+
print(io, s)
3238
end
33-
print(io, s)
39+
40+
result = QuartoNotebookRunner.run!(server, file)
41+
@test result.cells[6].outputs[1].data["text/plain"] == "true"
42+
@test result.cells[8].outputs[1].data["text/plain"] == "true"
3443
end
3544

36-
result = QuartoNotebookRunner.run!(server, file)
37-
@test result.cells[6].outputs[1].data["text/plain"] == "true"
38-
@test result.cells[8].outputs[1].data["text/plain"] == "true"
45+
QuartoNotebookRunner.close!(server)
3946
end
40-
41-
QuartoNotebookRunner.close!(server)
4247
end
4348
end
Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
1-
include("../../utilities/prelude.jl")
1+
if VERSION >= v"1.10"
2+
include("../../utilities/prelude.jl")
23

3-
if Sys.iswindows()
4-
# There are issues with the Kaleido_jll v0.2 build on Windows, skip for now.
5-
@info "Skipping PlotlyJS.jl tests on Windows"
6-
else
7-
test_example(joinpath(@__DIR__, "../../examples/integrations/PlotlyJS.qmd")) do json
8-
cells = json["cells"]
9-
preamble_cell = cells[5]
10-
outputs = preamble_cell["outputs"]
11-
@test length(outputs) == 1
12-
data = outputs[1]["data"]
13-
@test keys(data) == Set(["text/html", "text/plain"])
14-
@test startswith(data["text/html"], "<script type=\"text/javascript\">")
15-
@test occursin("require.undef(\"plotly\")", data["text/html"])
16-
for nth in (6, 9)
17-
cell = cells[nth]
18-
outputs = cell["outputs"]
4+
if Sys.iswindows()
5+
# There are issues with the Kaleido_jll v0.2 build on Windows, skip for now.
6+
@info "Skipping PlotlyJS.jl tests on Windows"
7+
else
8+
test_example(joinpath(@__DIR__, "../../examples/integrations/PlotlyJS.qmd")) do json
9+
cells = json["cells"]
10+
preamble_cell = cells[5]
11+
outputs = preamble_cell["outputs"]
1912
@test length(outputs) == 1
2013
data = outputs[1]["data"]
21-
@test haskey(data, "image/png")
22-
@test haskey(data, "image/svg+xml")
23-
@test haskey(data, "text/html")
24-
@test startswith(data["text/html"], "<div>")
14+
@test keys(data) == Set(["text/html", "text/plain"])
15+
@test startswith(data["text/html"], "<script type=\"text/javascript\">")
16+
@test occursin("require.undef(\"plotly\")", data["text/html"])
17+
for nth in (6, 9)
18+
cell = cells[nth]
19+
outputs = cell["outputs"]
20+
@test length(outputs) == 1
21+
data = outputs[1]["data"]
22+
@test haskey(data, "image/png")
23+
@test haskey(data, "image/svg+xml")
24+
@test haskey(data, "text/html")
25+
@test startswith(data["text/html"], "<div>")
26+
end
2527
end
2628
end
2729
end

test/testsets/integrations/Plots.jl

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
include("../../utilities/prelude.jl")
1+
if VERSION >= v"1.10"
2+
include("../../utilities/prelude.jl")
23

3-
test_example(joinpath(@__DIR__, "../../examples/integrations/Plots.qmd")) do json
4-
cells = json["cells"]
5-
cell = cells[6]
6-
output = cell["outputs"][1]
4+
test_example(joinpath(@__DIR__, "../../examples/integrations/Plots.qmd")) do json
5+
cells = json["cells"]
6+
cell = cells[6]
7+
output = cell["outputs"][1]
78

8-
@test !isempty(output["data"]["image/png"])
9-
@test !isempty(output["data"]["image/svg+xml"])
10-
@test !isempty(output["data"]["text/html"])
9+
@test !isempty(output["data"]["image/png"])
10+
@test !isempty(output["data"]["image/svg+xml"])
11+
@test !isempty(output["data"]["text/html"])
1112

12-
@test cell["outputs"][1]["metadata"]["image/png"] ==
13-
Dict("width" => 575, "height" => 432) # Plots does not seem to follow standard dpi rules so the values don't match Makie
14-
end
13+
@test cell["outputs"][1]["metadata"]["image/png"] ==
14+
Dict("width" => 575, "height" => 432) # Plots does not seem to follow standard dpi rules so the values don't match Makie
15+
end
1516

16-
test_example(joinpath(@__DIR__, "../../examples/integrations/PlotsPDF.qmd")) do json
17-
cells = json["cells"]
17+
test_example(joinpath(@__DIR__, "../../examples/integrations/PlotsPDF.qmd")) do json
18+
cells = json["cells"]
1819

19-
cell = cells[4]
20-
output = cell["outputs"][1]
20+
cell = cells[4]
21+
output = cell["outputs"][1]
2122

22-
@test !isempty(output["data"]["application/pdf"])
23+
@test !isempty(output["data"]["application/pdf"])
24+
end
2325
end
Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,45 @@
1-
include("../../utilities/prelude.jl")
1+
if VERSION >= v"1.10"
2+
include("../../utilities/prelude.jl")
23

3-
test_example(joinpath(@__DIR__, "../../examples/integrations/PythonCall.qmd")) do json
4-
cells = json["cells"]
4+
test_example(joinpath(@__DIR__, "../../examples/integrations/PythonCall.qmd")) do json
5+
cells = json["cells"]
56

6-
cell = cells[8]
7-
@test occursin("PythonCall", cell["outputs"][1]["data"]["text/plain"])
7+
cell = cells[8]
8+
@test occursin("PythonCall", cell["outputs"][1]["data"]["text/plain"])
89

9-
cell = cells[11]
10-
@test occursin("'PythonCall'", cell["outputs"][1]["text"])
10+
cell = cells[11]
11+
@test occursin("'PythonCall'", cell["outputs"][1]["text"])
1112

12-
cell = cells[16]
13-
@test occursin("5", cell["outputs"][1]["data"]["text/plain"])
13+
cell = cells[16]
14+
@test occursin("5", cell["outputs"][1]["data"]["text/plain"])
1415

15-
cell = cells[17]
16-
@test occursin("Inline python code: something.", join(cell["source"]))
16+
cell = cells[17]
17+
@test occursin("Inline python code: something.", join(cell["source"]))
1718

18-
cell = cells[22]
19-
@test occursin("1000", cell["outputs"][1]["data"]["text/plain"])
19+
cell = cells[22]
20+
@test occursin("1000", cell["outputs"][1]["data"]["text/plain"])
2021

21-
cell = cells[27]
22-
@test occursin("150", cell["outputs"][1]["data"]["text/plain"])
22+
cell = cells[27]
23+
@test occursin("150", cell["outputs"][1]["data"]["text/plain"])
2324

24-
cell = cells[30]
25-
@test isempty(cell["outputs"])
25+
cell = cells[30]
26+
@test isempty(cell["outputs"])
2627

27-
cell = cells[33]
28-
traceback = cell["outputs"][1]["traceback"]
29-
@test occursin("division by zero", traceback[1])
30-
@test occursin("PythonCall.qmd:54", traceback[4])
31-
@test occursin("PythonCall.qmd:58", traceback[end])
28+
cell = cells[33]
29+
traceback = cell["outputs"][1]["traceback"]
30+
@test occursin("division by zero", traceback[1])
31+
@test occursin("PythonCall.qmd:54", traceback[4])
32+
@test occursin("PythonCall.qmd:58", traceback[end])
3233

33-
cell = cells[36]
34-
traceback = cell["outputs"][1]["traceback"]
35-
@test occursin("unmatched ']'", traceback[1])
36-
@test occursin("PythonCall.qmd, line 62", traceback[1])
37-
@test occursin("ast.py", traceback[end])
34+
cell = cells[36]
35+
traceback = cell["outputs"][1]["traceback"]
36+
@test occursin("unmatched ']'", traceback[1])
37+
@test occursin("PythonCall.qmd, line 62", traceback[1])
38+
@test occursin("ast.py", traceback[end])
3839

39-
cell = cells[39]
40-
output = cell["outputs"][1]
41-
@test output["name"] == "stdout"
42-
@test occursin("Define the builtin 'help'.", output["text"])
40+
cell = cells[39]
41+
output = cell["outputs"][1]
42+
@test output["name"] == "stdout"
43+
@test occursin("Define the builtin 'help'.", output["text"])
44+
end
4345
end

test/testsets/integrations/RCall.jl

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
include("../../utilities/prelude.jl")
1+
if VERSION >= v"1.10"
2+
include("../../utilities/prelude.jl")
23

3-
test_example(joinpath(@__DIR__, "../../examples/integrations/RCall.qmd")) do json
4-
cells = json["cells"]
5-
cell = cells[4]
6-
output = cell["outputs"][1]
7-
8-
@test !isempty(output["data"]["image/png"])
9-
10-
@test cell["outputs"][1]["metadata"]["image/png"] ==
11-
Dict("width" => 600, "height" => 450)
12-
end
13-
14-
# Don't run this on macOS CI, since that appears to be missing the required libs.
15-
if !(get(ENV, "CI", "false") == "true" && Sys.isapple())
16-
test_example(joinpath(@__DIR__, "../../examples/integrations/RCallSVG.qmd")) do json
4+
test_example(joinpath(@__DIR__, "../../examples/integrations/RCall.qmd")) do json
175
cells = json["cells"]
186
cell = cells[4]
197
output = cell["outputs"][1]
208

21-
@test !isempty(output["data"]["image/svg+xml"])
22-
@test isempty(cell["outputs"][1]["metadata"])
9+
@test !isempty(output["data"]["image/png"])
10+
11+
@test cell["outputs"][1]["metadata"]["image/png"] ==
12+
Dict("width" => 600, "height" => 450)
13+
end
14+
15+
# Don't run this on macOS CI, since that appears to be missing the required libs.
16+
if !(get(ENV, "CI", "false") == "true" && Sys.isapple())
17+
test_example(joinpath(@__DIR__, "../../examples/integrations/RCallSVG.qmd")) do json
18+
cells = json["cells"]
19+
cell = cells[4]
20+
output = cell["outputs"][1]
21+
22+
@test !isempty(output["data"]["image/svg+xml"])
23+
@test isempty(cell["outputs"][1]["metadata"])
24+
end
2325
end
2426
end

0 commit comments

Comments
 (0)