Skip to content
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

Add Julia registries only when not present #49

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
22 changes: 19 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- "main"
- "master"
paths-ignore:
- "README.md"
- "LICENSE"
Expand All @@ -17,10 +16,11 @@ jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
fail-fast: ${{ github.event_name == 'pull_request' }}
matrix:
version:
- "1.0"
- "1.6" # Long-term support (LTS) release of Julia
- "1" # automatically expands to the latest stable 1.x release of Julia
- nightly
os:
Expand All @@ -33,10 +33,15 @@ jobs:
pkg-server:
- ""
- "pkg.julialang.org"
# 32-bit Julia binaries are not available on macOS
exclude:
# 32-bit Julia binaries are not available on macOS
- os: macOS-latest
arch: x86
# Only Julia 1.7+ can use the package server
- version: "1.0"
pkg-server: "pkg.julialang.org"
- version: "1.6"
pkg-server: "pkg.julialang.org"

steps:
- name: Checkout Example.jl
Expand All @@ -61,9 +66,20 @@ jobs:
- uses: ./.github/actions/julia-buildpkg
with:
ignore-no-cache: true
localregistry: |
https://github.com/JuliaRegistries/General.git
env:
JULIA_PKG_SERVER: ${{ matrix.pkg-server }}

# When using the Pkg server the `Pkg.Registry.add("General")` will add the General registry
# via Pkg servers. Using `localregistry` to clone the General registry via HTTPS should be
# skipped.
- name: Test skipping registry cloning of duplicate repos
if: ${{ matrix.pkg-server == 'pkg.julialang.org' }}
shell: bash
run: |
! test -d $HOME/.julia/registries/General

- uses: julia-actions/julia-runtest@v1

- uses: julia-actions/julia-processcoverage@v1
Expand Down
30 changes: 21 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,31 @@ runs:
VERSION >= v"1.7-" && (ENV["JULIA_PKG_USE_CLI_GIT"] = ${{ inputs.git_cli }})

if VERSION < v"1.7-" && ${{ inputs.git_cli }} == true
printstyled("::notice::JULIA_PKG_USE_CLI_GIT requires Julia >= 1.7. Using default LibGit2 git-interface instead! \n"; color = :yellow)
printstyled("::notice::JULIA_PKG_USE_CLI_GIT requires Julia >= 1.7. Using default LibGit2 git-interface instead! \n"; color = :yellow)
end


if VERSION >= v"1.5-"
Pkg.Registry.add("General")
function reachable_registries()
return if VERSION >= v"1.7-"
Pkg.Registry.reachable_registries()
else
[(; name=r.name, repo=r.url) for r in Pkg.Types.collect_registries()]
end
end

if !any(r -> r.name == "General", reachable_registries())
Pkg.Registry.add("General")
end

# If provided add local registries
if !isempty("${{ inputs.localregistry }}")
local_repos = split("${{ inputs.localregistry }}", "\n") .|> string
for repo_url in local_repos
isempty(repo_url) && continue
Pkg.Registry.add(Pkg.RegistrySpec(; url = repo_url))
end
if !isempty(ENV["LOCAL_REGISTRY"])
local_repos = split(ENV["LOCAL_REGISTRY"], "\n"; keepempty=false) .|> string
for repo_url in local_repos
# https://github.com/JuliaLang/Pkg.jl/issues/3753
if !any(r -> r.repo == repo_url, reachable_registries())
Pkg.Registry.add(Pkg.RegistrySpec(; url = repo_url))
end
end
end
end

Expand All @@ -63,3 +74,4 @@ runs:
env:
JULIA_PKG_PRECOMPILE_AUTO: "${{ inputs.precompile }}"
GITHUB_TOKEN: ${{ github.token }}
LOCAL_REGISTRY: ${{ inputs.localregistry }}