Skip to content

Commit a0d2f46

Browse files
Merge pull request #2695 from SciML/at/use-reusable-workflows
ci: standardise workflows using SciML's reusable workflows
2 parents 0726a4d + 623f986 commit a0d2f46

File tree

9 files changed

+73
-143
lines changed

9 files changed

+73
-143
lines changed

.github/workflows/FormatCheck.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: "Format Check"
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
tags: '*'
8+
pull_request:
9+
10+
jobs:
11+
format-check:
12+
name: "Format Check"
13+
uses: "SciML/.github/.github/workflows/format-suggestions-on-pr.yml@v1"

.github/workflows/Invalidations.yml

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: Invalidations
1+
name: "Invalidations"
22

33
on:
44
pull_request:
55
paths-ignore:
6-
- 'docs/**'
6+
- 'docs/**'
77

88
concurrency:
99
# Skip intermediate builds: always.
@@ -12,31 +12,6 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15-
evaluate:
16-
# Only run on PRs to the default branch.
17-
# In the PR trigger above branches can be specified only explicitly whereas this check should work for master, main, or any other default branch
18-
if: github.base_ref == github.event.repository.default_branch
19-
runs-on: ubuntu-latest
20-
steps:
21-
- uses: julia-actions/setup-julia@v1
22-
with:
23-
version: '1'
24-
- uses: actions/checkout@v4
25-
- uses: julia-actions/julia-buildpkg@v1
26-
- uses: julia-actions/julia-invalidations@v1
27-
id: invs_pr
28-
29-
- uses: actions/checkout@v4
30-
with:
31-
ref: ${{ github.event.repository.default_branch }}
32-
- uses: julia-actions/julia-buildpkg@v1
33-
- uses: julia-actions/julia-invalidations@v1
34-
id: invs_default
35-
36-
- name: Report invalidation counts
37-
run: |
38-
echo "Invalidations on default branch: ${{ steps.invs_default.outputs.total }} (${{ steps.invs_default.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY
39-
echo "This branch: ${{ steps.invs_pr.outputs.total }} (${{ steps.invs_pr.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY
40-
- name: Check if the PR does increase number of invalidations
41-
if: steps.invs_pr.outputs.total > steps.invs_default.outputs.total
42-
run: exit 1
15+
evaluate-invalidations:
16+
name: "Evaluate Invalidations"
17+
uses: "SciML/.github/.github/workflows/invalidations.yml@v1"

.github/workflows/Tests.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: "Tests"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
- 'release-'
8+
paths-ignore:
9+
- 'docs/**'
10+
push:
11+
branches:
12+
- master
13+
paths-ignore:
14+
- 'docs/**'
15+
16+
concurrency:
17+
# Skip intermediate builds: always, but for the master branch.
18+
# Cancel intermediate builds: always, but for the master branch.
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
21+
22+
jobs:
23+
tests:
24+
name: "Tests"
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
group:
29+
- InterfaceI
30+
- InterfaceII
31+
- Extensions
32+
- Downstream
33+
- RegressionI
34+
uses: "SciML/.github/.github/workflows/tests.yml@v1"
35+
with:
36+
group: "${{ matrix.group }}"
37+
secrets: "inherit"

.github/workflows/ci.yml

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

test/hierarchical_initialization_eqs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,6 @@ syslist = ModelingToolkit.get_systems(model)
142142
u0 = []
143143
prob = ODEProblem(structural_simplify(model), u0, (0.0, 10.0))
144144
sol = solve(prob, Rodas5P())
145-
@test length(sol[end]) == 2
145+
@test length(sol.u[end]) == 2
146146
@test length(equations(prob.f.initializeprob.f.sys)) == 0
147147
@test length(unknowns(prob.f.initializeprob.f.sys)) == 0

test/modelingtoolkitize.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ sys = complete(modelingtoolkitize(prob)) # symbolicitize me captain!
5959

6060
prob = OptimizationProblem(sys, x0, p, grad = true, hess = true)
6161
sol = solve(prob, NelderMead())
62-
@test sol.minimum < 1e-8
62+
@test sol.objective < 1e-8
6363

6464
sol = solve(prob, BFGS())
65-
@test sol.minimum < 1e-8
65+
@test sol.objective < 1e-8
6666

6767
sol = solve(prob, Newton())
68-
@test sol.minimum < 1e-8
68+
@test sol.objective < 1e-8
6969

7070
## SIR System Regression Test
7171

test/optimizationsystem.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ using ModelingToolkit: get_metadata
5050
cons_h = true)
5151
@test prob.f.sys === combinedsys
5252
sol = solve(prob, Ipopt.Optimizer(); print_level = 0)
53-
@test sol.minimum < -1e5
53+
@test sol.objective < -1e5
5454
end
5555

5656
@testset "inequality constraint" begin
@@ -66,14 +66,14 @@ end
6666
grad = true, hess = true, cons_j = true, cons_h = true)
6767
@test prob.f.sys === sys
6868
sol = solve(prob, IPNewton())
69-
@test sol.minimum < 1.0
69+
@test sol.objective < 1.0
7070
sol = solve(prob, Ipopt.Optimizer(); print_level = 0)
71-
@test sol.minimum < 1.0
71+
@test sol.objective < 1.0
7272

