Skip to content

Commit

Permalink
CI: don't run threads tests in Windows GHA CI (attempt 2) (#530)
Browse files Browse the repository at this point in the history
* CI: don't run `threads` tests in Windows GHA CI

* Change some `@info`s to `@debug`s
  • Loading branch information
DilumAluthge authored Apr 3, 2024
1 parent 7408e4b commit 08d6ae1
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 24 deletions.
65 changes: 41 additions & 24 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license
using Test, LinearAlgebra, SparseArrays

include("util/gha.jl")

if Base.get_bool_env("SPARSEARRAYS_AQUA_TEST", false)
include("ambiguous.jl")
end
Expand All @@ -18,32 +20,47 @@ if Base.USE_GPL_LIBS
Threads.nthreads()
end

# Test multithreaded execution
@testset "threaded SuiteSparse tests" verbose = true begin
@testset "threads = $nt" begin
include("threads.jl")
end
# test both nthreads==1 and nthreads>1. spawn a process to test whichever
# case we are not running currently.
other_nthreads = nt == 1 ? 4 : 1
@testset "threads = $other_nthreads" begin
let p, cmd = `$(Base.julia_cmd()) --depwarn=error --startup-file=no threads.jl`
p = run(
pipeline(
setenv(
cmd,
"JULIA_NUM_THREADS" => other_nthreads,
dir=@__DIR__()),
stdout = stdout,
stderr = stderr),
wait = false)
if !success(p)
error("SuiteSparse threads test failed with nthreads == $other_nthreads")
else
@test true # mimic the one @test in threads.jl
# 1. If the OS is Windows and we are in GitHub Actions CI, we do NOT run
# the `threads` tests.
# 2. If the OS is Windows and we are NOT in GitHub Actions CI, we DO run
# the `threads` tests.
# - So, just as an example, if the OS is Windows and we are in
# Buildkite CI, we DO run the `threads` tests.
# 3. If the OS is NOT Windows, we DO run the `threads` tests.
if Sys.iswindows() && is_github_actions_ci()
@warn "Skipping `threads` tests on Windows on GitHub Actions CI"
@test_skip false
else
@debug "Beginning the `threads` tests..."

# Test multithreaded execution
@testset "threaded SuiteSparse tests" verbose = true begin
@testset "threads = $nt" begin
include("threads.jl")
end
# test both nthreads==1 and nthreads>1. spawn a process to test whichever
# case we are not running currently.
other_nthreads = nt == 1 ? 4 : 1
@testset "threads = $other_nthreads" begin
let p, cmd = `$(Base.julia_cmd()) --depwarn=error --startup-file=no threads.jl`
p = run(
pipeline(
setenv(
cmd,
"JULIA_NUM_THREADS" => other_nthreads,
dir=@__DIR__()),
stdout = stdout,
stderr = stderr),
wait = false)
if !success(p)
error("SuiteSparse threads test failed with nthreads == $other_nthreads")
else
@test true # mimic the one @test in threads.jl
end
end
end
end
end

@debug "Finished the `threads` tests..."
end
end
6 changes: 6 additions & 0 deletions test/util/gha.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function is_github_actions_ci()
is_ci = parse(Bool, get(ENV, "CI", "false"))
is_gha = parse(Bool, get(ENV, "GITHUB_ACTIONS", "false"))

return is_ci && is_gha
end

0 comments on commit 08d6ae1

Please sign in to comment.