Skip to content

Commit

Permalink
Merge pull request #226 from SciML/at/use-reusable-workflows
Browse files Browse the repository at this point in the history
ci: update tests workflow to use centralised reusable workflow
  • Loading branch information
ChrisRackauckas authored Jul 31, 2024
2 parents dfc2a85 + 4024690 commit 802ca9e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 62 deletions.
48 changes: 0 additions & 48 deletions .github/workflows/CI.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/FormatCheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ on:
jobs:
format-check:
name: "Format Check"
uses: "SciML/.github/.github/workflows/format-check.yml@v1"
uses: "SciML/.github/.github/workflows/format-suggestions-on-pr.yml@v1"
32 changes: 32 additions & 0 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: "Tests"

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

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref_name != github.event.repository.default_branch || github.ref != 'refs/tags/v*' }}

jobs:
tests:
name: "Tests"
strategy:
fail-fast: false
matrix:
os:
- "ubuntu-latest"
- "macos-latest"
- "windows-latest"
uses: "SciML/.github/.github/workflows/tests.yml@v1"
with:
os: "${{ matrix.os }}"
secrets: "inherit"
26 changes: 13 additions & 13 deletions test/manifold_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ function isautonomous(::ManifoldProjection{
end

sol = solve(prob, Vern7())
@test !(sol[end][1]^2 + sol[end][2]^2 2)
@test !(sol.u[end][1]^2 + sol.u[end][2]^2 2)

# autodiff=true
@inferred ManifoldProjection(g; autonomous = Val(false), resid_prototype = zeros(2))
cb = ManifoldProjection(g; resid_prototype = zeros(2))
@test isautonomous(cb.affect!)
solve(prob, Vern7(), callback = cb)
@time sol = solve(prob, Vern7(), callback = cb)
@test sol[end][1]^2 + sol[end][2]^2 2
@test sol.u[end][1]^2 + sol.u[end][2]^2 2

cb_t = ManifoldProjection(g_t; resid_prototype = zeros(2))
@test !isautonomous(cb_t.affect!)
Expand All @@ -42,7 +42,7 @@ cb_false = ManifoldProjection(
@test isautonomous(cb_false.affect!)
solve(prob, Vern7(), callback = cb_false)
sol = solve(prob, Vern7(), callback = cb_false)
@test sol[end][1]^2 + sol[end][2]^2 2
@test sol.u[end][1]^2 + sol.u[end][2]^2 2

cb_t_false = ManifoldProjection(g_t,
nlsolve = GaussNewton(; autodiff = AutoFiniteDiff()), resid_prototype = zeros(2))
Expand All @@ -56,16 +56,16 @@ u₀ = ArrayPartition(ones(2), ones(2))
prob = ODEProblem(f, u₀, (0.0, 100.0))

sol = solve(prob, Vern7(), callback = cb)
@test sol[end][1]^2 + sol[end][2]^2 2
@test sol.u[end][1]^2 + sol.u[end][2]^2 2

sol = solve(prob, Vern7(), callback = cb_t)
@test sol[end][1]^2 + sol[end][2]^2 2
@test sol.u[end][1]^2 + sol.u[end][2]^2 2

sol = solve(prob, Vern7(), callback = cb_false)
@test sol[end][1]^2 + sol[end][2]^2 2
@test sol.u[end][1]^2 + sol.u[end][2]^2 2

sol = solve(prob, Vern7(), callback = cb_t_false)
@test sol[end][1]^2 + sol[end][2]^2 2
@test sol.u[end][1]^2 + sol.u[end][2]^2 2

# Test termination if cannot project to manifold
function g_unsat(resid, u, p)
Expand Down Expand Up @@ -94,7 +94,7 @@ cb = ManifoldProjection(g_oop; isinplace = Val(false))
@test isautonomous(cb.affect!)
solve(prob, Vern7(), callback = cb)
@time sol = solve(prob, Vern7(), callback = cb)
@test sol[end][1]^2 + sol[end][2]^2 2
@test sol.u[end][1]^2 + sol.u[end][2]^2 2

cb_t = ManifoldProjection(g_oop_t; isinplace = Val(false))
@test !isautonomous(cb_t.affect!)
Expand All @@ -108,7 +108,7 @@ cb_false = ManifoldProjection(
@test isautonomous(cb_false.affect!)
solve(prob, Vern7(), callback = cb_false)
sol = solve(prob, Vern7(), callback = cb_false)
@test sol[end][1]^2 + sol[end][2]^2 2
@test sol.u[end][1]^2 + sol.u[end][2]^2 2

cb_t_false = ManifoldProjection(g_oop_t,
nlsolve = GaussNewton(; autodiff = AutoFiniteDiff()), isinplace = Val(false))
Expand All @@ -122,13 +122,13 @@ u₀ = ArrayPartition(ones(2), ones(2))
prob = ODEProblem(f, u₀, (0.0, 100.0))

sol = solve(prob, Vern7(), callback = cb)
@test sol[end][1]^2 + sol[end][2]^2 2
@test sol.u[end][1]^2 + sol.u[end][2]^2 2

sol = solve(prob, Vern7(), callback = cb_t)
@test sol[end][1]^2 + sol[end][2]^2 2
@test sol.u[end][1]^2 + sol.u[end][2]^2 2

sol = solve(prob, Vern7(), callback = cb_false)
@test sol[end][1]^2 + sol[end][2]^2 2
@test sol.u[end][1]^2 + sol.u[end][2]^2 2

sol = solve(prob, Vern7(), callback = cb_t_false)
@test sol[end][1]^2 + sol[end][2]^2 2
@test sol.u[end][1]^2 + sol.u[end][2]^2 2

0 comments on commit 802ca9e

Please sign in to comment.