Skip to content

Fix testing setup #299

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 11 commits into from
Jun 14, 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
47 changes: 45 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,66 @@ on:
pull_request:
branches:
- main
- 'release-'
paths-ignore:
- 'docs/**'
push:
branches:
- main
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:
formatter:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1]
julia-arch: [x86]
os: [ubuntu-latest]
steps:
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.julia-version }}

- uses: actions/checkout@v4
- name: Install JuliaFormatter and format
# This will use the latest version by default but you can set the version like so:
#
# julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))'
run: |
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="1.0.50"))'
julia -e 'using JuliaFormatter; format(".", verbose=true)'
- name: Format check
run: |
julia -e '
out = Cmd(`git diff`) |> read |> String
if out == ""
exit(0)
else
@error "Some files have not been formatted !!!"
write(stdout, out)
exit(1)
end'
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
group:
- All
- QA
- Core
version:
- '1'
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
- uses: actions/cache@v4
Expand All @@ -36,6 +77,8 @@ jobs:
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
env:
GROUP: ${{ matrix.group }}
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion docs/pages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pages = [
],
"About Acausal Connections" => [
"Theory" => "connectors/connections.md",
"Sign Convention" => "connectors/sign_convention.md",
"Sign Convention" => "connectors/sign_convention.md"
],
"API" => [
"Basic Blocks" => "API/blocks.md",
Expand Down
1 change: 1 addition & 0 deletions docs/src/connectors/sign_convention.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ The flow variable (i.e. force) input component for the `Mechanical` domain is
```@example sign_convention
using ModelingToolkit
using ModelingToolkitStandardLibrary.Mechanical.Translational
using ModelingToolkit: t_nounits as t

@mtkmodel ConstantForce begin
@parameters begin
Expand Down
4 changes: 2 additions & 2 deletions src/Blocks/analysis_points.jl
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ function ModelingToolkit.linearization_function(sys::ModelingToolkit.AbstractSys
push!(multiplicities_u, length(ui)) # one ap may yield several new vars
append!(u, ui)
if loop_openings !== nothing && ap.name ∈ loop_openings
# In thise case, we break the existing connection.
# In this case, we break the existing connection.
[ap_var(ap.out) .~ ui;], ui
else
[ap_var(ap.out) .~ ap_var(ap.in) + ui;], ui
Expand All @@ -454,7 +454,7 @@ function ModelingToolkit.linearization_function(sys::ModelingToolkit.AbstractSys
append!(y, yi)
if loop_openings !== nothing && ap.name ∈ loop_openings
[ap_var(ap.in) .~ yi;
ap_var(ap.out) .~ 0], yi # In thise case, we break the existing connection.
ap_var(ap.out) .~ 0], yi # In this case, we break the existing connection.
else
[ap_var(ap.in) .~ yi;
ap_var(ap.out) .~ ap_var(ap.in)], yi
Expand Down
28 changes: 14 additions & 14 deletions src/Hydraulic/IsothermalCompressible/components.jl
Original file line number Diff line number Diff line change
Expand Up @@ -495,20 +495,20 @@ See also [`FixedVolume`](@ref), [`DynamicVolume`](@ref)
end

eqs = [
# connectors
port.p ~ p
port.dm ~ dm
flange.v * direction ~ dx
flange.f * direction ~ -f

# differentials
D(x) ~ dx
D(rho) ~ drho

# physics
rho ~ liquid_density(port, p)
f ~ p * area
dm ~ drho * x * area + rho * dx * area]
# connectors
port.p ~ p
port.dm ~ dm
flange.v * direction ~ dx
flange.f * direction ~ -f

# differentials
D(x) ~ dx
D(rho) ~ drho

# physics
rho ~ liquid_density(port, p)
f ~ p * area
dm ~ drho * x * area + rho * dx * area]

ODESystem(eqs, t, vars, pars; name, systems, defaults = [rho => liquid_density(port)])
end
Expand Down
File renamed without changes.
130 changes: 70 additions & 60 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,69 +1,79 @@
using SafeTestsets
using SafeTestsets, Test

@safetestset "Quality Assurance" begin
include("qa.jl")
end
const GROUP = get(ENV, "GROUP", "All")

# Blocks
@safetestset "Blocks: utils" begin
include("Blocks/utils.jl")
end
@safetestset "Blocks: math" begin
include("Blocks/math.jl")
end
@safetestset "Blocks: nonlinear" begin
include("Blocks/nonlinear.jl")
end
@safetestset "Blocks: continuous" begin
include("Blocks/continuous.jl")
end
@safetestset "Blocks: sources" begin
include("Blocks/sources.jl")
end
@safetestset "Blocks: analysis points" begin
include("Blocks/test_analysis_points.jl")
end
@time begin
if GROUP == "QA" || GROUP == "All"
@time @safetestset "Aqua" begin
include("aqua.jl")
end
end

# Electrical
@safetestset "Analog Circuits" begin
include("Electrical/analog.jl")
end
if GROUP == "Core" || GROUP == "All"
@testset "Core" begin
# Blocks
@safetestset "Blocks: utils" begin
include("Blocks/utils.jl")
end
@safetestset "Blocks: math" begin
include("Blocks/math.jl")
end
@safetestset "Blocks: nonlinear" begin
include("Blocks/nonlinear.jl")
end
@safetestset "Blocks: continuous" begin
include("Blocks/continuous.jl")
end
@safetestset "Blocks: sources" begin
include("Blocks/sources.jl")
end
@safetestset "Blocks: analysis points" begin
include("Blocks/test_analysis_points.jl")
end

@safetestset "Digital Circuits" begin
include("Electrical/digital.jl")
end
@safetestset "Chua Circuit Demo" begin
include("chua_circuit.jl")
end
# Electrical
@safetestset "Analog Circuits" begin
include("Electrical/analog.jl")
end

# Thermal
@safetestset "Thermal Circuits" begin
include("Thermal/thermal.jl")
end
@safetestset "Thermal Demo" begin
include("Thermal/demo.jl")
end
@safetestset "Digital Circuits" begin
include("Electrical/digital.jl")
end
@safetestset "Chua Circuit Demo" begin
include("chua_circuit.jl")
end

# Magnetic
@safetestset "Magnetic" begin
include("Magnetic/magnetic.jl")
end
# Thermal
@safetestset "Thermal Circuits" begin
include("Thermal/thermal.jl")
end
@safetestset "Thermal Demo" begin
include("Thermal/demo.jl")
end

# Mechanical
@safetestset "Mechanical Rotation" begin
include("Mechanical/rotational.jl")
end
@safetestset "Mechanical Translation" begin
include("Mechanical/translational.jl")
end
@safetestset "Mechanical Translation" begin
include("Mechanical/translational_modelica.jl")
end
@safetestset "Multi-Domain" begin
include("multi_domain.jl")
end
# Magnetic
@safetestset "Magnetic" begin
include("Magnetic/magnetic.jl")
end

# Mechanical
@safetestset "Mechanical Rotation" begin
include("Mechanical/rotational.jl")
end
@safetestset "Mechanical Translation" begin
include("Mechanical/translational.jl")
end
@safetestset "Mechanical Translation" begin
include("Mechanical/translational_modelica.jl")
end
@safetestset "Multi-Domain" begin
include("multi_domain.jl")
end

# Hydraulic
@safetestset "Hydraulic IsothermalCompressible" begin
include("Hydraulic/isothermal_compressible.jl")
# Hydraulic
@safetestset "Hydraulic IsothermalCompressible" begin
include("Hydraulic/isothermal_compressible.jl")
end
end
end
end
Loading