mirror of
https://github.com/julia-actions/julia-runtest.git
synced 2026-02-11 18:46:55 +08:00
Add the force_latest_compatible_version input, and add the "auto-detect Dependabot/CompatHelper" functionality (#20)
Co-authored-by: Sascha Mann <git@mail.saschamann.eu>
This commit is contained in:
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2018-2020 GitHub, Inc., David Anthoff and contributors
|
Copyright (c) 2018-2021 GitHub, Inc., David Anthoff and contributors
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ inputs:
|
|||||||
depwarn:
|
depwarn:
|
||||||
description: 'Value passed to the --depwarn flag. Options: yes | no | error. Default value: yes.'
|
description: 'Value passed to the --depwarn flag. Options: yes | no | error. Default value: yes.'
|
||||||
default: 'yes'
|
default: 'yes'
|
||||||
|
force_latest_compatible_version:
|
||||||
|
description: 'If true, then, for each [compat] entry in the active project, only allow the latest compatible version. If the value is auto and the pull request has been opened by Dependabot or CompatHelper, then force_latest_compatible_version will be set to true, otherwise it will be set to false. Options: true | false | auto. Default value: auto.'
|
||||||
|
default: 'auto'
|
||||||
inline:
|
inline:
|
||||||
description: 'Value passed to the --inline flag. Options: yes | no. Default value: yes.'
|
description: 'Value passed to the --inline flag. Options: yes | no. Default value: yes.'
|
||||||
default: 'yes'
|
default: 'yes'
|
||||||
@@ -45,7 +48,7 @@ runs:
|
|||||||
JULIA_PKG_SERVER: ""
|
JULIA_PKG_SERVER: ""
|
||||||
- run: |
|
- run: |
|
||||||
# The Julia command that will be executed
|
# The Julia command that will be executed
|
||||||
julia_cmd=( julia --color=yes --check-bounds=yes --inline=${{ inputs.inline }} --depwarn=${{ inputs.depwarn }} --project=${{ inputs.project }} -e 'using Pkg; Pkg.test(coverage=${{ inputs.coverage }})' )
|
julia_cmd=( julia --check-bounds=yes --color=yes --depwarn=${{ inputs.depwarn }} --inline=${{ inputs.inline }} --project=${{ inputs.project }} -e 'import Pkg;include(joinpath(ENV["GITHUB_ACTION_PATH"], "kwargs.jl"));kwargs = Kwargs.kwargs(;coverage = :(${{ inputs.coverage }}),force_latest_compatible_version = :(${{ inputs.force_latest_compatible_version }}),);Pkg.test(; kwargs...)' )
|
||||||
|
|
||||||
# Add the prefix in front of the command if there is one
|
# Add the prefix in front of the command if there is one
|
||||||
prefix="${{ inputs.prefix }}"
|
prefix="${{ inputs.prefix }}"
|
||||||
|
|||||||
25
autodetect-dependabot.jl
Normal file
25
autodetect-dependabot.jl
Normal file
@@ -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
|
||||||
30
kwargs.jl
Normal file
30
kwargs.jl
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user