diff --git a/roles/haskell-stack-test/README.rst b/roles/haskell-stack-test/README.rst index 9a85a46b9..9e5277600 100644 --- a/roles/haskell-stack-test/README.rst +++ b/roles/haskell-stack-test/README.rst @@ -2,6 +2,10 @@ Run the Haskell stack test command. **Role Variables** +.. zuul:rolevar:: haskell_stack_target + + The stack target(s) to test. + .. zuul:rolevar:: lts_version The lts version. diff --git a/roles/haskell-stack-test/defaults/main.yaml b/roles/haskell-stack-test/defaults/main.yaml index d354a93e4..e9914cd4e 100644 --- a/roles/haskell-stack-test/defaults/main.yaml +++ b/roles/haskell-stack-test/defaults/main.yaml @@ -1,2 +1,7 @@ +haskell_stack_target: "" lts_version: "" zuul_work_dir: "{{ zuul.project.src_dir }}" + +_stack_resolver_args: "{% if lts_version %}--resolver {{ lts_version }}{% endif %}" +_stack_build_args: "{{ _stack_resolver_args }} --test --no-run-tests {{ haskell_stack_target }}" +_stack_test_args: "{{ _stack_resolver_args }} {{ haskell_stack_target }}" diff --git a/roles/haskell-stack-test/tasks/main.yaml b/roles/haskell-stack-test/tasks/main.yaml index 6fd4aad0e..55704bf2a 100644 --- a/roles/haskell-stack-test/tasks/main.yaml +++ b/roles/haskell-stack-test/tasks/main.yaml @@ -1,4 +1,9 @@ -- name: Run stack test - command: "stack {% if lts_version %}--resolver {{ lts_version }}{% endif %} test" +- name: Run stack build {{ _stack_build_args }} + command: "stack build {{ _stack_build_args }}" + args: + chdir: "{{ zuul_work_dir }}" + +- name: Run stack test {{ _stack_test_args }} + command: "stack test {{ _stack_test_args }}" args: chdir: "{{ zuul_work_dir }}" diff --git a/zuul.d/haskell-jobs.yaml b/zuul.d/haskell-jobs.yaml index 3be089f84..790ecb2ca 100644 --- a/zuul.d/haskell-jobs.yaml +++ b/zuul.d/haskell-jobs.yaml @@ -22,6 +22,10 @@ description: | Run stack test for a Haskell project. + .. zuul:jobvar:: haskell_stack_target + + The stack target(s) to test. + .. zuul:jobvar:: lts_version Use the specified lts version.