Skip to content

Use GitHub workflow commands for improved workflow logs #2353

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

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions examples/tree_2d_dgsem/elixir_advection_basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ using Trixi
###############################################################################
# semidiscretization of the linear advection equation

advection_velocity = (0.2, -0.7)
advection_velocity = (0.3, -0.7)
equations = LinearScalarAdvectionEquation2D(advection_velocity)

# Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux
solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs)

coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y))
coordinates_min = (-11.1, -1.0) # minimum coordinates (min(x), min(y))
coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y))

# Create a uniformly refined mesh with periodic boundaries
Expand Down
26 changes: 26 additions & 0 deletions test/test_trixi.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
using Test: @test
import Trixi

const CI_ON_GITHUB = get(ENV, "GITHUB_ACTIONS", false) == "true"
const GITHUB_BASE_URL = get(ENV, "GITHUB_SERVER_URL", "https://github.com") *
"/" * get(ENV, "GITHUB_REPOSITORY", "") * "/blob/" *
get(ENV, "GITHUB_SHA", "") * "/"
const GITHUB_TEST_URL = GITHUB_BASE_URL * "test/"

# Use a macro to avoid world age issues when defining new initial conditions etc.
# inside an elixir.
"""
Expand Down Expand Up @@ -174,8 +180,15 @@ after execution.
"""
macro timed_testset(name, expr)
@assert name isa String
filename = basename(string(__source__.file))
lineno = string(__source__.line)
quote
local time_start = time_ns()
# Use GitHub workflow commands for improved CI logs
if CI_ON_GITHUB
println("::group::>>> Running testset '", $name, "'...")
println("Testset started at ", $GITHUB_TEST_URL, $filename, "#L", $lineno)
end
@testset $name $expr
local time_stop = time_ns()
if Trixi.mpi_isroot()
Expand All @@ -184,6 +197,9 @@ macro timed_testset(name, expr)
*string(1.0e-9 * (time_stop - time_start))*" seconds.\n")
flush(stdout)
end
if CI_ON_GITHUB
println("::endgroup::")
end
end
end

