From 00a320bfe34c2410b828128254a53a6459777559 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Tue, 14 Nov 2023 18:00:54 -0500 Subject: [PATCH 1/4] 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 --- action.yml | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/action.yml b/action.yml index 0e518b6..a7093d0 100644 --- a/action.yml +++ b/action.yml @@ -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' @@ -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-" + 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 }})" From f01cb2c2000265c3e05ce2c7e8acfdabba6e8bc1 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Tue, 14 Nov 2023 18:05:14 -0500 Subject: [PATCH 2/4] Fix syntax --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index a7093d0..dd5cca8 100644 --- a/action.yml +++ b/action.yml @@ -39,7 +39,7 @@ runs: # 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"])) + 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 From 9e7122aae26f97d503c152c2d1c0037cae6f96e0 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Tue, 14 Nov 2023 18:07:12 -0500 Subject: [PATCH 3/4] Fix a typo --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index dd5cca8..994be51 100644 --- a/action.yml +++ b/action.yml @@ -70,4 +70,4 @@ runs: env: JULIA_PKG_PRECOMPILE_AUTO: "${{ inputs.precompile }}" GITHUB_TOKEN: "${{ github.token }}" - INPUT_GIT_CLI: "${{ inputs.git_cli }})" + INPUT_GIT_CLI: "${{ inputs.git_cli }}" From a432b34dc13efa4036e3b231b5ed4c911a391064 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Tue, 14 Nov 2023 18:22:58 -0500 Subject: [PATCH 4/4] Don't print the warning if the user-provided `git_cli` input is set to `false` --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 994be51..2d6f7dc 100644 --- a/action.yml +++ b/action.yml @@ -47,7 +47,7 @@ runs: # `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-" + 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 end