From 6e7b5c9454634acbb3ce803abbede4ff70530bdc Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Thu, 28 Mar 2024 11:53:59 +0100 Subject: [PATCH] Frontend test: instantiate and precompile before --- .github/workflows/FrontendTest.yml | 25 ++++++++++++++- src/packages/PkgUtils.jl | 51 +++++++++++++++--------------- 2 files changed, 50 insertions(+), 26 deletions(-) diff --git a/.github/workflows/FrontendTest.yml b/.github/workflows/FrontendTest.yml index 99db72eeee..df6be941d9 100644 --- a/.github/workflows/FrontendTest.yml +++ b/.github/workflows/FrontendTest.yml @@ -32,7 +32,30 @@ jobs: - name: Install Pluto.jl packages run: | - julia --project=$GITHUB_WORKSPACE -e "using Pkg; Pkg.instantiate()" + julia --project=$GITHUB_WORKSPACE -e ' + using Pkg + Pkg.instantiate() + + # run all the notebooks once to get the package environments ready + import Pluto + nbs = readdir(joinpath("test", "frontend", "fixtures"); join=true) + + for n in nbs + try + @info "running" n + try + Pluto.activate_notebook_environment(n; show_help=false) + catch + Pkg.activate() + end + Pkg.instantiate() + Pkg.precompile() + include(n) + Pkg.instantiate() + Pkg.precompile() + catch + end + end' - uses: actions/setup-node@v3 with: diff --git a/src/packages/PkgUtils.jl b/src/packages/PkgUtils.jl index 01d50e488b..e3d759f112 100644 --- a/src/packages/PkgUtils.jl +++ b/src/packages/PkgUtils.jl @@ -106,7 +106,7 @@ function update_notebook_environment(path::String; kwargs...) end -function activate_notebook_environment(path::String) +function activate_notebook_environment(path::String; show_help::Bool=true) notebook_ref = Ref(load_notebook(path)) ensure_has_nbpkg(notebook_ref[]) @@ -199,30 +199,31 @@ function activate_notebook_environment(path::String) # end # end - println() - """ - - > Notebook environment activated! - - ## Step 1. - _Press `]` to open the Pkg REPL._ - - The notebook environment is currently active. - - ## Step 2. - The notebook file and your REPL environment are now synced. This means that: - 1. Any changes you make in the REPL environment will be written to the notebook file. For example, you can `pkg> update` or `pkg> add SomePackage`, and the notebook file will update. - 2. Whenever the notebook file changes, the REPL environment will be updated from the notebook file. - - ## Step 3. - When you are done, you can exit the notebook environment by deactivating it: - - ``` - pkg> activate - ``` - """ |> Markdown.parse |> display - println() - + if show_help + println() + """ + + > Notebook environment activated! + + ## Step 1. + _Press `]` to open the Pkg REPL._ + + The notebook environment is currently active. + + ## Step 2. + The notebook file and your REPL environment are now synced. This means that: + 1. Any changes you make in the REPL environment will be written to the notebook file. For example, you can `pkg> update` or `pkg> add SomePackage`, and the notebook file will update. + 2. Whenever the notebook file changes, the REPL environment will be updated from the notebook file. + + ## Step 3. + When you are done, you can exit the notebook environment by deactivating it: + + ``` + pkg> activate + ``` + """ |> Markdown.parse |> display + println() + end end