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

If the user does not specify the optional git_cli input, we should respect any pre-existing value of the JULIA_PKG_USE_CLI_GIT environment variable #39

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
36 changes: 25 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ inputs:
default: ''
git_cli:
description: 'Determine if Pkg uses the cli git executable (Julia >= 1.7). Might be necessary for more complicated SSH setups.
Options: true | false. Default : false'
default: 'false'
Options: true | false. If this input is provided, it will override any pre-existing value of the
JULIA_PKG_USE_CLI_GIT environment variable. If this input is not provided, and if the JULIA_PKG_USE_CLI_GIT
environnment is set, then that value will be respected. If this input is not provided, and if the
JULIA_PKG_USE_CLI_GIT environment variable is not set, then the default Julia behavior will be used.'
default: ''

runs:
using: 'composite'
Expand All @@ -30,30 +33,41 @@ runs:
shell: bash
- run: |
import Pkg

# Determine if Pkg uses git-cli executable instead of LibGit2
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)
# Determine if Pkg uses git-cli executable instead of LibGit2
#
# If the user does not provide the `git_cli` input, we want to make sure
# that we respect any pre-existing value of the `JULIA_PKG_USE_CLI_GIT`
# environment variable.
INPUT_GIT_CLI_str = strip(ENV["INPUT_GIT_CLI"])
if isempty(INPUT_GIT_CLI_str)
# Empty = user did not provide this input = we should do nothing.
else
# Non-empty = user provided this input = we enforce that it must be either
# `true` or `false`.
INPUT_GIT_CLI_b = parse(Bool, INPUT_GIT_CLI_str)
ENV["JULIA_PKG_USE_CLI_GIT"] = "$(INPUT_GIT_CLI_b)"
if (VERSION < v"1.7-") && INPUT_GIT_CLI_b
printstyled("::notice::JULIA_PKG_USE_CLI_GIT requires Julia >= 1.7. Using default LibGit2 git-interface instead! \n"; color = :yellow)
end
Comment on lines +42 to +52
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
INPUT_GIT_CLI_str = strip(ENV["INPUT_GIT_CLI"])
if isempty(INPUT_GIT_CLI_str)
# Empty = user did not provide this input = we should do nothing.
else
# Non-empty = user provided this input = we enforce that it must be either
# `true` or `false`.
INPUT_GIT_CLI_b = parse(Bool, INPUT_GIT_CLI_str)
ENV["JULIA_PKG_USE_CLI_GIT"] = "$(INPUT_GIT_CLI_b)"
if (VERSION < v"1.7-") && INPUT_GIT_CLI_b
printstyled("::notice::JULIA_PKG_USE_CLI_GIT requires Julia >= 1.7. Using default LibGit2 git-interface instead! \n"; color = :yellow)
end
git_cli = strip(ENV["INPUT_GIT_CLI"])
if !isempty(git_cli)
ENV["JULIA_PKG_USE_CLI_GIT"] = string(git_cli == "true")
if VERSION < v"1.7-" && git_cli == "true"
printstyled("::notice::JULIA_PKG_USE_CLI_GIT requires Julia >= 1.7. Using default LibGit2 git-interface instead! \n"; color = :yellow)
end

Alternatively, if we want to follow the original code's behavior where JULIA_PKG_USE_CLI_GIT is only set in Julia 1.7- and above we can do:

Suggested change
INPUT_GIT_CLI_str = strip(ENV["INPUT_GIT_CLI"])
if isempty(INPUT_GIT_CLI_str)
# Empty = user did not provide this input = we should do nothing.
else
# Non-empty = user provided this input = we enforce that it must be either
# `true` or `false`.
INPUT_GIT_CLI_b = parse(Bool, INPUT_GIT_CLI_str)
ENV["JULIA_PKG_USE_CLI_GIT"] = "$(INPUT_GIT_CLI_b)"
if (VERSION < v"1.7-") && INPUT_GIT_CLI_b
printstyled("::notice::JULIA_PKG_USE_CLI_GIT requires Julia >= 1.7. Using default LibGit2 git-interface instead! \n"; color = :yellow)
end
git_cli = strip(ENV["INPUT_GIT_CLI"])
if VERSION >= v"1.7-" && !isempty(git_cli)
ENV["JULIA_PKG_USE_CLI_GIT"] = string(git_cli == "true")
elseif VERSION < v"1.7-" && git_cli == "true"
printstyled("::notice::JULIA_PKG_USE_CLI_GIT requires Julia >= 1.7. Using default LibGit2 git-interface instead! \n"; color = :yellow)
end

end


if VERSION >= v"1.5-"
Pkg.Registry.add("General")

# If provided add local registries
if !isempty("${{ inputs.localregistry }}")
local_repos = split("${{ inputs.localregistry }}", "\n") .|> string
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
end
end

VERSION >= v"1.1.0-rc1" ? retry(Pkg.build)(verbose=true) : retry(Pkg.build)()
shell: julia --color=yes --project=${{ inputs.project }} {0}
env:
JULIA_PKG_PRECOMPILE_AUTO: "${{ inputs.precompile }}"
GITHUB_TOKEN: ${{ github.token }}
GITHUB_TOKEN: "${{ github.token }}"
INPUT_GIT_CLI: "${{ inputs.git_cli }}"