7373
prob = OptimizationProblem(sys, [x => 0.0, y => 0.0], [a => 1.0, b => 1.0],
7474
grad = false, hess = false, cons_j = false, cons_h = false)
7575
sol = solve(prob, AmplNLWriter.Optimizer(Ipopt_jll.amplexe))
76-
@test_skip sol.minimum < 1.0
76+
@test_skip sol.objective < 1.0
7777
end
7878

7979
@testset "equality constraint" begin
@@ -88,18 +88,18 @@ end
8888
prob = OptimizationProblem(sys, [x => 0.0, y => 0.0, z => 0.0], [a => 1.0, b => 1.0],
8989
grad = true, hess = true, cons_j = true, cons_h = true)
9090
sol = solve(prob, IPNewton())
91-
@test sol.minimum < 1.0
91+
@test sol.objective < 1.0
9292
@test sol.u[0.808, -0.064] atol=1e-3
9393
@test sol[x]^2 + sol[y]^2 1.0
9494
sol = solve(prob, Ipopt.Optimizer(); print_level = 0)
95-
@test sol.minimum < 1.0
95+
@test sol.objective < 1.0
9696
@test sol.u[0.808, -0.064] atol=1e-3
9797
@test sol[x]^2 + sol[y]^2 1.0
9898

9999
prob = OptimizationProblem(sys, [x => 0.0, y => 0.0, z => 0.0], [a => 1.0, b => 1.0],
100100
grad = false, hess = false, cons_j = false, cons_h = false)
101101
sol = solve(prob, AmplNLWriter.Optimizer(Ipopt_jll.amplexe))
102-
@test_skip sol.minimum < 1.0
102+
@test_skip sol.objective < 1.0
103103
@test_skip sol.u[0.808, -0.064] atol=1e-3
104104
@test_skip sol[x]^2 + sol[y]^2 1.0
105105
end
@@ -108,7 +108,7 @@ end
108108
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
109109
x0 = zeros(2)
110110
p = [1.0, 100.0]
111-
f = OptimizationFunction(rosenbrock, Optimization.AutoModelingToolkit())
111+
f = OptimizationFunction(rosenbrock, Optimization.AutoSymbolics())
112112
prob = OptimizationProblem(f, x0, p)
113113
sol = solve(prob, Newton())
114114
@test sol.u [1.0, 1.0]
@@ -215,15 +215,15 @@ end
215215
Ipopt.Optimizer();
216216
print_level = 0))
217217
#=
218-
@test sol.minimum < -1e5
218+
@test sol.objective < -1e5
219219
220220
prob = OptimizationProblem(sys2, [x => 0.0, y => 0.0], [a => 1.0, b => 100.0],
221221
grad = true, hess = true, cons_j = true, cons_h = true)
222222
@test prob.f.sys === sys2
223223
sol = solve(prob, IPNewton())
224-
@test sol.minimum < 1.0
224+
@test sol.objective < 1.0
225225
sol = solve(prob, Ipopt.Optimizer(); print_level = 0)
226-
@test sol.minimum < 1.0
226+
@test sol.objective < 1.0
227227
=#
228228
end
229229

@@ -298,11 +298,11 @@ end
298298
loss = (a - x)^2 + b * (y - x^2)^2
299299
@named sys = OptimizationSystem(loss, [x, y], [a, b], constraints = [x^2 + y^2 0.0])
300300
sys = complete(sys)
301-
@test_throws ArgumentError OptimizationProblem(sys,
301+
@test_throws ErrorException OptimizationProblem(sys,
302302
[x => 0.0, y => 0.0],
303303
[a => 1.0, b => 100.0],
304304
lcons = [0.0])
305-
@test_throws ArgumentError OptimizationProblem(sys,
305+
@test_throws ErrorException OptimizationProblem(sys,
306306
[x => 0.0, y => 0.0],
307307
[a => 1.0, b => 100.0],
308308
ucons = [0.0])

test/sdesystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ let # test to make sure that scalar noise always receive the same kicks
693693
@mtkbuild de = System(eqs, t)
694694
prob = SDEProblem(de, [x => 0, y => 0], (0.0, 10.0), [])
695695
sol = solve(prob, SOSRI())
696-
@test sol[end][1] == sol[end][2]
696+
@test sol.u[end][1] == sol.u[end][2]
697697
end
698698

699699
let # test that diagonal noise is correctly handled

test/variable_parsing.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ s1 = Num(Sym{Real}(:s))
3333
@test ModelingToolkit.isparameter(s)
3434
@test ModelingToolkit.isparameter(σ)
3535

36-
@derivatives D' ~ t
37-
D1 = Differential(t)
38-
@test D1 == D
39-
4036
@test @macroexpand(@parameters x, y, z(t)) == @macroexpand(@parameters x y z(t))
4137
@test @macroexpand(@variables x, y, z(t)) == @macroexpand(@variables x y z(t))
4238

0 commit comments

Comments
 (0)