Skip to content

ci: standardise workflows using SciML's reusable workflows #2695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 31, 2024
Merged
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
13 changes: 13 additions & 0 deletions .github/workflows/FormatCheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: "Format Check"

on:
push:
branches:
- 'master'
tags: '*'
pull_request:

jobs:
format-check:
name: "Format Check"
uses: "SciML/.github/.github/workflows/format-suggestions-on-pr.yml@v1"
35 changes: 5 additions & 30 deletions .github/workflows/Invalidations.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Invalidations
name: "Invalidations"

on:
pull_request:
paths-ignore:
- 'docs/**'
- 'docs/**'

concurrency:
# Skip intermediate builds: always.
Expand All @@ -12,31 +12,6 @@ concurrency:
cancel-in-progress: true

jobs:
evaluate:
# Only run on PRs to the default branch.
# In the PR trigger above branches can be specified only explicitly whereas this check should work for master, main, or any other default branch
if: github.base_ref == github.event.repository.default_branch
runs-on: ubuntu-latest
steps:
- uses: julia-actions/setup-julia@v1
with:
version: '1'
- uses: actions/checkout@v4
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-invalidations@v1
id: invs_pr

- uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-invalidations@v1
id: invs_default

- name: Report invalidation counts
run: |
echo "Invalidations on default branch: ${{ steps.invs_default.outputs.total }} (${{ steps.invs_default.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY
echo "This branch: ${{ steps.invs_pr.outputs.total }} (${{ steps.invs_pr.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY
- name: Check if the PR does increase number of invalidations
if: steps.invs_pr.outputs.total > steps.invs_default.outputs.total
run: exit 1
evaluate-invalidations:
name: "Evaluate Invalidations"
uses: "SciML/.github/.github/workflows/invalidations.yml@v1"
37 changes: 37 additions & 0 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "Tests"

on:
pull_request:
branches:
- master
- 'release-'
paths-ignore:
- 'docs/**'
push:
branches:
- master
paths-ignore:
- 'docs/**'

concurrency:
# Skip intermediate builds: always, but for the master branch.
# Cancel intermediate builds: always, but for the master branch.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

jobs:
tests:
name: "Tests"
strategy:
fail-fast: false
matrix:
group:
- InterfaceI
- InterfaceII
- Extensions
- Downstream
- RegressionI
uses: "SciML/.github/.github/workflows/tests.yml@v1"
with:
group: "${{ matrix.group }}"
secrets: "inherit"
91 changes: 0 additions & 91 deletions .github/workflows/ci.yml

This file was deleted.

2 changes: 1 addition & 1 deletion test/hierarchical_initialization_eqs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,6 @@ syslist = ModelingToolkit.get_systems(model)
u0 = []
prob = ODEProblem(structural_simplify(model), u0, (0.0, 10.0))
sol = solve(prob, Rodas5P())
@test length(sol[end]) == 2
@test length(sol.u[end]) == 2
@test length(equations(prob.f.initializeprob.f.sys)) == 0
@test length(unknowns(prob.f.initializeprob.f.sys)) == 0
6 changes: 3 additions & 3 deletions test/modelingtoolkitize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ sys = complete(modelingtoolkitize(prob)) # symbolicitize me captain!

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

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

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

## SIR System Regression Test

Expand Down
26 changes: 13 additions & 13 deletions test/optimizationsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ using ModelingToolkit: get_metadata
cons_h = true)
@test prob.f.sys === combinedsys
sol = solve(prob, Ipopt.Optimizer(); print_level = 0)
@test sol.minimum < -1e5
@test sol.objective < -1e5
end

@testset "inequality constraint" begin
Expand All @@ -66,14 +66,14 @@ end
grad = true, hess = true, cons_j = true, cons_h = true)
@test prob.f.sys === sys
sol = solve(prob, IPNewton())
@test sol.minimum < 1.0
@test sol.objective < 1.0
sol = solve(prob, Ipopt.Optimizer(); print_level = 0)
@test sol.minimum < 1.0
@test sol.objective < 1.0

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

