Skip to content

Commit 9fce8dd

Browse files
authored
Use the same plotlyjs version number for all imports (#480)
* Use the same plotlyjs version number for all imports * add tests for _js_path and _js_version
1 parent 5562c6c commit 9fce8dd

7 files changed

Lines changed: 16 additions & 9 deletions

File tree

.github/workflows/artifacts.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ jobs:
1313
gen-artifacts:
1414
# The type of runner that the job will run on
1515
runs-on: ubuntu-latest
16-
# The plotly version. Bumping this environment variable should do the trick
17-
env:
18-
PLOTLY_VER: 2.3.0
1916

2017
# Steps represent a sequence of tasks that will be executed as part of the job
2118
steps:
@@ -33,7 +30,7 @@ jobs:
3330
- name: "Get artifact"
3431
run: |
3532
cd $GITHUB_WORKSPACE
36-
julia -e 'include(joinpath(pwd(),"deps","generate_artifacts.jl")); generate_artifacts("'"$PLOTLY_VER"'","'"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"'")'
33+
julia -e 'include(joinpath(pwd(),"deps","generate_artifacts.jl")); generate_artifacts("'"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"'")'
3734
3835
- name: "Commit updated Artifacts.toml"
3936
run: |

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ tags/
66
tags
77
site/
88
.ipynb_checkpoints/
9-
assets/plotly-latest.min.js
10-
deps/plotly-latest.min.js
9+
assets/plotly-*.min.js
10+
deps/plotly-*.min.js
1111
deps/plotschema.json
1212
deps/schema.html
1313
deps/*.csv

deps/generate_artifacts.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
using Pkg.Artifacts
33
using Downloads
44

5-
function generate_artifacts(ver="latest", repo="https://github.com/JuliaPlots/PlotlyJS.jl")
5+
ver = include("./plotly_cdn_version.jl")
6+
7+
function generate_artifacts(repo="https://github.com/JuliaPlots/PlotlyJS.jl")
68
artifacts_toml = joinpath(dirname(@__DIR__), "Artifacts.toml")
79

810
# if Artifacts.toml does not exist we also do not have to remove it

deps/plotly_cdn_version.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# run the artifacts.yml Github Action after changing this file
2+
"2.3.0"

src/PlotlyJS.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export plot, dataset, list_datasets, make_subplots, savefig, mgrid
2626
# globals for this package
2727
const _pkg_root = dirname(dirname(@__FILE__))
2828
const _js_path = joinpath(artifact"plotly-artifacts", "plotly.min.js")
29-
const _js_cdn_path = "https://cdn.plot.ly/plotly-latest.min.js"
29+
const _js_version = include(joinpath(_pkg_root, "deps", "plotly_cdn_version.jl"))
30+
const _js_cdn_path = "https://cdn.plot.ly/plotly-$(_js_version).min.js"
3031
const _mathjax_cdn_path =
3132
"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_SVG"
3233

src/display.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function SyncPlot(
3131

3232
# setup scope
3333
deps = [
34-
"Plotly" => joinpath(artifact"plotly-artifacts", "plotly.min.js"),
34+
"Plotly" => _js_path,
3535
joinpath(@__DIR__, "..", "assets", "plotly_webio.bundle.js")
3636
]
3737
scope = Scope(imports=deps)

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ const M = PlotlyJS
1010
# include("blink.jl")
1111
include("kaleido.jl")
1212

13+
# these are public API
14+
@test isfile(PlotlyJS._js_path)
15+
@test !isempty(PlotlyJS._js_version)
16+
@test !startswith(PlotlyJS._js_version, "v")
17+
1318
end

0 commit comments

Comments
 (0)