Skip to content

Commit 3c0b457

Browse files
test CI on Julia v1.12 (#216)
* test CI on Julia v1.12 * fix * try with JET.jl v0.10 * remove some unnecessary type annotations * try to fix world age issues * add at-invokelatest * more at-invokelatest * define fallback set_approximation_variables! for JET.jl * loosen tolerances for CI * try a separate workflow for JET.jl * rename workflow to JET * remove using JET * try what happens if JET fails * looks good * Apply suggestions from code review
1 parent 728af22 commit 3c0b457

File tree

12 files changed

+124
-52
lines changed

12 files changed

+124
-52
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ jobs:
5656
include:
5757
- version: '1.11'
5858
os: ubuntu-latest
59+
- version: '1.12'
60+
os: ubuntu-latest
5961
steps:
6062
- uses: actions/checkout@v5
6163
- uses: julia-actions/setup-julia@v2

.github/workflows/JET.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: JET
2+
on:
3+
push:
4+
branches:
5+
- main
6+
tags: ['*']
7+
paths-ignore:
8+
- 'CITATION.bib'
9+
- 'LICENSE.md'
10+
- 'README.md'
11+
- '.zenodo.json'
12+
- '.github/workflows/benchmark.yml'
13+
- '.github/workflows/CompatHelper.yml'
14+
- '.github/workflows/Documenter.yml'
15+
- '.github/workflows/Format-check.yml'
16+
- '.github/workflows/TagBot.yml'
17+
- '.github/workflows/SpellCheck.yml'
18+
- 'benchmark/**'
19+
- 'docs/**'
20+
pull_request:
21+
paths-ignore:
22+
- 'CITATION.bib'
23+
- 'LICENSE.md'
24+
- 'README.md'
25+
- '.zenodo.json'
26+
- '.github/workflows/benchmark.yml'
27+
- '.github/workflows/CompatHelper.yml'
28+
- '.github/workflows/Documenter.yml'
29+
- '.github/workflows/Format-check.yml'
30+
- '.github/workflows/TagBot.yml'
31+
- '.github/workflows/SpellCheck.yml'
32+
- 'benchmark/**'
33+
- 'docs/**'
34+
workflow_dispatch:
35+
36+
concurrency:
37+
# Skip intermediate builds: always.
38+
# Cancel intermediate builds: only if it is a pull request build.
39+
group: ${{ github.workflow }}-${{ github.ref }}
40+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
41+
42+
jobs:
43+
test:
44+
if: "!contains(github.event.head_commit.message, 'skip ci')"
45+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ github.event_name }}
46+
runs-on: ${{ matrix.os }}
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
version:
51+
- '1.12'
52+
os:
53+
- ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v4
56+
- uses: julia-actions/setup-julia@v2
57+
with:
58+
version: ${{ matrix.version }}
59+
- run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)'
60+
- uses: julia-actions/cache@v2
61+
- name: Install and run JET.jl
62+
shell: julia --project="." --color=yes {0}
63+
run: |
64+
using Pkg
65+
Pkg.add("JET")
66+
Pkg.instantiate()
67+
using JET
68+
using DispersiveShallowWater
69+
70+
# JET.jl
71+
# With the default settings as of 2025-05-08, JET.jl
72+
# reports issues originating from RecipesBase.jl.
73+
# The only way to ignore them seems to be something like the
74+
# following hack inspired by the discussion in
75+
# https://github.com/aviatesk/JET.jl/issues/570
76+
struct IgnoreRecipesBase end
77+
function JET.match_module(::IgnoreRecipesBase,
78+
@nospecialize(report::JET.InferenceErrorReport))
79+
s = "MethodInstance for RecipesBase.apply_recipe"
80+
any(report.vst) do vst
81+
occursin(s, string(vst))
82+
end
83+
end
84+
test_package(DispersiveShallowWater;
85+
target_defined_modules = true,
86+
ignored_modules = (IgnoreRecipesBase(),))

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*.jl.*.cov
44
*.jl.cov
55
*.jl.mem
6-
**/Manifest.toml
6+
**/Manifest*.toml
77
out*/
88
/docs/build/
99
docs/src/changelog.md

