Skip to content

Commit

Permalink
Add test_arg input and populate to test_args in test() (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
sschlenkrich authored Jul 23, 2024
1 parent d0c4f09 commit e164761
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,38 @@ If you only want to add this prefix on certain builds, you can [include addition

This will add the prefix `xvfb-run` to all builds where the `os` is `ubuntu-latest`.

### Pass Arguments to Test Suite

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.

The functionality can be incorporated as follows:

```yaml
# ...
steps:
# ...
- uses: julia-actions/julia-runtest@v1
with:
test_args: 'only_fast_tests'
# ...
```

The value of `test_args` can be accessed in `runtest.jl` via the `ARGS` variable. An example for `runtest.jl` is given below.

```julia
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
end
```


### Registry flavor preference

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ inputs:
allow_reresolve:
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.'
default: ''

runs:
using: 'composite'
Expand Down Expand Up @@ -74,3 +77,4 @@ runs:
CHECK_BOUNDS: ${{ inputs.check_bounds }}
COMPILED_MODULES: ${{ inputs.compiled_modules }}
ALLOW_RERESOLVE: ${{ inputs.allow_reresolve }}
TEST_ARGS: ${{ inputs.test_args }}
8 changes: 7 additions & 1 deletion kwargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ include(joinpath(@__DIR__, "autodetect-dependabot.jl"))
function kwargs(; coverage,
force_latest_compatible_version,
allow_reresolve,
julia_args::AbstractVector{<:AbstractString}=String[])
julia_args::AbstractVector{<:AbstractString}=String[],
test_args::AbstractString="",
)
if coverage isa AbstractString
coverage = parse(Bool, coverage)
end
Expand Down Expand Up @@ -55,6 +57,10 @@ function kwargs(; coverage,
if VERSION >= v"1.9"
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

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

if parse(Bool, ENV["ANNOTATE"]) && v"1.8pre" < VERSION < v"1.9.0-beta3"
push!(LOAD_PATH, "@tests-logger-env") # access dependencies
Expand Down

0 comments on commit e164761

Please sign in to comment.