@testset "equality constraint" begin
Expand All @@ -88,18 +88,18 @@ end
prob = OptimizationProblem(sys, [x => 0.0, y => 0.0, z => 0.0], [a => 1.0, b => 1.0],
grad = true, hess = true, cons_j = true, cons_h = true)
sol = solve(prob, IPNewton())
@test sol.minimum < 1.0
@test sol.objective < 1.0
@test sol.u≈[0.808, -0.064] atol=1e-3
@test sol[x]^2 + sol[y]^2 ≈ 1.0
sol = solve(prob, Ipopt.Optimizer(); print_level = 0)
@test sol.minimum < 1.0
@test sol.objective < 1.0
@test sol.u≈[0.808, -0.064] atol=1e-3
@test sol[x]^2 + sol[y]^2 ≈ 1.0

prob = OptimizationProblem(sys, [x => 0.0, y => 0.0, z => 0.0], [a => 1.0, b => 1.0],
grad = false, hess = false, cons_j = false, cons_h = false)
sol = solve(prob, AmplNLWriter.Optimizer(Ipopt_jll.amplexe))
@test_skip sol.minimum < 1.0
@test_skip sol.objective < 1.0
@test_skip sol.u≈[0.808, -0.064] atol=1e-3
@test_skip sol[x]^2 + sol[y]^2 ≈ 1.0
end
Expand All @@ -108,7 +108,7 @@ end
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
x0 = zeros(2)
p = [1.0, 100.0]
f = OptimizationFunction(rosenbrock, Optimization.AutoModelingToolkit())
f = OptimizationFunction(rosenbrock, Optimization.AutoSymbolics())
prob = OptimizationProblem(f, x0, p)
sol = solve(prob, Newton())
@test sol.u ≈ [1.0, 1.0]
Expand Down Expand Up @@ -215,15 +215,15 @@ end
Ipopt.Optimizer();
print_level = 0))
#=
@test sol.minimum < -1e5
@test sol.objective < -1e5

prob = OptimizationProblem(sys2, [x => 0.0, y => 0.0], [a => 1.0, b => 100.0],
grad = true, hess = true, cons_j = true, cons_h = true)
@test prob.f.sys === sys2
sol = solve(prob, IPNewton())
@test sol.minimum < 1.0
@test sol.objective < 1.0
sol = solve(prob, Ipopt.Optimizer(); print_level = 0)
@test sol.minimum < 1.0
@test sol.objective < 1.0
=#
end

Expand Down Expand Up @@ -298,11 +298,11 @@ end
loss = (a - x)^2 + b * (y - x^2)^2
@named sys = OptimizationSystem(loss, [x, y], [a, b], constraints = [x^2 + y^2 ≲ 0.0])
sys = complete(sys)
@test_throws ArgumentError OptimizationProblem(sys,
@test_throws ErrorException OptimizationProblem(sys,
[x => 0.0, y => 0.0],
[a => 1.0, b => 100.0],
lcons = [0.0])
@test_throws ArgumentError OptimizationProblem(sys,
@test_throws ErrorException OptimizationProblem(sys,
[x => 0.0, y => 0.0],
[a => 1.0, b => 100.0],
ucons = [0.0])
Expand Down
2 changes: 1 addition & 1 deletion test/sdesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ let # test to make sure that scalar noise always receive the same kicks
@mtkbuild de = System(eqs, t)
prob = SDEProblem(de, [x => 0, y => 0], (0.0, 10.0), [])
sol = solve(prob, SOSRI())
@test sol[end][1] == sol[end][2]
@test sol.u[end][1] == sol.u[end][2]
end

let # test that diagonal noise is correctly handled
Expand Down
4 changes: 0 additions & 4 deletions test/variable_parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ s1 = Num(Sym{Real}(:s))
@test ModelingToolkit.isparameter(s)
@test ModelingToolkit.isparameter(σ)

@derivatives D' ~ t
D1 = Differential(t)
@test D1 == D

@test @macroexpand(@parameters x, y, z(t)) == @macroexpand(@parameters x y z(t))
@test @macroexpand(@variables x, y, z(t)) == @macroexpand(@variables x y z(t))

Expand Down
Loading