Skip to content

Commit

Permalink
Make it easier to review Julia manifest updates (#2069)
Browse files Browse the repository at this point in the history
This should put the output of `] update` and `status --outdated` in the
PR body, so we can easily see what changed and what is stuck.

Without this it looks like #1990.
With this it looks like
[#2070](#2070).
  • Loading branch information
visr authored Feb 14, 2025
1 parent 0d3de2c commit 4eb952a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/julia_auto_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ jobs:
run: |
pixi run install-julia
pixi run update-manifest-julia
env:
JULIA_PKG_PRECOMPILE_AUTO: "0"
- uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.CI_PR_PAT }}
branch: update/julia-manifest
title: Update Julia manifest
commit-message: "Update Julia manifest"
body: Update Julia dependencies to the latest version.
body-path: .pixi/update-manifest-julia.md
author: "GitHub <noreply@github.com>"
2 changes: 1 addition & 1 deletion pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ install = { depends-on = [
# Julia
# Clear SSL_CERT_DIR to avoid Julia warnings, see https://github.com/JuliaLang/Downloads.jl/issues/244
update-registry-julia = { cmd = "julia --eval='using Pkg; Registry.update()'", env = { SSL_CERT_DIR = "" } }
update-manifest-julia = { cmd = "julia --project --eval='using Pkg; Pkg.update()'", env = { SSL_CERT_DIR = "" } }
update-manifest-julia = { cmd = "julia --project utils/update-manifest.jl", env = { SSL_CERT_DIR = "", JULIA_SSL_CA_ROOTS_PATH = "" } }
instantiate-julia = { cmd = "julia --project --eval='using Pkg; Pkg.instantiate()'", env = { SSL_CERT_DIR = "", JULIA_SSL_CA_ROOTS_PATH = "" } }
initialize-julia = { depends-on = [
"update-registry-julia",
Expand Down
47 changes: 47 additions & 0 deletions utils/update-manifest.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import Pkg

const IS_INSTALLED = r"\s*Installed (.+)"
const DETAILS_BEGIN = """
<details>
<summary>
All package versions
</summary>
```
"""

"""
Update the Julia Manifest.toml and show the changes as well as outdated packages.
The output is written to a file that can be used as the body of a pull request.
"""
function (@main)(_)
path = normpath(@__DIR__, "../.pixi/update-manifest-julia.md")
redirect_stdio(; stdout = path, stderr = path) do
println("Update the Julia Manifest.toml to get the latest dependencies.\n")
println("__Changed packages__\n```")
Pkg.update()
println("```\n\n__Packages still outdated after update__\n```")
Pkg.status(; outdated = true)
println("```")
end

# The Pkg.update output first prints all installed package versions.
# This is a lot, strip it out, sort it, and put it in a details tag at the end.
installed_lines = String[]
lines = readlines(path)
open(path, "w") do io
for line in lines
m = match(IS_INSTALLED, line)
if m === nothing
println(io, line)
else
push!(installed_lines, only(m.captures))
end
end

println(io, DETAILS_BEGIN)
sort!(installed_lines)
foreach(line -> println(io, line), installed_lines)
println("```\n\n</details>")
end
end

0 comments on commit 4eb952a

Please sign in to comment.