Allow control of --check-bounds command option (#46)

* allow control of bounds-check command option

* tryfix

* Update action.yml

Co-authored-by: Sascha Mann <git@mail.saschamann.eu>

* Update action.yml

Co-authored-by: Sascha Mann <git@mail.saschamann.eu>

* tryfix

* alternative bash if else approach

* another approach

* use julia_args approach

* add julia_args to kwargs func

* fix

* move julia_args to before return

* guard against v1.0

* add warning

* Update kwargs.jl

Co-authored-by: Sascha Mann <git@mail.saschamann.eu>

* handle the default state and improve error message

* Update kwargs.jl

Co-authored-by: Chris Foster <chris42f@gmail.com>

* Update kwargs.jl

Co-authored-by: Sascha Mann <git@mail.saschamann.eu>
Co-authored-by: Chris Foster <chris42f@gmail.com>
This commit is contained in:
Ian Butterworth
2021-12-22 09:00:07 -05:00
committed by GitHub
parent a5f2948fcb
commit 161c97cbc5
2 changed files with 14 additions and 2 deletions

View File

@@ -7,6 +7,9 @@ branding:
color: 'gray-dark' color: 'gray-dark'
inputs: inputs:
check_bounds:
description: 'Value determining which bounds checking setting to use. Options: yes | no | auto. Default value: yes.'
default: 'yes'
coverage: coverage:
description: 'Value determining whether to test with coverage or not. Options: true | false. Default value: true.' description: 'Value determining whether to test with coverage or not. Options: true | false. Default value: true.'
default: 'true' default: 'true'
@@ -48,7 +51,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 --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...)' ) julia_cmd=( julia --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 }}), julia_args = ["--check-bounds=${{ inputs.check_bounds }}"]);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 }}"

View File

@@ -5,7 +5,8 @@ import Pkg
include(joinpath(@__DIR__, "autodetect-dependabot.jl")) include(joinpath(@__DIR__, "autodetect-dependabot.jl"))
function kwargs(; coverage::Bool, function kwargs(; coverage::Bool,
force_latest_compatible_version::Union{Bool, Symbol}) force_latest_compatible_version::Union{Bool, Symbol},
julia_args::AbstractVector{<:AbstractString}=String[])
if !(force_latest_compatible_version isa Bool) && (force_latest_compatible_version != :auto) 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)")) throw(ArgumentError("Invalid value for force_latest_compatible_version: $(force_latest_compatible_version)"))
end end
@@ -13,6 +14,14 @@ function kwargs(; coverage::Bool,
kwargs_dict = Dict{Symbol, Any}() kwargs_dict = Dict{Symbol, Any}()
kwargs_dict[:coverage] = coverage kwargs_dict[:coverage] = coverage
if VERSION >= v"1.6.0"
kwargs_dict[:julia_args] = julia_args
elseif julia_args == ["--check-bounds=yes"]
# silently don't add this default julia_args value as < 1.6 doesn't support julia_args, but it's the default state
else
println("::warning::The Pkg.test bounds checking behavior cannot be changed before Julia 1.6. VERSION=$VERSION, julia_args=$julia_args")
end
if VERSION < v"1.7.0-" || !hasmethod(Pkg.Operations.test, Tuple{Pkg.Types.Context, Vector{Pkg.Types.PackageSpec}}, (:force_latest_compatible_version,)) if VERSION < v"1.7.0-" || !hasmethod(Pkg.Operations.test, Tuple{Pkg.Types.Context, Vector{Pkg.Types.PackageSpec}}, (:force_latest_compatible_version,))
(force_latest_compatible_version != :auto) && @warn("The `force_latest_compatible_version` option requires at least Julia 1.7", VERSION, force_latest_compatible_version) (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 return kwargs_dict