Expand All @@ -197,6 +213,8 @@ of the testset similarly to [`timed_testset`](@ref).
"""
macro trixi_testset(name, expr)
@assert name isa String
filename = basename(string(__source__.file))
lineno = string(__source__.line)
# TODO: `@eval` is evil
# We would like to use
# mod = gensym(name)
Expand All @@ -220,6 +238,11 @@ macro trixi_testset(name, expr)
catch
nothing
end
# Use GitHub workflow commands for improved CI logs
if CI_ON_GITHUB
println("::group::>>> Running testset '", $name, "'...")
println("Testset started at ", $GITHUB_TEST_URL, $filename, "#L", $lineno)
end
@testset $name $expr
end
local time_stop = time_ns()
Expand All @@ -228,6 +251,9 @@ macro trixi_testset(name, expr)
@info("Testset "*$name*" finished in "
*string(1.0e-9 * (time_stop - time_start))*" seconds.\n")
end
if CI_ON_GITHUB
println("::endgroup::")
end
nothing
end
end
46 changes: 23 additions & 23 deletions test/test_visualization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ outdir = "out"
isdir(outdir) && rm(outdir, recursive = true)

# Run various visualization tests
@testset "Visualization tests" begin
@timed_testset "Visualization tests" begin
#! format: noindent

# Run 2D tests with elixirs for all mesh types
Expand Down Expand Up @@ -88,7 +88,7 @@ test_examples_2d = Dict("TreeMesh" => ("tree_2d_dgsem",
@test_nowarn_mod show(stdout, getmesh(pd))
println(stdout)

@testset "2D plot recipes" begin
@timed_testset "2D plot recipes" begin
pd = PlotData2D(sol)

@test_nowarn_mod Plots.plot(sol)
Expand All @@ -112,17 +112,17 @@ test_examples_2d = Dict("TreeMesh" => ("tree_2d_dgsem",
end
end

@testset "1D plot from 2D solution" begin
@timed_testset "1D plot from 2D solution" begin
if mesh != "DGMulti"
@testset "Create 1D plot as slice" begin
@timed_testset "Create 1D plot as slice" begin
@test_nowarn_mod PlotData1D(sol, slice = :y, point = (0.5, 0.0)) isa
PlotData1D
@test_nowarn_mod PlotData1D(sol, slice = :x, point = (0.5, 0.0)) isa
PlotData1D
pd1D = PlotData1D(sol, slice = :y, point = (0.5, 0.0))
@test_nowarn_mod Plots.plot(pd1D)

@testset "Create 1D plot along curve" begin
@timed_testset "Create 1D plot along curve" begin
curve = zeros(2, 10)
curve[1, :] = range(-1, 1, length = 10)
@test_nowarn_mod PlotData1D(sol, curve = curve) isa PlotData1D
Expand Down Expand Up @@ -186,7 +186,7 @@ end
pd2 = PlotData1D(sol, nvisnodes = 2)
@test size(pd2.data) == (128, 3)

@testset "1D plot recipes" begin
@timed_testset "1D plot recipes" begin
pd = PlotData1D(sol)

@test_nowarn_mod Plots.plot(sol)
Expand All @@ -202,7 +202,7 @@ end

# Fake a PlotDataXD objects to test code for plotting multiple variables on at least two rows
# with at least one plot remaining empty
@testset "plotting multiple variables" begin
@timed_testset "plotting multiple variables" begin
x = collect(0.0:0.1:1.0)
data1d = rand(5, 11)
variable_names = string.('a':'e')
Expand Down Expand Up @@ -320,7 +320,7 @@ end
x_curve = range(0, 1, length = 1000)
curve = vcat(x_curve', x_curve')

@testset "TreeMesh" begin
@timed_testset "TreeMesh" begin
pd_tree = @inferred PlotData1D(ode_tree.u0, ode_tree.p; curve)
@test pd_tree.x ≈ range(0, 1, length = length(x_curve)) * sqrt(2)

Expand All @@ -336,7 +336,7 @@ end
end
end

@testset "P4estMesh" begin
@timed_testset "P4estMesh" begin
pd_p4est = @inferred PlotData1D(ode_p4est.u0, ode_p4est.p; curve)
@test pd_p4est.x ≈ range(0, 1, length = length(x_curve)) * sqrt(2)

Expand All @@ -352,7 +352,7 @@ end
end
end

@testset "T8codeMesh" begin
@timed_testset "T8codeMesh" begin
pd_t8code = @inferred PlotData1D(ode_t8code.u0, ode_t8code.p; curve)
@test pd_t8code.x ≈ range(0, 1, length = length(x_curve)) * sqrt(2)

Expand All @@ -371,7 +371,7 @@ end
end
end

@testset "StructuredMesh" begin
@timed_testset "StructuredMesh" begin
pd_structured = @inferred PlotData1D(ode_structured.u0, ode_structured.p;
curve)
@test pd_structured.x ≈ range(0, 1, length = length(x_curve)) * sqrt(2)
Expand Down Expand Up @@ -468,8 +468,8 @@ end
@test PlotData2D(sol, slice = :yz) isa Trixi.PlotData2DCartesian
@test PlotData2D(sol, slice = :xz) isa Trixi.PlotData2DCartesian

@testset "1D plot from 3D solution and Tree-mesh" begin
@testset "Create 1D plot as slice" begin
@timed_testset "1D plot from 3D solution and Tree-mesh" begin
@timed_testset "Create 1D plot as slice" begin
@test_nowarn_mod PlotData1D(sol) isa PlotData1D
pd1D = PlotData1D(sol)
@test_nowarn_mod Plots.plot(pd1D)
Expand All @@ -479,7 +479,7 @@ end
PlotData1D
end

@testset "Create 1D plot along curve" begin
@timed_testset "Create 1D plot along curve" begin
curve = zeros(3, 10)
curve[1, :] = range(-1.0, -0.5, length = 10)
@test_nowarn_mod PlotData1D(sol, curve = curve) isa PlotData1D
Expand All @@ -492,8 +492,8 @@ end
joinpath(examples_dir(), "structured_3d_dgsem",
"elixir_advection_basic.jl"))

@testset "1D plot from 3D solution and general mesh" begin
@testset "Create 1D plot as slice" begin
@timed_testset "1D plot from 3D solution and general mesh" begin
@timed_testset "Create 1D plot as slice" begin
@test_nowarn_mod PlotData1D(sol) isa PlotData1D
pd1D = PlotData1D(sol)
@test_nowarn_mod Plots.plot(pd1D)
Expand All @@ -503,7 +503,7 @@ end
PlotData1D
end

@testset "Create 1D plot along curve" begin
@timed_testset "Create 1D plot along curve" begin
curve = zeros(3, 10)
curve[1, :] = range(-1.0, 1.0, length = 10)
@test_nowarn_mod PlotData1D(sol, curve = curve) isa PlotData1D
Expand Down Expand Up @@ -615,7 +615,7 @@ end
x_curve = range(0, 1, length = 1000)
curve = vcat(x_curve', x_curve', x_curve')

@testset "TreeMesh" begin
@timed_testset "TreeMesh" begin
pd_tree = @inferred PlotData1D(ode_tree.u0, ode_tree.p; curve)
@test pd_tree.x ≈ range(0, 1, length = length(x_curve)) * sqrt(3)

Expand All @@ -633,7 +633,7 @@ end
end
end

@testset "P4estMesh" begin
@timed_testset "P4estMesh" begin
pd_p4est = @inferred PlotData1D(ode_p4est.u0, ode_p4est.p; curve)
@test pd_p4est.x ≈ range(0, 1, length = length(x_curve)) * sqrt(3)

Expand All @@ -651,7 +651,7 @@ end
end
end

@testset "T8codeMesh" begin
@timed_testset "T8codeMesh" begin
pd_t8code = @inferred PlotData1D(ode_t8code.u0, ode_t8code.p; curve)
@test pd_t8code.x ≈ range(0, 1, length = length(x_curve)) * sqrt(3)

Expand All @@ -669,7 +669,7 @@ end
end
end

@testset "StructuredMesh" begin
@timed_testset "StructuredMesh" begin
pd_structured = @inferred PlotData1D(ode_structured.u0, ode_structured.p;
curve)
@test pd_structured.x ≈ range(0, 1, length = length(x_curve)) * sqrt(3)
Expand Down Expand Up @@ -718,13 +718,13 @@ end
plot_creator = Trixi.save_plot),
tspan = (0.0, 3.0))

@testset "elixir_advection_amr_visualization.jl with save_plot" begin
@timed_testset "elixir_advection_amr_visualization.jl with save_plot" begin
@test isfile(joinpath(outdir, "solution_000000000.png"))
@test isfile(joinpath(outdir, "solution_000000020.png"))
@test isfile(joinpath(outdir, "solution_000000022.png"))
end

@testset "show" begin
@timed_testset "show" begin
@test_nowarn_mod show(stdout, visualization)
println(stdout)

Expand Down
Loading