diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 198b4fd..d89d6c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,7 +89,7 @@ jobs: key: ${{ steps.cache-julia.outputs.cache-primary-key }} - name: Run notebooks if: ${{ steps.cache-nb.outputs.cache-hit != 'true' }} - run: julia --project=@. --color=yes -p ${{ env.LITERATE_PROC }} run.jl + run: julia --project=@. --color=yes -p ${{ env.LITERATE_PROC }} ci.jl - name: Copy back built notebooks run: cp --verbose -rf ${{ env.NBCACHE }}/docs/* docs/ - name: Build website diff --git a/run.jl b/ci.jl similarity index 92% rename from run.jl rename to ci.jl index c16eb4e..04ed6ac 100644 --- a/run.jl +++ b/ci.jl @@ -95,7 +95,7 @@ function main(; (; ipynbs, litnbs) = list_notebooks(basedir, cachedir) - if length(litnbs) > 0 + if !isempty(litnbs) # Execute literate notebooks in worker process(es) ts_lit = pmap(litnbs; on_error=ex -> NaN) do nb @elapsed run_literate(nb, cachedir; rmsvg) @@ -120,7 +120,7 @@ function main(; ts_lit = [] end - if length(ipynbs) > 0 + if !isempty(ipynbs) # Install IJulia kernel IJulia.installkernel("Julia", "--project=@.", "--heap-size-hint=4G") @@ -129,11 +129,15 @@ function main(; kernelname = "--ExecutePreprocessor.kernel_name=julia-1.$(VERSION.minor)" execute = ifelse(get(ENV, "ALLOWERRORS", " ") == "true", "--execute --allow-errors", "--execute") timeout = "--ExecutePreprocessor.timeout=" * get(ENV, "TIMEOUT", "-1") - cmds = [`jupyter nbconvert --to notebook $(execute) $(timeout) $(kernelname) --output $(joinpath(abspath(pwd()), cachedir, nb)) $(nb)` for nb in ipynbs] # Run the nbconvert commands in parallel - ts_ipynb = asyncmap(cmds; ntasks) do cmd - @elapsed run(cmd) + ts_ipynb = asyncmap(ipynbs; ntasks) do nb + @elapsed begin + nbout = joinpath(abspath(pwd()), cachedir, nb) + cmd = `jupyter nbconvert --to notebook $(execute) $(timeout) $(kernelname) --output $(nbout) $(nb)` + run(cmd) + rmsvg && strip_svg(nbout) + end end else ts_ipynb = []