From bd105b09bf8f917e24885e61b5aede7ef04f1f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Fuhrmann?= Date: Thu, 8 Jan 2026 21:06:55 +0100 Subject: [PATCH 1/6] Run scripts in script directory testscripts now behaves like include: the script is executed in in the directory where it is locate instead of the current directory. This fixes the situation where scripts or notebooks activate environments relative to their location. --- Project.toml | 2 +- examples/ExamplePluto2.jl | 45 +++++++++++++++++++++++++++++++++++++++ src/scripts.jl | 8 ++++--- test/runtests.jl | 12 +++++------ 4 files changed, 56 insertions(+), 11 deletions(-) create mode 100644 examples/ExamplePluto2.jl diff --git a/Project.toml b/Project.toml index 3ac579a..a52898e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ExampleJuggler" uuid = "3bbe58f8-ed81-4c4e-a134-03e85fcf4a1a" authors = ["Jürgen Fuhrmann "] -version = "2.4" +version = "2.5" [deps] ChunkSplitters = "ae650224-84b6-46f8-82ea-d812ca08434e" diff --git a/examples/ExamplePluto2.jl b/examples/ExamplePluto2.jl new file mode 100644 index 0000000..91fd947 --- /dev/null +++ b/examples/ExamplePluto2.jl @@ -0,0 +1,45 @@ +### A Pluto.jl notebook ### +# v0.20.21 + +using Markdown +using InteractiveUtils + +# ╔═╡ b285aca3-dee5-4b77-9276-537563e8643b +begin + using Pkg + Pkg.activate(joinpath(@__DIR__, "..")) + # using Revise + using Test + using ExampleJuggler +end; + +# ╔═╡ 200a864a-d50e-45fa-915a-283c71ce8686 +md""" +# Graphics example +""" + +# ╔═╡ 50e60295-2bb6-4aea-aea7-e600dad18bbd +x, fx = mock_x() + +# ╔═╡ 51a7525b-8afd-46cd-8334-f6acd3062bf6 +y, t, fyt = mock_xt() + +# ╔═╡ dd736474-3cbf-4b09-8dbb-0ab16fce6c5e +function runtests() + # hideall + @test isapprox(maximum(fyt), 1.0; rtol = 1.0e-3) + @test splitpath(pwd())[end]=="examples" + @test isapprox(maximum(fx), 1.0; rtol = 1.0e-3) + return +end; + +# ╔═╡ e87fd871-04be-4dbc-b933-3daeb11002b9 +runtests() + +# ╔═╡ Cell order: +# ╟─200a864a-d50e-45fa-915a-283c71ce8686 +# ╠═b285aca3-dee5-4b77-9276-537563e8643b +# ╠═50e60295-2bb6-4aea-aea7-e600dad18bbd +# ╠═51a7525b-8afd-46cd-8334-f6acd3062bf6 +# ╠═dd736474-3cbf-4b09-8dbb-0ab16fce6c5e +# ╠═e87fd871-04be-4dbc-b933-3daeb11002b9 diff --git a/src/scripts.jl b/src/scripts.jl index 3925f14..1ed2f38 100644 --- a/src/scripts.jl +++ b/src/scripts.jl @@ -11,9 +11,11 @@ macro testscript(source, kwargs...) :( ExampleJuggler.verbose() && @info "Testing " * basename($(source)); try - mod = eval(ExampleJuggler.parsescript($(source))) - if Base.invokelatest(isdefined, mod, :runtests) - Base.invokelatest(Base.invokelatest(getproperty, mod, :runtests); $(kwargs...)) + cd(dirname($source)) do + mod = eval(ExampleJuggler.parsescript($(source))) + if Base.invokelatest(isdefined, mod, :runtests) + Base.invokelatest(Base.invokelatest(getproperty, mod, :runtests); $(kwargs...)) + end end catch err @error "Error in $(source): $(err)" diff --git a/test/runtests.jl b/test/runtests.jl index 1ac2a5d..41e0d9d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,6 +1,6 @@ using Test, Aqua using ExampleJuggler - +import Pluto if isdefined(Docs, :undocumented_names) # >=1.11 @testset "undocumented names" begin @@ -25,14 +25,12 @@ ExampleJuggler.verbose!(true) example_dir = joinpath(@__DIR__, "..", "examples") modules = ["ExampleModule.jl"] -notebooks = ["PlutoTemplate.jl", "ExamplePluto.jl"] +notebooks = ["PlutoTemplate.jl", "ExamplePluto.jl", "ExamplePluto2.jl"] scripts = ["ExampleScript.jl"] -# This kind of test needs `import Pluto` -# and has been temporarily disabled due to lacking support on Julia nightly -# @testset "pluto notebooks" begin -# @testplutonotebooks(example_dir, notebooks) -# end +@testset "pluto notebooks" begin + @testplutonotebooks(example_dir, notebooks) +end # This kind of test works without Pluto @testset "notebooks as scripts" begin From 763f927195138123484b4861133149fadbf05a97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Fuhrmann?= Date: Thu, 8 Jan 2026 21:10:41 +0100 Subject: [PATCH 2/6] remove test on macos13 --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86a160c..d0eaf21 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,6 @@ jobs: os: - ubuntu-latest - windows-latest - - macOS-13 # intel - macOS-14 # arm arch: - x64 @@ -31,8 +30,6 @@ jobs: arch: aarch64 - os: windows-latest arch: aarch64 - - os: macOS-13 - arch: aarch64 - os: macOS-14 arch: x64 steps: From 86694192726d0d0f30d0789ebfe2ee4e71c52584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Fuhrmann?= Date: Thu, 8 Jan 2026 21:16:13 +0100 Subject: [PATCH 3/6] JuliaFormatter -> runic --- .JuliaFormatter.toml | 7 ----- .github/workflows/format_check.yml | 45 ------------------------------ .github/workflows/pre-commit.yml | 22 +++++++++++++++ examples/ExamplePluto2.jl | 6 ++-- 4 files changed, 25 insertions(+), 55 deletions(-) delete mode 100644 .JuliaFormatter.toml delete mode 100644 .github/workflows/format_check.yml create mode 100644 .github/workflows/pre-commit.yml diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml deleted file mode 100644 index 5d28f1b..0000000 --- a/.JuliaFormatter.toml +++ /dev/null @@ -1,7 +0,0 @@ -style = "sciml" -pipe_to_function_call=false -always_for_in = false -separate_kwargs_with_semicolon = true -margin = 132 -yas_style_nesting=true -ignore = "examples/PlutoGridFactory.jl" \ No newline at end of file diff --git a/.github/workflows/format_check.yml b/.github/workflows/format_check.yml deleted file mode 100644 index 3b1e618..0000000 --- a/.github/workflows/format_check.yml +++ /dev/null @@ -1,45 +0,0 @@ - -name: format-check - -on: - push: - branches: - - 'master' - - 'release-' - tags: '*' - pull_request: - -jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - julia-version: [1.3.0] - julia-arch: [x86] - os: [ubuntu-latest] - steps: - - uses: julia-actions/setup-julia@latest - with: - version: ${{ matrix.julia-version }} - - - uses: actions/checkout@v1 - - name: Install JuliaFormatter and format - # This will use the latest version by default but you can set the version like so: - # - # julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))' - run: | - julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))' - julia -e 'using JuliaFormatter; format(".", verbose=true)' - - name: Format check - run: | - julia -e ' - out = Cmd(`git diff --name-only`) |> read |> String - if out == "" - exit(0) - else - @error "Some files have not been formatted !!!" - write(stdout, out) - exit(1) - end' - - diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..20c6046 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,22 @@ +name: code quality checks + +on: + pull_request: + +jobs: + pre-commit: + name: run pre-commit + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: julia-actions/setup-julia@v2 + with: + version: 1 + - run: | + julia --project=@runic -e ' + using Pkg + Pkg.add("Runic")' + env: + PYTHON: "" + - uses: actions/setup-python@v6 + - uses: pre-commit/action@v3.0.1 diff --git a/examples/ExamplePluto2.jl b/examples/ExamplePluto2.jl index 91fd947..b2685ea 100644 --- a/examples/ExamplePluto2.jl +++ b/examples/ExamplePluto2.jl @@ -6,7 +6,7 @@ using InteractiveUtils # ╔═╡ b285aca3-dee5-4b77-9276-537563e8643b begin - using Pkg + using Pkg Pkg.activate(joinpath(@__DIR__, "..")) # using Revise using Test @@ -28,9 +28,9 @@ y, t, fyt = mock_xt() function runtests() # hideall @test isapprox(maximum(fyt), 1.0; rtol = 1.0e-3) - @test splitpath(pwd())[end]=="examples" + @test splitpath(pwd())[end] == "examples" @test isapprox(maximum(fx), 1.0; rtol = 1.0e-3) - return + return end; # ╔═╡ e87fd871-04be-4dbc-b933-3daeb11002b9 From 0bdcba0203c27ffc08026d7d3849b0a44796ad29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Fuhrmann?= Date: Thu, 8 Jan 2026 21:24:04 +0100 Subject: [PATCH 4/6] add precommit config --- .pre-commit-config.yaml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100755 index 0000000..2d40ab6 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-added-large-files + args: [--maxkb=8192] + - id: check-merge-conflict + - id: check-toml + - id: check-yaml + args: [--allow-multiple-documents] + - id: end-of-file-fixer + - id: no-commit-to-branch + args: [--branch,master] +- repo: https://github.com/gitleaks/gitleaks + rev: v8.24.2 + hooks: + - id: gitleaks +- repo: https://github.com/fredrikekre/runic-pre-commit + rev: v1.0.0 + hooks: + - id: runic +- repo: https://github.com/codespell-project/codespell + rev: v2.4.1 + hooks: + - id: codespell From 872570eab319dd4b218e8fab4c767ee5e56f92cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Fuhrmann?= Date: Thu, 8 Jan 2026 21:43:44 +0100 Subject: [PATCH 5/6] fix codespell complaints --- .github/workflows/ci.yml | 1 - CHANGELOG.md | 5 ++++- README.md | 1 - docs/src/api.md | 2 +- docs/src/index.md | 3 --- src/modules.jl | 2 +- src/plutoext.jl | 8 ++++---- src/scripts.jl | 2 +- 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0eaf21..b4c006e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,4 +74,3 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} - \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 2054ab3..86cd419 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## [2.5.0] - 2026-01-08 +- run script tests in the directory where script is located +- runic format and other checks + ## [2.4.0] - 2025-10-31 - Improve error output for script testing - get rid of Base.get_extension @@ -48,4 +52,3 @@ All notable changes to this project will be documented in this file. - Use distributed for static html generation from notebooks - Add `use_module_titles` flag for @docmodules - Set version to 1.0.0 for full SemVer - diff --git a/README.md b/README.md index eccc9fa..fd7af53 100644 --- a/README.md +++ b/README.md @@ -92,4 +92,3 @@ deploydocs(; repo = "github.com/j-fu/ExampleJuggler.jl.git", devbranch = "main") end ``` In particular, graphics generation for module and script examples is supported. - diff --git a/docs/src/api.md b/docs/src/api.md index b0ae72c..c497009 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -1,6 +1,6 @@ # API !!! tip - All additonal packages used in tests or docs need to be recorded in + All additional packages used in tests or docs need to be recorded in `tests/Project.toml` resp. `docs/Project.toml`, preferably with a [compat] entry. diff --git a/docs/src/index.md b/docs/src/index.md index 20f0c69..231640b 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -4,6 +4,3 @@ ExampleJuggler ```@contents Depth=5 ``` - - - diff --git a/src/modules.jl b/src/modules.jl index b8de98d..dbecfa6 100644 --- a/src/modules.jl +++ b/src/modules.jl @@ -130,7 +130,7 @@ for use with documenter from list of Julia modules. Wrapper macro for [`docmodules`](@ref) and [`ExampleJuggler.@plotmodules`](@ref). Parameters: -- `example_dir`: subdirectory where the files coresponding to the modules reside. +- `example_dir`: subdirectory where the files corresponding to the modules reside. - `modules`: Vector of file names or pairs `"title" => "filename"` as in [Documenter.jl](https://documenter.juliadocs.org/stable/man/guide/#Pages-in-the-Sidebar). diff --git a/src/plutoext.jl b/src/plutoext.jl index 5d616fd..96a1ae8 100644 --- a/src/plutoext.jl +++ b/src/plutoext.jl @@ -44,7 +44,7 @@ Keyword arguments: - `ntasks`: number of parallel tasks. - `source_prefix`: Prefix of notebook source file on github. - `iframe_height`: Height of iframe. -- `force`: force ovewriting of already rendered notebooks. +- `force`: force overwriting of already rendered notebooks. Returns: Vector of markdown file names (one for each notebook) ready to be passed to `makedocs`. @@ -109,7 +109,7 @@ end @testplutonotebooks(example_dir,notebooks, kwargs...) Macro wrapper for [`testplutonotebooks`](@ref). -Just for aestethic reasons, as other parts of the API have to be macros. +Just for aesthetic reasons, as other parts of the API have to be macros. """ macro testplutonotebooks(example_dir, notebooks, kwargs...) return esc(:(ExampleJuggler.testplutonotebooks($example_dir, $notebooks; $(kwargs...)))) @@ -133,7 +133,7 @@ Keyword arguments: html export. For documenter, a markdown page is created which contains statements to show the notebook html in an iframe. The advantage of this method is that active javascript content is shown. The disadvantage is weak integration into documenter. Prerequisite is `import PlutoSliderServer` in `docs/make.jl`. - - If false, Documenter markdown files are ceated via [PlutoStaticHTML.jl](https://github.com/rikhuijzer/PlutoStaticHTML.jl). These integrate well with + - If false, Documenter markdown files are created via [PlutoStaticHTML.jl](https://github.com/rikhuijzer/PlutoStaticHTML.jl). These integrate well with Documenter, but are (as of now) unable to show active javascript content. Graphics is best prepared with CairoMakie. Prerequisite is `import PlutoStaticHTML` in `docs/make.jl`. - `distributed`: Use parallel evaluation @@ -174,7 +174,7 @@ end @docplutonotebooks(example_dir, notebooklist, kwargs...) Macro wrapper for [`docplutonotebooks`](@ref). -Just for aestethic reasons, as other parts of the API have to be macros. +Just for aesthetic reasons, as other parts of the API have to be macros. """ macro docplutonotebooks(example_dir, notebooklist, kwargs...) return esc(:(docplutonotebooks($example_dir, $notebooklist; $(kwargs...)))) diff --git a/src/scripts.jl b/src/scripts.jl index 1ed2f38..1d7b36d 100644 --- a/src/scripts.jl +++ b/src/scripts.jl @@ -107,7 +107,7 @@ Generate markdown files and plots (via the respective `generateplots` methods) Parameters: -- `example_dir`: subdirectory where the files coresponding to the modules reside. +- `example_dir`: subdirectory where the files corresponding to the modules reside. - `scripts`: Vector of file names or pairs `"title" => "filename"` as in [Documenter.jl](https://documenter.juliadocs.org/stable/man/guide/#Pages-in-the-Sidebar). From 8347037f56f15eb676cb18d4ded4274d3408b560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Fuhrmann?= Date: Thu, 8 Jan 2026 21:48:52 +0100 Subject: [PATCH 6/6] fix codespell complaints --- docs/src/api.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/src/api.md b/docs/src/api.md index c497009..a465755 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -21,4 +21,3 @@ ExampleJuggler.verbose! testplutonotebooks @testplutonotebooks ``` -