Skip to content

Commit

Permalink
allow passing multiple arguments in test_args (#118)
Browse files Browse the repository at this point in the history
Co-authored-by: Markus Hauru <[email protected]>
Co-authored-by: Ian Butterworth <[email protected]>
  • Loading branch information
3 people authored Oct 18, 2024
1 parent ed05f1e commit df05726
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ This will add the prefix `xvfb-run` to all builds where the `os` is `ubuntu-late

You can pass arguments from the workflow specification to the test script via the `test_args` parameter.

This is useful, for example, to specify separate workflows for fast and slow tests.
This is useful, for example, to specify separate workflows for fast and slow tests, or conditionally enabling quality assurance tests.

The functionality can be incorporated as follows:

Expand All @@ -101,7 +101,7 @@ The functionality can be incorporated as follows:
# ...
- uses: julia-actions/julia-runtest@v1
with:
test_args: 'only_fast_tests'
test_args: 'slow_tests "quality assurance"'
# ...
```

Expand All @@ -111,11 +111,17 @@ The value of `test_args` can be accessed in `runtest.jl` via the `ARGS` variable
using Test
# ...

if @isdefined(ARGS) && length(ARGS) > 0 && ARGS[1] == "only_fast_tests"
# run only fast tests
include("only_fast_tests.jl")
else
# do something else
# run fast tests by default
include("fast_tests.jl")

if "slow_tests" in ARGS
# run slow tests
include("slow_tests.jl")
end

if "quality assurance" in ARGS
# run quality assurance tests
include("qa.jl")
end
```

Expand Down
5 changes: 2 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ inputs:
description: 'Whether to allow re-resolving of package versions in the test environment. Only effective on Julia 1.9+. Options: true | false. Default value: true'
default: 'true'
test_args:
description: 'Argument string that is passed on to test.'
description: 'Arguments string that is passed on to test.'
default: ''

runs:
Expand All @@ -60,7 +60,7 @@ runs:
if: inputs.annotate == 'true'
- run: |
# The Julia command that will be executed
julia_cmd=( julia --color=yes --depwarn=${{ inputs.depwarn }} --inline=${{ inputs.inline }} --project=${{ inputs.project }} -e 'include(joinpath(ENV["GITHUB_ACTION_PATH"], "test_harness.jl"))' )
julia_cmd=( julia --color=yes --depwarn=${{ inputs.depwarn }} --inline=${{ inputs.inline }} --project=${{ inputs.project }} -e 'include(joinpath(ENV["GITHUB_ACTION_PATH"], "test_harness.jl"))' -- ${{inputs.test_args}} )
# Add the prefix in front of the command if there is one
prefix=( ${{ inputs.prefix }} )
Expand All @@ -77,4 +77,3 @@ runs:
CHECK_BOUNDS: ${{ inputs.check_bounds }}
COMPILED_MODULES: ${{ inputs.compiled_modules }}
ALLOW_RERESOLVE: ${{ inputs.allow_reresolve }}
TEST_ARGS: ${{ inputs.test_args }}
6 changes: 2 additions & 4 deletions kwargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function kwargs(; coverage,
force_latest_compatible_version,
allow_reresolve,
julia_args::AbstractVector{<:AbstractString}=String[],
test_args::AbstractString="",
test_args::AbstractVector{<:AbstractString}=String[],
)
if coverage isa AbstractString
coverage = parse(Bool, coverage)
Expand Down Expand Up @@ -58,9 +58,7 @@ function kwargs(; coverage,
kwargs_dict[:allow_reresolve] = parse(Bool, allow_reresolve)
end

if test_args != "" # avoid ambiguity by empty string in test_args
kwargs_dict[:test_args] = [test_args]
end
kwargs_dict[:test_args] = test_args

return kwargs_dict
end
Expand Down
2 changes: 1 addition & 1 deletion test_harness.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ kwargs = Kwargs.kwargs(; coverage=ENV["COVERAGE"],
allow_reresolve=ENV["ALLOW_RERESOLVE"],
julia_args=[string("--check-bounds=", ENV["CHECK_BOUNDS"]),
string("--compiled-modules=", ENV["COMPILED_MODULES"])],
test_args=ENV["TEST_ARGS"],
test_args=ARGS,
)

kwargs_reprs = map(kv -> string(kv[1], "=", repr(kv[2])), collect(kwargs))
Expand Down

0 comments on commit df05726

Please sign in to comment.