generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the
force_latest_compatible_version
input, and add the "auto-de…
…tect Dependabot/CompatHelper" functionality (#20) Co-authored-by: Sascha Mann <git@mail.saschamann.eu>
- Loading branch information
1 parent
07b45fe
commit eda4346
Showing
4 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module AutodetectDependabot | ||
|
||
function _get_possible_branch_names() | ||
possible_branch_names = [ | ||
get(ENV, "GITHUB_BASE_REF", ""), | ||
get(ENV, "GITHUB_HEAD_REF", ""), | ||
get(ENV, "GITHUB_REF", ""), | ||
] | ||
return possible_branch_names | ||
end | ||
|
||
function _chop_refs_head(branch_name::AbstractString) | ||
replace(branch_name, r"^(refs\/heads\/)" => "") | ||
end | ||
|
||
function _is_dependabot_branch(branch_name::AbstractString) | ||
return startswith(branch_name, "dependabot/julia") || startswith(branch_name, "compathelper/") | ||
end | ||
|
||
function is_dependabot_job() | ||
possible_branch_names = _get_possible_branch_names() | ||
return any(_is_dependabot_branch.(_chop_refs_head.(possible_branch_names))) | ||
end | ||
|
||
end # module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module Kwargs | ||
|
||
include(joinpath(@__DIR__, "autodetect-dependabot.jl")) | ||
|
||
function kwargs(; coverage::Bool, | ||
force_latest_compatible_version::Union{Bool, Symbol}) | ||
if !(force_latest_compatible_version isa Bool) && (force_latest_compatible_version != :auto) | ||
throw(ArgumentError("Invalid value for force_latest_compatible_version: $(force_latest_compatible_version)")) | ||
end | ||
|
||
kwargs_dict = Dict{Symbol, Any}() | ||
kwargs_dict[:coverage] = coverage | ||
|
||
if VERSION < v"1.7.0-" | ||
(force_latest_compatible_version != :auto) && @warn("The `force_latest_compatible_version` option requires at least Julia 1.7", VERSION, force_latest_compatible_version) | ||
return kwargs_dict | ||
end | ||
|
||
if force_latest_compatible_version == :auto | ||
is_dependabot_job = AutodetectDependabot.is_dependabot_job() | ||
is_dependabot_job && @info("This is a Dependabot/CompatHelper job, so `force_latest_compatible_version` has been set to `true`") | ||
kwargs_dict[:force_latest_compatible_version] = is_dependabot_job | ||
else | ||
kwargs_dict[:force_latest_compatible_version] = force_latest_compatible_version::Bool | ||
end | ||
|
||
return kwargs_dict | ||
end | ||
|
||
end # module |