diff --git a/roles/cabal-test/README.rst b/roles/cabal-test/README.rst index 523a52b61..a546de0a9 100644 --- a/roles/cabal-test/README.rst +++ b/roles/cabal-test/README.rst @@ -2,6 +2,10 @@ Run the cabal test command. **Role Variables** +.. zuul:rolevar:: cabal_target + + The cabal target(s) to test. + .. zuul:rolevar:: zuul_work_dir :default: {{ zuul.project.src_dir }} diff --git a/roles/cabal-test/defaults/main.yaml b/roles/cabal-test/defaults/main.yaml index 9739eb171..7065db023 100644 --- a/roles/cabal-test/defaults/main.yaml +++ b/roles/cabal-test/defaults/main.yaml @@ -1 +1,7 @@ +cabal_target: "" + zuul_work_dir: "{{ zuul.project.src_dir }}" + +_cabal_install_args: "--only-dependencies {{ cabal_target }}" +_cabal_build_args: "--enable-tests {{ cabal_target }}" +_cabal_test_args: "{{ cabal_target }}" diff --git a/roles/cabal-test/tasks/main.yaml b/roles/cabal-test/tasks/main.yaml index 7d3274913..0b8d51f58 100644 --- a/roles/cabal-test/tasks/main.yaml +++ b/roles/cabal-test/tasks/main.yaml @@ -1,19 +1,14 @@ -- name: Run cabal install --only-dependencies - command: cabal install --only-dependencies +- name: Run cabal install {{ _cabal_install_args }} + command: "cabal install {{ _cabal_install_args }}" args: chdir: "{{ zuul_work_dir }}" -- name: Run cabal configure --enable-test - command: cabal configure --enable-test +- name: Run cabal build {{ _cabal_build_args }} + command: "cabal build {{ _cabal_build_args }}" args: chdir: "{{ zuul_work_dir }}" -- name: Run cabal build - command: cabal build - args: - chdir: "{{ zuul_work_dir }}" - -- name: Run cabal test - command: cabal test +- name: Run cabal test {{ _cabal_test_args }} + command: "cabal test {{ _cabal_test_args }}" args: chdir: "{{ zuul_work_dir }}" diff --git a/roles/ensure-cabal/README.rst b/roles/ensure-cabal/README.rst index a97d4e81a..a8d3c88ee 100644 --- a/roles/ensure-cabal/README.rst +++ b/roles/ensure-cabal/README.rst @@ -2,3 +2,4 @@ Ensure cabal is installed This role installs the cabal-install package and ensures the hackage packages list exists. +This role uses the Fedora copr package. diff --git a/roles/ensure-cabal/tasks/main.yaml b/roles/ensure-cabal/tasks/main.yaml index 9b6cf95cf..7dce0911e 100644 --- a/roles/ensure-cabal/tasks/main.yaml +++ b/roles/ensure-cabal/tasks/main.yaml @@ -1,14 +1,24 @@ +- name: Make sure the role is run on Fedora + fail: + msg: "This role supports Fedora only" + when: "ansible_distribution != 'Fedora'" + - name: Check cabal version command: cabal --version failed_when: false register: _cabal_version -- name: Install cabal - package: - name: cabal-install - state: present - become: yes - when: "_cabal_version.rc != 0" +- block: + - name: Install cabal copr + command: dnf copr enable -y petersen/cabal-install + become: true + + - name: Install cabal + package: + name: cabal-install + state: present + become: true + when: _cabal_version.rc != 0 - name: Check package stat: diff --git a/zuul.d/haskell-jobs.yaml b/zuul.d/haskell-jobs.yaml index 6f60e8d0d..3be089f84 100644 --- a/zuul.d/haskell-jobs.yaml +++ b/zuul.d/haskell-jobs.yaml @@ -5,6 +5,10 @@ Responds to these variables: + .. zuul:jobvar:: cabal_target + + The cabal target(s) to test. + .. zuul:jobvar:: ghc_version Use the specified ghc version (``latest`` picks the latest).