From 252d4686a50ca4e21207e09c8ec7b2907867a4f5 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Tue, 20 Dec 2022 05:52:13 -0500 Subject: [PATCH] Fix add_general_registry (#28) --- .github/workflows/ci.yml | 6 +++- action.yml | 8 +---- ...try.jl => add_general_registry.buildpkg.jl | 31 +++++++++++++------ 3 files changed, 28 insertions(+), 17 deletions(-) rename add_general_registry.jl => add_general_registry.buildpkg.jl (63%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07a018e..5bff194 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,6 @@ on: jobs: test: - name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -31,6 +30,9 @@ jobs: arch: - x64 - x86 + pkg-server: + - "" + - "pkg.julialang.org" # 32-bit Julia binaries are not available on macOS exclude: - os: macOS-latest @@ -68,6 +70,8 @@ jobs: ${{ runner.os }}- - uses: ./.github/actions/julia-buildpkg + env: + JULIA_PKG_SERVER: ${{ matrix.pkg-server }} - uses: julia-actions/julia-runtest@v1 diff --git a/action.yml b/action.yml index a66ea0a..b3aab38 100644 --- a/action.yml +++ b/action.yml @@ -25,14 +25,8 @@ runs: # * https://github.com/JuliaLang/Pkg.jl/issues/2011 # * https://github.com/JuliaRegistries/General/issues/16777 # * https://github.com/JuliaPackaging/PkgServer.jl/issues/60 - - run: julia --color=yes "$GITHUB_ACTION_PATH"/add_general_registry.jl + - run: julia --color=yes "$GITHUB_ACTION_PATH"/add_general_registry.buildpkg.jl shell: bash - env: - # We set `JULIA_PKG_SERVER` only for this step to enforce - # `Pkg.Registry.add` to use Git. This way, Pkg.jl can send - # the request metadata to pkg.julialang.org when installing - # packages via `Pkg.test`. - JULIA_PKG_SERVER: "" - run: julia --color=yes --project=${{ inputs.project }} -e 'using Pkg; if VERSION >= v"1.1.0-rc1"; Pkg.build(verbose=true); else Pkg.build(); end' shell: bash diff --git a/add_general_registry.jl b/add_general_registry.buildpkg.jl similarity index 63% rename from add_general_registry.jl rename to add_general_registry.buildpkg.jl index fce71d8..40446ca 100644 --- a/add_general_registry.jl +++ b/add_general_registry.buildpkg.jl @@ -18,22 +18,35 @@ function general_registry_exists() if isfile(general_registry_tarball) && isfile(registry_toml_file) return true end + general_registry_dir, registry_toml_file = cloned_general_registry_location() - if !isdir(general_registry_dir) - return false - elseif !isfile(registry_toml_file) - return false - else + if isdir(general_registry_dir) && isfile(registry_toml_file) return true end + + return false end function add_general_registry() - @info("Attempting to clone the General registry") - general_registry_dir, registry_toml_file = general_registry_location() + @info("Attempting to install the General registry") + + general_registry_tarball, registry_toml_file = tarball_general_registry_location() + rm(general_registry_tarball; force = true, recursive = true) + rm(registry_toml_file; force = true, recursive = true) + + general_registry_dir, registry_toml_file = cloned_general_registry_location() rm(general_registry_dir; force = true, recursive = true) - Pkg.Registry.add("General") - isfile(registry_toml_file) || throw(ErrorException("the Registry.toml file does not exist")) + + # If not already set, We set `JULIA_PKG_SERVER` to enforce + # `Pkg.Registry.add` to use Git. This way, Pkg.jl can send + # the request metadata to pkg.julialang.org when installing + # packages via `Pkg.test`. + pkg_server = get(ENV, "JULIA_PKG_SERVER", "") + withenv("JULIA_PKG_SERVER" => pkg_server) do + Pkg.Registry.add("General") + end + + general_registry_exists() || throw(ErrorException("The Registry was not intalled properly")) return nothing end