Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/NotebookDifference.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Compare notebook files
on:
# workflow_dispatch:
# push:
# paths-ignore:
# - "**.md"
# branches:
# - main
pull_request:
paths-ignore:
- "**.md"

jobs:
notebook-changes-check:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
path: source


- name: Checkout
uses: actions/checkout@v4
with:
ref: dist
path: gh_pages_dir


- name: Install Julia
uses: julia-actions/setup-julia@v2
with:
# note: this version should match the version in the other actions in this repo
version: "1.11"

- name: Cache Julia artifacts & such
uses: julia-actions/cache@v2
with:
cache-registries: "true"

# We set up a folder that Pluto can use to cache exported notebooks. If the notebook file did not change, then Pluto can take the exported file from cache instead of running the notebook.
- name: Set up notebook state cache
uses: actions/cache@v4
with:
path: pluto_state_cache
# use the same key as the export action on the main branch:
key: ${{ runner.os }}-pluto_state_cache-v3-${{ hashFiles('**/Project.toml', '**/Manifest.toml') }}-${{ github.run_id }}
# here, you want to use the same restore key, but without the Project/Manifest hash:
restore-keys: |
${{ runner.os }}-pluto_state_cache-v3

- name: Compare notebooks in PR
run: |
julia --threads=auto source/tools/diff.jl

10 changes: 9 additions & 1 deletion pluto-deployment-environment/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.11.3"
manifest_format = "2.0"
project_hash = "13a51ad2b377d764861ea553e631182e0e81a599"
project_hash = "9854db52c26347aaaf320fc7b5e3c74d874b1bb3"

[[deps.AbstractPlutoDingetjes]]
deps = ["Pkg"]
Expand Down Expand Up @@ -354,6 +354,14 @@ git-tree-sha1 = "9071bfe6d1c3c51f62918513e8dfa0705fbdef7e"
uuid = "72656b73-756c-7461-726b-72656b6b696b"
version = "1.2.1"

[[deps.PlutoNotebookComparison]]
deps = ["Compat", "ExpressionExplorer", "HTTP", "InteractiveUtils", "LibGit2", "Logging", "LoggingExtras", "Markdown", "Pkg", "Pluto", "PlutoSliderServer", "TOML", "URIs"]
git-tree-sha1 = "ad309f681e6f3812d943933ef736267911ebccc3"
repo-rev = "main"
repo-url = "https://github.com/JuliaPluto/PlutoNotebookComparison.jl"
uuid = "828d9ff0-206c-6161-646e-6576656f7242"
version = "1.0.0"

[[deps.PlutoSliderServer]]
deps = ["AbstractPlutoDingetjes", "Base64", "BetterFileWatching", "Configurations", "Distributed", "FromFile", "Git", "Glob", "HTTP", "JSON", "Logging", "Pkg", "Pluto", "PlutoDependencyExplorer", "SHA", "Serialization", "Sockets", "TOML", "TerminalLoggers", "UUIDs"]
git-tree-sha1 = "9e1a630079de12343df2ccf9a90c46177bd38780"
Expand Down
1 change: 1 addition & 0 deletions pluto-deployment-environment/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[deps]
Pluto = "c3e4b0f8-55cb-11ea-2926-15256bba5781"
PlutoNotebookComparison = "828d9ff0-206c-6161-646e-6576656f7242"
PlutoSliderServer = "2fc8631c-6f24-4c5b-bca7-cbb509c42db4"
57 changes: 57 additions & 0 deletions tools/diff.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
source = joinpath(@__DIR__, "..")


function tryexpanduser(path)
try
expanduser(path)
catch ex
path
end
end

tamepath = abspath ∘ tryexpanduser

pluto_state_cache = tamepath("pluto_state_cache")
gh_pages_dir = tamepath("gh_pages_dir")

if !isdir(pluto_state_cache) || readdir(pluto_state_cache) == []
@warn "Running this script without a GitHub Actions PlutoSliderServer cache. Using a local cache in the temp dir."
pluto_state_cache = joinpath(tempdir(), "bmlip cache")
end

cd(source)

using Pkg
Pkg.activate(joinpath(source, "pluto-deployment-environment"))
Pkg.instantiate()

using PlutoNotebookComparison


sources_old = [
PSSCache(pluto_state_cache)
WebsiteDir(gh_pages_dir)
WebsiteAddress("https://featured.plutojl.org/")
SafePreview()
]

sources_new = [
PSSCache(pluto_state_cache)
RunWithPlutoSliderServer(; Export_cache_dir=pluto_state_cache)
]

drama_checkers = [
DramaRestartRequired()
DramaNewError()
DramaBrokenImport()
]

PlutoNotebookComparison.compare_PR(source;
sources_old,
sources_new,
drama_checkers,
)




4 changes: 2 additions & 2 deletions tools/update_notebook_packages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ all_notebooks = filter(Pluto.is_pluto_notebook, all_files_recursive)

level = getfield(Pkg, Symbol("UPLEVEL_$(ARGS[1])"))

for n in all_notebooks
@info "Updating" n
for (i,n) in enumerate(all_notebooks)
@info "Updating [$i/$(length(all_notebooks))] $n"
Pluto.update_notebook_environment(n; backup=false, level)
end

Expand Down
Loading