Skip to content
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

Add test_arg input and populate to test_args in test() #73

Merged
merged 3 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_arg` 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_arg: 'only_fast_tests'
# ...
```

The value of `test_arg` 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_arg:
description: 'Argument string that is passed on to test.'
default: ''
IanButterworth marked this conversation as resolved.
Show resolved Hide resolved

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_ARG: ${{ inputs.test_arg }}
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_arg::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_arg != "" # avoid ambiguity by empty string in test_args
kwargs_dict[:test_args] = [test_arg]
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_arg=ENV["TEST_ARG"],
)

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