From 16673b8dc13edd3ee45dcea08377fdf5760771d8 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Fri, 8 May 2020 00:07:03 +0000 Subject: [PATCH] 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 --- roles/haskell-stack-test/README.rst | 4 ++++ roles/haskell-stack-test/defaults/main.yaml | 5 +++++ roles/haskell-stack-test/tasks/main.yaml | 9 +++++++-- zuul.d/haskell-jobs.yaml | 4 ++++ 4 files changed, 20 insertions(+), 2 deletions(-) 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.