haskell-stack-test: add build target job variable

This change adds support for custom target and adds a
separate build step to better report build failure, as
opposed to a single test failure.

Change-Id: I9e7a5e14b669dcbacd26861595358f6a4c04b585
This commit is contained in:
Tristan Cacqueray 2020-05-08 00:07:03 +00:00
parent 7fdf0cc3ab
commit 16673b8dc1
4 changed files with 20 additions and 2 deletions

View File

@ -2,6 +2,10 @@ Run the Haskell stack test command.
**Role Variables** **Role Variables**
.. zuul:rolevar:: haskell_stack_target
The stack target(s) to test.
.. zuul:rolevar:: lts_version .. zuul:rolevar:: lts_version
The lts version. The lts version.

View File

@ -1,2 +1,7 @@
haskell_stack_target: ""
lts_version: "" lts_version: ""
zuul_work_dir: "{{ zuul.project.src_dir }}" 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 }}"

View File

@ -1,4 +1,9 @@
- name: Run stack test - name: Run stack build {{ _stack_build_args }}
command: "stack {% if lts_version %}--resolver {{ lts_version }}{% endif %} test" 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: args:
chdir: "{{ zuul_work_dir }}" chdir: "{{ zuul_work_dir }}"

View File

@ -22,6 +22,10 @@
description: | description: |
Run stack test for a Haskell project. Run stack test for a Haskell project.
.. zuul:jobvar:: haskell_stack_target
The stack target(s) to test.
.. zuul:jobvar:: lts_version .. zuul:jobvar:: lts_version
Use the specified lts version. Use the specified lts version.