haskell-stack-test: add haskell tool stack test
This change adds a new job to test stack based haskell project. Change-Id: Ie3492097b351eec743d98e9ca8bc693c00c11a78
This commit is contained in:
parent
64b347fa63
commit
cf64b73f78
@ -2,4 +2,5 @@ Haskell Jobs
|
|||||||
============
|
============
|
||||||
|
|
||||||
.. zuul:autojob:: cabal-test
|
.. zuul:autojob:: cabal-test
|
||||||
|
.. zuul:autojob:: haskell-stack-test
|
||||||
.. zuul:autojob:: hlint
|
.. zuul:autojob:: hlint
|
||||||
|
@ -4,5 +4,7 @@ Haskell Roles
|
|||||||
.. zuul:autorole:: ensure-cabal
|
.. zuul:autorole:: ensure-cabal
|
||||||
.. zuul:autorole:: ensure-ghc
|
.. zuul:autorole:: ensure-ghc
|
||||||
.. zuul:autorole:: ensure-hlint
|
.. zuul:autorole:: ensure-hlint
|
||||||
|
.. zuul:autorole:: ensure-haskell-stack
|
||||||
.. zuul:autorole:: cabal-test
|
.. zuul:autorole:: cabal-test
|
||||||
|
.. zuul:autorole:: haskell-stack-test
|
||||||
.. zuul:autorole:: hlint
|
.. zuul:autorole:: hlint
|
||||||
|
3
playbooks/haskell/pre-stack.yaml
Normal file
3
playbooks/haskell/pre-stack.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
- hosts: all
|
||||||
|
roles:
|
||||||
|
- ensure-haskell-stack
|
3
playbooks/haskell/stack.yaml
Normal file
3
playbooks/haskell/stack.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
- hosts: all
|
||||||
|
roles:
|
||||||
|
- haskell-stack-test
|
10
roles/ensure-haskell-stack/README.rst
Normal file
10
roles/ensure-haskell-stack/README.rst
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
Ensure the Haskell tool stack is installed.
|
||||||
|
|
||||||
|
Installs the specified stack version and setup the toolchain.
|
||||||
|
This role uses the Fedora copr package.
|
||||||
|
|
||||||
|
**Role Variables**
|
||||||
|
|
||||||
|
.. zuul:rolevar:: lts_version
|
||||||
|
|
||||||
|
The lts version.
|
1
roles/ensure-haskell-stack/defaults/main.yaml
Normal file
1
roles/ensure-haskell-stack/defaults/main.yaml
Normal file
@ -0,0 +1 @@
|
|||||||
|
lts_version: ""
|
28
roles/ensure-haskell-stack/tasks/main.yaml
Normal file
28
roles/ensure-haskell-stack/tasks/main.yaml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
- name: Make sure the role is run on Fedora
|
||||||
|
fail:
|
||||||
|
msg: "This role supports Fedora only"
|
||||||
|
when: "ansible_distribution != 'Fedora'"
|
||||||
|
|
||||||
|
- name: Check stack version
|
||||||
|
command: stack --version
|
||||||
|
failed_when: false
|
||||||
|
register: _stack_version
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Install stack copr
|
||||||
|
command: dnf copr enable -y petersen/stack2
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Install stack
|
||||||
|
package:
|
||||||
|
name: stack
|
||||||
|
state: present
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Upgrade stack
|
||||||
|
command: stack upgrade
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Setup stack LTS
|
||||||
|
command: "stack {% if lts_version %}--resolver {{ lts_version }}{% endif %} setup"
|
||||||
|
when: _stack_version.rc != 0
|
12
roles/haskell-stack-test/README.rst
Normal file
12
roles/haskell-stack-test/README.rst
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
Run the Haskell stack test command.
|
||||||
|
|
||||||
|
**Role Variables**
|
||||||
|
|
||||||
|
.. zuul:rolevar:: lts_version
|
||||||
|
|
||||||
|
The lts version.
|
||||||
|
|
||||||
|
.. zuul:rolevar:: zuul_work_dir
|
||||||
|
:default: {{ zuul.project.src_dir }}
|
||||||
|
|
||||||
|
Directory to run the cabal command in.
|
2
roles/haskell-stack-test/defaults/main.yaml
Normal file
2
roles/haskell-stack-test/defaults/main.yaml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
lts_version: ""
|
||||||
|
zuul_work_dir: "{{ zuul.project.src_dir }}"
|
4
roles/haskell-stack-test/tasks/main.yaml
Normal file
4
roles/haskell-stack-test/tasks/main.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
- name: Run stack test
|
||||||
|
command: "stack {% if lts_version %}--resolver {{ lts_version }}{% endif %} test"
|
||||||
|
args:
|
||||||
|
chdir: "{{ zuul_work_dir }}"
|
7
test-playbooks/haskell/setup-stack-project.yaml
Normal file
7
test-playbooks/haskell/setup-stack-project.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
- hosts: all
|
||||||
|
tasks:
|
||||||
|
- name: Setup file
|
||||||
|
command: stack new new-project
|
||||||
|
|
||||||
|
- name: Copy file over zuul-jobs
|
||||||
|
command: rsync -a new-project/ "{{ zuul.project.src_dir }}/"
|
@ -14,6 +14,21 @@
|
|||||||
- name: fedora-31
|
- name: fedora-31
|
||||||
label: fedora-31
|
label: fedora-31
|
||||||
|
|
||||||
|
- job:
|
||||||
|
name: zuul-jobs-test-haskell-stack-test
|
||||||
|
description: Test the haskell-stack-test job and roles
|
||||||
|
parent: haskell-stack-test
|
||||||
|
files:
|
||||||
|
- playbooks/haskell/stack.yaml
|
||||||
|
- playbooks/haskell/pre-stack.yaml
|
||||||
|
- roles/ensure-haskell-stack/.*
|
||||||
|
- roles/haskell-stack-test/.*
|
||||||
|
pre-run: test-playbooks/haskell/setup-stack-project.yaml
|
||||||
|
nodeset:
|
||||||
|
nodes:
|
||||||
|
- name: fedora-31
|
||||||
|
label: fedora-31
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: zuul-jobs-test-hlint
|
name: zuul-jobs-test-hlint
|
||||||
description: Test the hlint job and roles
|
description: Test the hlint job and roles
|
||||||
@ -35,6 +50,7 @@
|
|||||||
check:
|
check:
|
||||||
jobs: &id001
|
jobs: &id001
|
||||||
- zuul-jobs-test-cabal-test
|
- zuul-jobs-test-cabal-test
|
||||||
|
- zuul-jobs-test-haskell-stack-test
|
||||||
- zuul-jobs-test-hlint
|
- zuul-jobs-test-hlint
|
||||||
gate:
|
gate:
|
||||||
jobs: *id001
|
jobs: *id001
|
||||||
|
@ -13,6 +13,19 @@
|
|||||||
vars:
|
vars:
|
||||||
ghc_version: latest
|
ghc_version: latest
|
||||||
|
|
||||||
|
- job:
|
||||||
|
name: haskell-stack-test
|
||||||
|
description: |
|
||||||
|
Run stack test for a Haskell project.
|
||||||
|
|
||||||
|
.. zuul:jobvar:: lts_version
|
||||||
|
|
||||||
|
Use the specified lts version.
|
||||||
|
run: playbooks/haskell/stack.yaml
|
||||||
|
pre-run: playbooks/haskell/pre-stack.yaml
|
||||||
|
vars:
|
||||||
|
ghc_version: latest
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: hlint
|
name: hlint
|
||||||
description: |
|
description: |
|
||||||
|
Loading…
Reference in New Issue
Block a user