Skip to content

Commit 85801be

Browse files
authored
Have CI tests depend on formatter passing (#2451)
1 parent 3462dc1 commit 85801be

21 files changed

+102
-90
lines changed

.github/workflows/FormatCheck.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on:
33
pull_request:
44
branches:
55
- master
6+
- 'release-'
67
paths-ignore:
78
- 'docs/**'
89
push:
@@ -18,7 +19,39 @@ concurrency:
1819
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
1920

2021
jobs:
22+
formatter:
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
matrix:
26+
julia-version: [1]
27+
julia-arch: [x86]
28+
os: [ubuntu-latest]
29+
steps:
30+
- uses: julia-actions/setup-julia@latest
31+
with:
32+
version: ${{ matrix.julia-version }}
33+
34+
- uses: actions/checkout@v4
35+
- name: Install JuliaFormatter and format
36+
# This will use the latest version by default but you can set the version like so:
37+
#
38+
# julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))'
39+
run: |
40+
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
41+
julia -e 'using JuliaFormatter; format(".", verbose=true)'
42+
- name: Format check
43+
run: |
44+
julia -e '
45+
out = Cmd(`git diff`) |> read |> String
46+
if out == ""
47+
exit(0)
48+
else
49+
@error "Some files have not been formatted !!!"
50+
write(stdout, out)
51+
exit(1)
52+
end'
2153
test:
54+
needs: formatter
2255
runs-on: ubuntu-latest
2356
strategy:
2457
fail-fast: false

docs/src/tutorials/bifurcation_diagram_computation.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Let us consider the `BifurcationProblem` from the last section. If we wish to co
5656
```@example Bif1
5757
p_span = (-4.0, 6.0)
5858
opts_br = ContinuationPar(nev = 2,
59-
p_min = p_span[1],
59+
p_min = p_span[1],
6060
p_max = p_span[2])
6161
```
6262

@@ -111,8 +111,7 @@ bprob = BifurcationProblem(osys,
111111
112112
p_span = (-3.0, 3.0)
113113
opts_br = ContinuationPar(nev = 2,
114-
p_max = p_span[2], p_min = p_span[1],
115-
)
114+
p_max = p_span[2], p_min = p_span[1])
116115
117116
bf = bifurcationdiagram(bprob, PALC(), 2, (args...) -> opts_br; bothside = true)
118117
using Plots
@@ -130,21 +129,19 @@ We compute the branch of periodic orbits which is nearby the Hopf Bifurcation. W
130129

131130
```@example Bif2
132131
br_po = continuation(bf.γ, 2, opts_br,
133-
PeriodicOrbitOCollProblem(20, 5);
134-
)
132+
PeriodicOrbitOCollProblem(20, 5);)
135133
136134
plot(bf; putspecialptlegend = false,
137135
markersize = 2,
138136
plotfold = false,
139137
xguide = "μ",
140138
yguide = "x")
141-
plot!(br_po, xguide = "μ", yguide = "x", label = "Maximum of periodic orbit")
139+
plot!(br_po, xguide = "μ", yguide = "x", label = "Maximum of periodic orbit")
142140
```
143141

144142
Let's see how to plot the periodic solution we just computed:
145143

146144
```@example Bif2
147145
sol = get_periodic_orbit(br_po, 10)
148-
plot(sol.t, sol[1,:], yguide = "x", xguide = "time", label = "")
146+
plot(sol.t, sol[1, :], yguide = "x", xguide = "time", label = "")
149147
```
150-

docs/src/tutorials/optimization.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,12 @@ cons = [
7171
@named sys = OptimizationSystem(loss, [x, y], [a, b], constraints = cons)
7272
u0 = [x => 0.14
7373
y => 0.14]
74-
prob = OptimizationProblem(complete(sys), u0, grad = true, hess = true, cons_j = true, cons_h = true)
74+
prob = OptimizationProblem(complete(sys),
75+
u0,
76+
grad = true,
77+
hess = true,
78+
cons_j = true,
79+
cons_h = true)
7580
solve(prob, IPNewton())
7681
```
7782

src/structural_transformation/symbolics_tearing.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,8 @@ function tearing_reassemble(state::TearingState, var_eq_matching;
541541
sys = state.sys
542542
@set! sys.eqs = neweqs
543543
@set! sys.unknowns = Any[v
544-
for (i, v) in enumerate(fullvars)
545-
if diff_to_var[i] === nothing && ispresent(i)]
544+
for (i, v) in enumerate(fullvars)
545+
if diff_to_var[i] === nothing && ispresent(i)]
546546
@set! sys.substitutions = Substitutions(subeqs, deps)
547547

548548
obs_sub = dummy_sub

src/systems/abstractsystem.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,9 @@ function toexpr(sys::AbstractSystem)
921921
name = $name, checks = false)))
922922
end
923923

924-
expr = :(let; $expr; end)
924+
expr = :(let
925+
$expr
926+
end)
925927
Base.remove_linenums!(expr) # keeping the line numbers is never helpful
926928
end
927929

src/systems/connectors.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ function connection2set!(connectionsets, namespace, ss, isouter)
270270
orientation_vars = Symbolics.unwrap.(vec(O.R))
271271
unknown_vars = [unknown_vars; orientation_vars]
272272
end
273-
i != 1 && ((num_unknowns == length(unknown_vars) && all(Base.Fix2(in, sts1), unknown_vars)) ||
273+
i != 1 && ((num_unknowns == length(unknown_vars) &&
274+
all(Base.Fix2(in, sts1), unknown_vars)) ||
274275
connection_error(ss))
275276
io = isouter(s)
276277
for (j, v) in enumerate(unknown_vars)
@@ -410,7 +411,7 @@ end
410411

411412
function generate_connection_equations_and_stream_connections(csets::AbstractVector{
412413
<:ConnectionSet,
413-
})
414+
})
414415
eqs = Equation[]
415416
stream_connections = ConnectionSet[]
416417

@@ -605,7 +606,8 @@ function expand_instream(csets::AbstractVector{<:ConnectionSet}, sys::AbstractSy
605606
vtype = get_connection_type(sv)
606607
vtype === Stream || continue
607608
if n_inners == 1 && n_outers == 1
608-
push!(additional_eqs, unknowns(cset[1].sys.sys, sv) ~ unknowns(cset[2].sys.sys, sv))
609+
push!(additional_eqs,
610+
unknowns(cset[1].sys.sys, sv) ~ unknowns(cset[2].sys.sys, sv))
609611
elseif n_inners == 0 && n_outers == 2
610612
# we don't expand `instream` in this case.
611613
v1 = unknowns(cset[1].sys.sys, sv)
@@ -664,7 +666,8 @@ function expand_instream(csets::AbstractVector{<:ConnectionSet}, sys::AbstractSy
664666
end
665667

666668
function get_current_var(namespace, cele, sv)
667-
unknowns(renamespace(unnamespace(namespace, _getname(cele.sys.namespace)), cele.sys.sys),
669+
unknowns(renamespace(unnamespace(namespace, _getname(cele.sys.namespace)),
670+
cele.sys.sys),
668671
sv)
669672
end
670673

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ function generate_tgrad(sys::AbstractODESystem, dvs = unknowns(sys), ps = parame
101101
end
102102
end
103103

104-
function generate_jacobian(sys::AbstractODESystem, dvs = unknowns(sys), ps = parameters(sys);
104+
function generate_jacobian(sys::AbstractODESystem, dvs = unknowns(sys),
105+
ps = parameters(sys);
105106
simplify = false, sparse = false, kwargs...)
106107
jac = calculate_jacobian(sys; simplify = simplify, sparse = sparse)
107108
pre = get_preprocess_constants(jac)
@@ -139,7 +140,8 @@ function generate_dae_jacobian(sys::AbstractODESystem, dvs = unknowns(sys),
139140
postprocess_fbody = pre, kwargs...)
140141
end
141142

142-
function generate_function(sys::AbstractODESystem, dvs = unknowns(sys), ps = parameters(sys);
143+
function generate_function(sys::AbstractODESystem, dvs = unknowns(sys),
144+
ps = parameters(sys);
143145
implicit_dae = false,
144146
ddvs = implicit_dae ? map(Differential(get_iv(sys)), dvs) :
145147
nothing,
@@ -294,7 +296,8 @@ function DiffEqBase.ODEFunction{false}(sys::AbstractODESystem, args...;
294296
ODEFunction{false, SciMLBase.FullSpecialize}(sys, args...; kwargs...)
295297
end
296298

297-
function DiffEqBase.ODEFunction{iip, specialize}(sys::AbstractODESystem, dvs = unknowns(sys),
299+
function DiffEqBase.ODEFunction{iip, specialize}(sys::AbstractODESystem,
300+
dvs = unknowns(sys),
298301
ps = parameters(sys), u0 = nothing;
299302
version = nothing, tgrad = false,
300303
jac = false, p = nothing,

src/systems/diffeqs/sdesystem.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ function stochastic_integral_transform(sys::SDESystem, correction_factor)
260260
∇σσ′ = simplify.(jac * get_noiseeqs(sys)[:, 1])
261261
for k in 2:m
262262
eqs = vcat([equations(sys)[i].lhs ~ get_noiseeqs(sys)[Int(i +
263-
(k - 1) * dimunknowns)]
263+
(k - 1) *
264+
dimunknowns)]
264265
for i in eachindex(unknowns(sys))]...)
265266
de = ODESystem(eqs, get_iv(sys), unknowns(sys), parameters(sys), name = name,
266267
checks = false)

src/systems/jumps/jumpsystem.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ struct JumpSystem{U <: ArrayPartition} <: AbstractTimeDependentSystem
102102
"""
103103
complete::Bool
104104

105-
function JumpSystem{U}(tag, ap::U, iv, unknowns, ps, var_to_name, observed, name, systems,
105+
function JumpSystem{U}(tag, ap::U, iv, unknowns, ps, var_to_name, observed, name,
106+
systems,
106107
defaults, connector_type, devents,
107108
metadata = nothing, gui_metadata = nothing,
108109
complete = false;
@@ -119,7 +120,9 @@ struct JumpSystem{U <: ArrayPartition} <: AbstractTimeDependentSystem
119120
connector_type, devents, metadata, gui_metadata, complete)
120121
end
121122
end
122-
JumpSystem(tag, ap, iv, states, ps, var_to_name, args...; kwargs...) = JumpSystem{typeof(ap)}(tag, ap, iv, states, ps, var_to_name, args...; kwargs...)
123+
function JumpSystem(tag, ap, iv, states, ps, var_to_name, args...; kwargs...)
124+
JumpSystem{typeof(ap)}(tag, ap, iv, states, ps, var_to_name, args...; kwargs...)
125+
end
123126

124127
function JumpSystem(eqs, iv, unknowns, ps;
125128
observed = Equation[],
@@ -498,7 +501,7 @@ function (ratemap::JumpSysMajParamMapper{
498501
U,
499502
V,
500503
W,
501-
})(params) where {U <: AbstractArray,
504+
})(params) where {U <: AbstractArray,
502505
V <: AbstractArray, W}
503506
updateparams!(ratemap, params)
504507
[convert(W, value(substitute(paramexpr, ratemap.subdict)))

0 commit comments

Comments
 (0)