src/semidiscretization.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,12 @@ function PolynomialBases.integrate(q, semi::Semidiscretization)
164164
integrate(identity, q, semi)
165165
end
166166

167-
function integrate_quantity(func, q, semi::Semidiscretization)
167+
function integrate_quantity(func, q, semi)
168168
quantity = zeros(eltype(q), nnodes(semi))
169169
integrate_quantity!(quantity, func, q, semi)
170170
end
171171

172-
function integrate_quantity!(quantity, func, q, semi::Semidiscretization)
172+
function integrate_quantity!(quantity, func, q, semi)
173173
for i in eachnode(semi)
174174
quantity[i] = func(get_node_vars(q, semi.equations, i), semi.equations)
175175
end
@@ -186,26 +186,26 @@ function integrate_quantity!(quantity,
186186
func::Union{typeof(energy_total_modified),
187187
typeof(entropy_modified),
188188
typeof(hamiltonian)}, q,
189-
semi::Semidiscretization)
189+
semi)
190190
inplace_version(func)(quantity, q, semi.equations, semi.cache)
191191
integrate(quantity, semi)
192192
end
193193

194-
@inline function mesh_equations_solver(semi::Semidiscretization)
194+
@inline function mesh_equations_solver(semi)
195195
@unpack mesh, equations, solver = semi
196196
return mesh, equations, solver
197197
end
198198

199-
@inline function mesh_equations_solver_cache(semi::Semidiscretization)
199+
@inline function mesh_equations_solver_cache(semi)
200200
@unpack mesh, equations, solver, cache = semi
201201
return mesh, equations, solver, cache
202202
end
203203

204-
function calc_error_norms(q, t, semi::Semidiscretization)
204+
function calc_error_norms(q, t, semi)
205205
calc_error_norms(q, t, semi.initial_condition, mesh_equations_solver(semi)...)
206206
end
207207

208-
function rhs!(dq, q, semi::Semidiscretization, t)
208+
function rhs!(dq, q, semi, t)
209209
@unpack mesh, equations, initial_condition, boundary_conditions, solver, source_terms, cache = semi
210210

