Skip to content

Commit 6990e68

Browse files
committed
try getting branch name from environment on Gitlab CI
1 parent f255319 commit 6990e68

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/runtests.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ using Pkg
77
GPUArrays.test(JLArray)
88
end
99

10-
function test_package(package)
10+
function test_package(package, branch=nothing)
1111
mktempdir() do devdir
1212
withenv("JULIA_PKG_DEVDIR" => devdir) do
1313
# try to install from the same branch of GPUArrays
1414
try
15-
branch = chomp(read(`git -C $(@__DIR__) rev-parse --abbrev-ref HEAD`, String))
15+
if branch === nothing
16+
branch = chomp(read(`git -C $(@__DIR__) rev-parse --abbrev-ref HEAD`, String))
17+
branch == "HEAD" && error("in detached HEAD state")
18+
end
1619
Pkg.add(PackageSpec(name=package, rev=String(branch)))
1720
@info "Installed $package from $branch branch"
1821
catch ex
@@ -26,7 +29,8 @@ function test_package(package)
2629
end
2730

2831
if haskey(ENV, "GITLAB_CI")
32+
branch = ENV["CI_COMMIT_REF_NAME"]
2933
@testset "CuArray" begin
30-
test_package("CuArrays")
34+
test_package("CuArrays", branch)
3135
end
3236
end

0 commit comments

Comments
 (0)