-
Notifications
You must be signed in to change notification settings - Fork 31
Add the force_latest_compatible_version input, and add the "auto-detect Dependabot/CompatHelper" functionality
#20
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
Changes from 1 commit
4e2b021
790be2f
dd8c4ad
770d141
d928f49
9be550b
78c6039
7d93fe6
1132bc0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
force_latest_compatible_version input, and add the "auto-de…
…tect Dependabot/CompatHelper" functionality
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,9 @@ inputs: | |
| depwarn: | ||
| description: 'Value passed to the --depwarn flag. Options: yes | no | error. Default value: yes.' | ||
| default: 'yes' | ||
| force_latest_compatible_version: | ||
| description: 'If true, then, for each `[compat]` entry in the active project, only the latest compatible version will be allowed. Options: true | false | auto. Default value: auto. If the value is auto, then force_latest_compatible_version will be set to true if this is a Dependabot/CompatHelper pull request, and false otherwise.' | ||
| default: 'auto' | ||
| inline: | ||
| description: 'Value passed to the --inline flag. Options: yes | no. Default value: yes.' | ||
| default: 'yes' | ||
|
|
@@ -44,13 +47,18 @@ runs: | |
| # packages via `Pkg.test`. | ||
| JULIA_PKG_SERVER: "" | ||
| - run: | | ||
| # 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 }})' ) | ||
|
|
||
| # Add the prefix in front of the command if there is one | ||
| prefix="${{ inputs.prefix }}" | ||
| [[ -n $prefix ]] && julia_cmd=( "$prefix" "${julia_cmd[@]}" ) | ||
|
|
||
| # Run the Julia command | ||
| "${julia_cmd[@]}" | ||
| JULIA_CMD="julia" | ||
| PREFIX="${{ inputs.prefix }}" | ||
| [[ -n $PREFIX ]] && JULIA_CMD="$PREFIX $JULIA_CMD" | ||
| echo "JULIA_CMD=$JULIA_CMD" >> $GITHUB_ENV | ||
| shell: bash | ||
| - run: | | ||
| ${{ env.JULIA_CMD }} --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...)' | ||
|
||
| shell: bash | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| 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) | ||
| if startswith(branch_name, "refs/heads/") | ||
| return replace(branch_name, r"^(refs\/heads\/)" => "") | ||
| else | ||
| return branch_name | ||
| end | ||
DilumAluthge marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| module Kwargs | ||
|
|
||
| include(joinpath(@__DIR__, "autodetect-dependabot.jl")) | ||
|
|
||
| function kwargs(; coverage::Bool, | ||
| force_latest_compatible_version::Union{Bool, Symbol}) | ||
| is_dependabot_job = AutodetectDependabot.is_dependabot_job() | ||
| kwargs_dict = Dict{Symbol, Any}() | ||
| kwargs_dict[:coverage] = coverage | ||
|
|
||
| if !Sys.isapple() && VERSION >= v"1.7.0-" # TODO: delete this line | ||
DilumAluthge marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # if VERSION >= v"1.7.0-" # excludes 1.6, includes 1.7-DEV, includes 1.7 # TODO: uncomment this line | ||
| if force_latest_compatible_version isa Bool | ||
| kwargs_dict[:force_latest_compatible_version] = force_latest_compatible_version | ||
| elseif force_latest_compatible_version == :auto | ||
| if 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] = true | ||
| else | ||
| kwargs_dict[:force_latest_compatible_version] = false | ||
| end | ||
DilumAluthge marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| else | ||
| throw(ArgumentError("Invalid value for force_latest_compatible_version: $(force_latest_compatible_version)")) | ||
DilumAluthge marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| end | ||
| else | ||
| if force_latest_compatible_version != :auto | ||
| @warn( | ||
| "The `force_latest_compatible_version` option requires at least Julia 1.7", | ||
| VERSION, | ||
| force_latest_compatible_version, | ||
| ) | ||
DilumAluthge marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| end | ||
| end | ||
| return kwargs_dict | ||
DilumAluthge marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| end | ||
|
|
||
| end # module | ||
Uh oh!
There was an error while loading. Please reload this page.