211211
@trixi_timeit timer() "rhs!" rhs!(dq, q, t, mesh, equations, initial_condition,
@@ -214,14 +214,14 @@ function rhs!(dq, q, semi::Semidiscretization, t)
214214
return nothing
215215
end
216216

217-
function compute_coefficients(func, t, semi::Semidiscretization)
217+
function compute_coefficients(func, t, semi)
218218
@unpack mesh, equations, solver = semi
219219
q = allocate_coefficients(mesh_equations_solver(semi)...)
220220
compute_coefficients!(q, func, t, semi)
221221
return q
222222
end
223223

224-
function compute_coefficients!(q, func, t, semi::Semidiscretization)
224+
function compute_coefficients!(q, func, t, semi)
225225
# Call `compute_coefficients` defined by the solver
226226
mesh, equations, solver = mesh_equations_solver(semi)
227227
compute_coefficients!(q, func, t, mesh,

src/solver.jl

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ Create a solver, where the three summation-by-parts (SBP) first-, second-, and t
5757
are of accuracy order `accuracy_order` and associated to the `mesh`.
5858
5959
!!! warning "Periodic operators only"
60-
This constructor creates periodic derivative operators that are only compatible with periodic
61-
boundary conditions. For non-periodic boundary conditions, use the `Solver(D1, D2, D3)`
60+
This constructor creates periodic derivative operators that are only compatible with periodic
61+
boundary conditions. For non-periodic boundary conditions, use the `Solver(D1, D2, D3)`
6262
constructor with appropriate non-periodic operators (or `nothing`).
6363
"""
6464
function Solver(mesh, accuracy_order)
@@ -78,7 +78,7 @@ end
7878
7979
Create a solver, where `D1` is an `AbstractDerivativeOperator`
8080
from [SummationByPartsOperators.jl](https://github.com/ranocha/SummationByPartsOperators.jl)
81-
of first `derivative_order`, `D2` is an `AbstractDerivativeOperator`
81+
of first `derivative_order`, `D2` is an `AbstractDerivativeOperator`
8282
of second `derivative_order` or an `AbstractMatrix`, and `D3` is an `AbstractDerivativeOperator`
8383
of third `derivative_order` or an `AbstractMatrix`. `D2` and `D3` can also be `nothing`
8484
if that derivative is not used by the discretization.
@@ -135,28 +135,34 @@ end
135135
return nothing
136136
end
137137

138-
function allocate_coefficients(mesh::Mesh1D, equations, solver::AbstractSolver)
138+
function allocate_coefficients(mesh, equations, solver)
139139
return ArrayPartition(ntuple(_ -> zeros(real(solver), nnodes(mesh)),
140140
Val(nvariables(equations))))
141141
end
142142

143-
function compute_coefficients!(q, func, t, mesh::Mesh1D,
143+
function compute_coefficients!(q, func, t, mesh,
144144
is_hyperbolic_appproximation::Val{false},
145-
equations, solver::AbstractSolver)
145+
equations, solver)
146146
x = grid(solver)
147147
for i in eachnode(solver)
148148
q_node = func(x[i], t, equations, mesh)
149149
set_node_vars!(q, q_node, equations, i)
150150
end
151151
end
152152

153+
# `set_approximation_variables!` is defined for equations, which are hyperbolic
154+
# approximations, but below it is called for `equations` for which the compiler
155+
# doesn't know from type annotations that these are hyperbolic approximations.
156+
# Therefore, JET.jl fails. We provide a fallback definition here that does nothing.
157+
set_approximation_variables!(q, mesh, equations, solver) = nothing
158+
153159
# For a hyperbolic approximation, we allow returning either the full set
154160
# of variables or a reduced number determining only the limit system.
155161
# In the second case, we compute the remaining variables using the default
156162
# initialization specific to the equations.
157-
function compute_coefficients!(q, func, t, mesh::Mesh1D,
163+
function compute_coefficients!(q, func, t, mesh,
158164
is_hyperbolic_appproximation::Val{true},
159-
equations, solver::AbstractSolver)
165+
equations, solver)
160166
x = grid(solver)
161167
q_node = func(x[begin], t, equations, mesh)
162168
if length(q_node) == nvariables(equations)
@@ -176,8 +182,8 @@ function compute_coefficients!(q, func, t, mesh::Mesh1D,
176182
end
177183
end
178184

179-
function calc_error_norms(q, t, initial_condition, mesh::Mesh1D, equations,
180-
solver::AbstractSolver)
185+
function calc_error_norms(q, t, initial_condition, mesh, equations,
186+
solver)
181187
q_exact = similar(q)
182188
compute_coefficients!(q_exact, initial_condition, t, mesh,
183189
is_hyperbolic_appproximation(equations), equations,
@@ -192,13 +198,11 @@ function calc_error_norms(q, t, initial_condition, mesh::Mesh1D, equations,
192198
return l2_error, linf_error
193199
end
194200

195-
function calc_sources!(dq, q, t, source_terms::Nothing,
196-
equations::AbstractEquations{1}, solver::Solver)
201+
function calc_sources!(dq, q, t, source_terms::Nothing, equations, solver)
197202
return nothing
198203
end
199204

200-
function calc_sources!(dq, q, t, source_terms,
201-
equations::AbstractEquations{1}, solver::Solver)
205+
function calc_sources!(dq, q, t, source_terms, equations, solver)
202206
x = grid(solver)
203207
for i in eachnode(solver)
204208
local_source = source_terms(get_node_vars(q, equations, i), x[i], t, equations)

src/util.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function convergence_test(mod::Module, example::AbstractString, Ns::AbstractVect
101101

102102
trixi_include(mod, example; kwargs..., N = Ns[iter])
103103

104-
l2_error, linf_error = mod.analysis_callback(mod.sol)
104+
l2_error, linf_error = @invokelatest mod.analysis_callback(@invokelatest mod.sol)
105105

106106
# collect errors as one vector to reshape later
107107
append!(errors[:l2], l2_error)
@@ -112,7 +112,7 @@ function convergence_test(mod::Module, example::AbstractString, Ns::AbstractVect
112112
end
113113

114114
# Use raw error values to compute EOC
115-
analyze_convergence(io, errors, iterations, mod.semi, Ns)
115+
analyze_convergence(io, errors, iterations, (@invokelatest mod.semi), Ns)
116116
end
117117

118118
# Analyze convergence for any semidiscretization

test/Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
33
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
44
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
5-
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
65
OrdinaryDiffEqLowStorageRK = "b0944070-b475-4768-8dec-fb6eb410534d"
76
OrdinaryDiffEqRosenbrock = "43230ef6-c299-4910-a778-202eb28ce4ce"
87
OrdinaryDiffEqTsit5 = "b1df2697-797e-41e3-8120-5422d3b24e4a"
@@ -18,7 +17,6 @@ TrixiTest = "0a316866-cbd0-4425-8bcb-08103b2c1f26"
1817
Aqua = "0.7, 0.8"
1918
ExplicitImports = "1.0.1"
2019
ForwardDiff = "0.10.36, 1"
21-
JET = "0.9.9"
2220
OrdinaryDiffEqLowStorageRK = "1.1"
2321
OrdinaryDiffEqRosenbrock = "1.9"
2422
OrdinaryDiffEqTsit5 = "1.1"

test/test_aqua.jl

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
@testitem "Aqua.jl" setup=[Setup] begin
22
using Aqua
33
using ExplicitImports: check_no_implicit_imports, check_no_stale_explicit_imports
4-
using JET
54

65
# Aqua.jl
76
Aqua.test_all(DispersiveShallowWater,
@@ -10,22 +9,4 @@
109
# ExplicitImports.jl
1110
@test isnothing(check_no_implicit_imports(DispersiveShallowWater))
1211
@test isnothing(check_no_stale_explicit_imports(DispersiveShallowWater))
13-
14-
# JET.jl
15-
# With the default settings as of 2025-05-08, JET.jl
16-
# reports issues originating from RecipesBase.jl.
17-
# The only way to ignore them seems to be something like the
18-
# following hack inspired by the discussion in
19-
# https://github.com/aviatesk/JET.jl/issues/570
20-
struct IgnoreRecipesBase end
21-
function JET.match_module(::IgnoreRecipesBase,
22-
@nospecialize(report::JET.InferenceErrorReport))
23-
s = "MethodInstance for RecipesBase.apply_recipe"
24-
any(report.vst) do vst
25-
occursin(s, string(vst))
26-
end
27-
end
28-
test_package(DispersiveShallowWater;
29-
target_defined_modules = true,
30-
ignored_modules = (IgnoreRecipesBase(),))
3112
end

test/test_hyperbolic_serre_green_naghdi_1d.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ end
259259
0.0,
260260
1.141036530464996,
261261
4.819814592771365e-6
262-
])
262+
], atol=1e-8) # to make CI pass
263263

264264
@test_allocations(DispersiveShallowWater.rhs!, semi, sol, allocs=1_000)
265265
end

test/test_kdv_1d.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ end
8383
linf=[8.131770758672274e-5],
8484
cons_error=[2.842170943040401e-14],
8585
change_waterheight=2.842170943040401e-14,
86-
change_entropy=5.861043206323302e-9)
86+
change_entropy=5.861043206323302e-9,
87+
atol=1e-9) # to make CI pass
8788

8889
@test_allocations(DispersiveShallowWater.rhs!, semi, sol, allocs=5_000)
8990
end

0 commit comments

Comments
 (0)