From ae842184ab87721c2d94e83a1b2bab01c5d4fc59 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Tue, 4 Jul 2023 03:34:14 -0400 Subject: [PATCH 1/9] handle git cli errors as pkgerrors Co-Authored-By: Fredrik Ekre <11698744+fredrikekre@users.noreply.github.com> --- src/GitTools.jl | 14 ++++++++++++-- test/new.jl | 5 +++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/GitTools.jl b/src/GitTools.jl index a63dcde15a..d1d6551ebc 100644 --- a/src/GitTools.jl +++ b/src/GitTools.jl @@ -109,7 +109,12 @@ function clone(io::IO, url, source_path; header=nothing, credentials=nothing, kw end try if use_cli_git() - run(pipeline(`git clone --quiet $url $source_path`; stdout=devnull)) + cmd = `git clone --quiet $url $source_path` + try + run(pipeline(cmd; stdout=devnull)) + catch err + Pkg.Types.pkgerror("The command $(cmd) failed, error: $err") + end return LibGit2.GitRepo(source_path) else mkpath(source_path) @@ -161,7 +166,12 @@ function fetch(io::IO, repo::LibGit2.GitRepo, remoteurl=nothing; header=nothing, if use_cli_git() let remoteurl=remoteurl cd(LibGit2.path(repo)) do - run(pipeline(`git fetch -q $remoteurl $(only(refspecs))`; stdout=devnull)) + cmd = `git fetch -q $remoteurl $(only(refspecs))` + try + run(pipeline(cmd; stdout=devnull)) + catch err + Pkg.Types.pkgerror("The command $(cmd) failed, error: $err") + end end end else diff --git a/test/new.jl b/test/new.jl index dd5e5c731a..bca827e8ce 100644 --- a/test/new.jl +++ b/test/new.jl @@ -2704,6 +2704,11 @@ end @test haskey(Pkg.dependencies(), TEST_PKG.uuid) Pkg.rm(TEST_PKG.name) end + @testset "libgit2 failures" begin + doesnotexist = "https://github.com/DoesNotExist/DoesNotExist.jl" + @test_throws Pkg.Types.PkgError Pkg.add(url=doesnotexist, use_git_for_all_downloads=true) + @test_throws Pkg.Types.PkgError Pkg.Registry.add(Pkg.RegistrySpec(url=doesnotexist)) + end @testset "tarball downloads" begin Pkg.add("JSON"; use_only_tarballs_for_downloads=true) @test "JSON" in [pkg.name for (uuid, pkg) in Pkg.dependencies()] From 94b1907687b8ec2a6648497e17d5ddca1c475003 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Sat, 8 Jul 2023 19:51:39 -0400 Subject: [PATCH 2/9] debug - run CI with logs on Revert "debug - run CI with logs on" This reverts commit a8f8125514a06b2d411d8e489e24ef47f43ab168. Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bf226a78df..c03c8fd4c3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -61,7 +61,7 @@ jobs: - run: julia --project --color=yes --check-bounds=yes -e 'import Pkg; Pkg.build(); Pkg.test(; coverage=true)' env: JULIA_PKG_SERVER: ${{ matrix.pkg-server }} - JULIA_PKG_TEST_QUIET: "true" # "true" is the default. i.e. tests are quiet when this env var isn't set + JULIA_PKG_TEST_QUIET: "false" # "true" is the default. i.e. tests are quiet when this env var isn't set - uses: julia-actions/julia-processcoverage@v1 env: JULIA_PKG_SERVER: ${{ matrix.pkg-server }} From 3a78e477b20bfbaf4f66f1cbe28c97a25cb680ae Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Mon, 10 Jul 2023 12:30:37 -0400 Subject: [PATCH 3/9] test add Example via url (and tidy up dup tests) --- test/new.jl | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/test/new.jl b/test/new.jl index bca827e8ce..48a5fe29ba 100644 --- a/test/new.jl +++ b/test/new.jl @@ -2690,19 +2690,20 @@ end @testset "downloads" begin for v in (nothing, "true") withenv("JULIA_PKG_USE_CLI_GIT" => v) do - # libgit2 downloads - isolate() do - Pkg.add("Example"; use_git_for_all_downloads=true) - @test haskey(Pkg.dependencies(), exuuid) - @eval import $(Symbol(TEST_PKG.name)) - @test_throws SystemError open(pathof(eval(Symbol(TEST_PKG.name))), "w") do io end # check read-only - Pkg.rm(TEST_PKG.name) - end isolate() do @testset "libgit2 downloads" begin - Pkg.add(TEST_PKG.name; use_git_for_all_downloads=true) - @test haskey(Pkg.dependencies(), TEST_PKG.uuid) - Pkg.rm(TEST_PKG.name) + @testset "via name" begin + Pkg.add(TEST_PKG.name; use_git_for_all_downloads=true) + @test haskey(Pkg.dependencies(), TEST_PKG.uuid) + @eval import $(Symbol(TEST_PKG.name)) + @test_throws SystemError open(pathof(eval(Symbol(TEST_PKG.name))), "w") do io end # check read-only + Pkg.rm(TEST_PKG.name) + end + @testset "via url" begin + Pkg.add(url=TEST_PKG.url; use_git_for_all_downloads=true) + @test haskey(Pkg.dependencies(), TEST_PKG.uuid) + Pkg.rm(TEST_PKG.name) + end end @testset "libgit2 failures" begin doesnotexist = "https://github.com/DoesNotExist/DoesNotExist.jl" From d2df396d7b045145931561bd7dc120775832ccb0 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Mon, 10 Jul 2023 16:23:01 -0400 Subject: [PATCH 4/9] fixes & test tidy --- test/new.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/new.jl b/test/new.jl index 48a5fe29ba..f9cd39e90b 100644 --- a/test/new.jl +++ b/test/new.jl @@ -2687,9 +2687,9 @@ end # # Other # # Note: these tests should be run on clean depots -@testset "downloads" begin - for v in (nothing, "true") - withenv("JULIA_PKG_USE_CLI_GIT" => v) do +for v in (nothing, "true") + withenv("JULIA_PKG_USE_CLI_GIT" => v) do + @testset "downloads" begin isolate() do @testset "libgit2 downloads" begin @testset "via name" begin @@ -2700,7 +2700,7 @@ end Pkg.rm(TEST_PKG.name) end @testset "via url" begin - Pkg.add(url=TEST_PKG.url; use_git_for_all_downloads=true) + Pkg.add(url="https://github.com/JuliaLang/Example.jl", use_git_for_all_downloads=true) @test haskey(Pkg.dependencies(), TEST_PKG.uuid) Pkg.rm(TEST_PKG.name) end From e1691aa938dfdad84132a4a5291d7d0743c587b0 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Mon, 10 Jul 2023 17:03:48 -0400 Subject: [PATCH 5/9] fix testset name --- test/new.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/new.jl b/test/new.jl index f9cd39e90b..60c7dba712 100644 --- a/test/new.jl +++ b/test/new.jl @@ -2689,7 +2689,7 @@ end # Note: these tests should be run on clean depots for v in (nothing, "true") withenv("JULIA_PKG_USE_CLI_GIT" => v) do - @testset "downloads" begin + @testset "downloads with JULIA_PKG_USE_CLI_GIT = $v" begin isolate() do @testset "libgit2 downloads" begin @testset "via name" begin From 3acfb98fb0633d7c8d492a951183db2d629abb46 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Mon, 10 Jul 2023 23:24:56 -0400 Subject: [PATCH 6/9] set GIT_TERMINAL_PROMPT = 0 --- test/new.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/new.jl b/test/new.jl index 60c7dba712..25058ee071 100644 --- a/test/new.jl +++ b/test/new.jl @@ -2688,7 +2688,7 @@ end # # Note: these tests should be run on clean depots for v in (nothing, "true") - withenv("JULIA_PKG_USE_CLI_GIT" => v) do + withenv("JULIA_PKG_USE_CLI_GIT" => v, "GIT_TERMINAL_PROMPT" => 0) do @testset "downloads with JULIA_PKG_USE_CLI_GIT = $v" begin isolate() do @testset "libgit2 downloads" begin From eb18656405ed600d343f333690877a9f35375637 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Fri, 14 Jul 2023 09:13:48 -0400 Subject: [PATCH 7/9] don't test git cli with urls on windows --- test/new.jl | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/test/new.jl b/test/new.jl index 25058ee071..31467cb76d 100644 --- a/test/new.jl +++ b/test/new.jl @@ -2699,16 +2699,22 @@ for v in (nothing, "true") @test_throws SystemError open(pathof(eval(Symbol(TEST_PKG.name))), "w") do io end # check read-only Pkg.rm(TEST_PKG.name) end - @testset "via url" begin - Pkg.add(url="https://github.com/JuliaLang/Example.jl", use_git_for_all_downloads=true) - @test haskey(Pkg.dependencies(), TEST_PKG.uuid) - Pkg.rm(TEST_PKG.name) + if (Base.get_bool_env("JULIA_PKG_USE_CLI_GIT", false) && Base.iswindows()) == false + # TODO: fix. on GH windows runners cli git will prompt for credentials here + @testset "via url" begin + Pkg.add(url="https://github.com/JuliaLang/Example.jl", use_git_for_all_downloads=true) + @test haskey(Pkg.dependencies(), TEST_PKG.uuid) + Pkg.rm(TEST_PKG.name) + end end end - @testset "libgit2 failures" begin - doesnotexist = "https://github.com/DoesNotExist/DoesNotExist.jl" - @test_throws Pkg.Types.PkgError Pkg.add(url=doesnotexist, use_git_for_all_downloads=true) - @test_throws Pkg.Types.PkgError Pkg.Registry.add(Pkg.RegistrySpec(url=doesnotexist)) + if (Base.get_bool_env("JULIA_PKG_USE_CLI_GIT", false) && Base.iswindows()) == false + # TODO: fix. on GH windows runners cli git will prompt for credentials here + @testset "libgit2 failures" begin + doesnotexist = "https://github.com/DoesNotExist/DoesNotExist.jl" + @test_throws Pkg.Types.PkgError Pkg.add(url=doesnotexist, use_git_for_all_downloads=true) + @test_throws Pkg.Types.PkgError Pkg.Registry.add(Pkg.RegistrySpec(url=doesnotexist)) + end end @testset "tarball downloads" begin Pkg.add("JSON"; use_only_tarballs_for_downloads=true) From d480065269a9085efac895795c4ac372880f0289 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Fri, 14 Jul 2023 21:02:25 -0400 Subject: [PATCH 8/9] fixes --- .github/workflows/test.yml | 2 +- test/new.jl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c03c8fd4c3..bf226a78df 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -61,7 +61,7 @@ jobs: - run: julia --project --color=yes --check-bounds=yes -e 'import Pkg; Pkg.build(); Pkg.test(; coverage=true)' env: JULIA_PKG_SERVER: ${{ matrix.pkg-server }} - JULIA_PKG_TEST_QUIET: "false" # "true" is the default. i.e. tests are quiet when this env var isn't set + JULIA_PKG_TEST_QUIET: "true" # "true" is the default. i.e. tests are quiet when this env var isn't set - uses: julia-actions/julia-processcoverage@v1 env: JULIA_PKG_SERVER: ${{ matrix.pkg-server }} diff --git a/test/new.jl b/test/new.jl index 31467cb76d..502ce3fee5 100644 --- a/test/new.jl +++ b/test/new.jl @@ -2699,7 +2699,7 @@ for v in (nothing, "true") @test_throws SystemError open(pathof(eval(Symbol(TEST_PKG.name))), "w") do io end # check read-only Pkg.rm(TEST_PKG.name) end - if (Base.get_bool_env("JULIA_PKG_USE_CLI_GIT", false) && Base.iswindows()) == false + if (Base.get_bool_env("JULIA_PKG_USE_CLI_GIT", false) && Sys.iswindows()) == false # TODO: fix. on GH windows runners cli git will prompt for credentials here @testset "via url" begin Pkg.add(url="https://github.com/JuliaLang/Example.jl", use_git_for_all_downloads=true) @@ -2708,7 +2708,7 @@ for v in (nothing, "true") end end end - if (Base.get_bool_env("JULIA_PKG_USE_CLI_GIT", false) && Base.iswindows()) == false + if (Base.get_bool_env("JULIA_PKG_USE_CLI_GIT", false) && Sys.iswindows()) == false # TODO: fix. on GH windows runners cli git will prompt for credentials here @testset "libgit2 failures" begin doesnotexist = "https://github.com/DoesNotExist/DoesNotExist.jl" From 397027715abf0bd5906b42c226b72461a1c46593 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Sun, 16 Jul 2023 19:55:58 -0400 Subject: [PATCH 9/9] more fix --- test/new.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/new.jl b/test/new.jl index 502ce3fee5..0062a8e98b 100644 --- a/test/new.jl +++ b/test/new.jl @@ -2708,7 +2708,7 @@ for v in (nothing, "true") end end end - if (Base.get_bool_env("JULIA_PKG_USE_CLI_GIT", false) && Sys.iswindows()) == false + if !Sys.iswindows() # TODO: fix. on GH windows runners cli git will prompt for credentials here @testset "libgit2 failures" begin doesnotexist = "https://github.com/DoesNotExist/DoesNotExist.jl"