cabal-test: add initial haskell job
This change adds a new job to test cabal based haskell project. Change-Id: Idb24eb5f8f9bd1409bae07bf4da415f1d05568e4
This commit is contained in:
parent
b3358c7559
commit
d92b39cae2
4
doc/source/haskell-jobs.rst
Normal file
4
doc/source/haskell-jobs.rst
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Haskell Jobs
|
||||||
|
============
|
||||||
|
|
||||||
|
.. zuul:autojob:: cabal-test
|
6
doc/source/haskell-roles.rst
Normal file
6
doc/source/haskell-roles.rst
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
Haskell Roles
|
||||||
|
=============
|
||||||
|
|
||||||
|
.. zuul:autorole:: ensure-cabal
|
||||||
|
.. zuul:autorole:: ensure-ghc
|
||||||
|
.. zuul:autorole:: cabal-test
|
@ -9,6 +9,7 @@ Jobs
|
|||||||
js-jobs
|
js-jobs
|
||||||
docker-jobs
|
docker-jobs
|
||||||
go-jobs
|
go-jobs
|
||||||
|
haskell-jobs
|
||||||
helm-jobs
|
helm-jobs
|
||||||
packer-jobs
|
packer-jobs
|
||||||
system-jobs
|
system-jobs
|
||||||
|
@ -15,6 +15,7 @@ Roles
|
|||||||
deprecated-roles
|
deprecated-roles
|
||||||
galaxy-roles
|
galaxy-roles
|
||||||
go-roles
|
go-roles
|
||||||
|
haskell-roles
|
||||||
helm-roles
|
helm-roles
|
||||||
java-roles
|
java-roles
|
||||||
js-roles
|
js-roles
|
||||||
|
3
playbooks/haskell/cabal.yaml
Normal file
3
playbooks/haskell/cabal.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
- hosts: all
|
||||||
|
roles:
|
||||||
|
- cabal-test
|
4
playbooks/haskell/pre.yaml
Normal file
4
playbooks/haskell/pre.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
- hosts: all
|
||||||
|
roles:
|
||||||
|
- ensure-ghc
|
||||||
|
- ensure-cabal
|
8
roles/cabal-test/README.rst
Normal file
8
roles/cabal-test/README.rst
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
Run the cabal test command.
|
||||||
|
|
||||||
|
**Role Variables**
|
||||||
|
|
||||||
|
.. zuul:rolevar:: zuul_work_dir
|
||||||
|
:default: {{ zuul.project.src_dir }}
|
||||||
|
|
||||||
|
Directory to run the cabal command in.
|
1
roles/cabal-test/defaults/main.yaml
Normal file
1
roles/cabal-test/defaults/main.yaml
Normal file
@ -0,0 +1 @@
|
|||||||
|
zuul_work_dir: "{{ zuul.project.src_dir }}"
|
19
roles/cabal-test/tasks/main.yaml
Normal file
19
roles/cabal-test/tasks/main.yaml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
- name: Run cabal install --only-dependencies
|
||||||
|
command: cabal install --only-dependencies
|
||||||
|
args:
|
||||||
|
chdir: "{{ zuul_work_dir }}"
|
||||||
|
|
||||||
|
- name: Run cabal configure --enable-test
|
||||||
|
command: cabal configure --enable-test
|
||||||
|
args:
|
||||||
|
chdir: "{{ zuul_work_dir }}"
|
||||||
|
|
||||||
|
- name: Run cabal build
|
||||||
|
command: cabal build
|
||||||
|
args:
|
||||||
|
chdir: "{{ zuul_work_dir }}"
|
||||||
|
|
||||||
|
- name: Run cabal test
|
||||||
|
command: cabal test
|
||||||
|
args:
|
||||||
|
chdir: "{{ zuul_work_dir }}"
|
4
roles/ensure-cabal/README.rst
Normal file
4
roles/ensure-cabal/README.rst
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Ensure cabal is installed
|
||||||
|
|
||||||
|
This role installs the cabal-install package and ensures
|
||||||
|
the hackage packages list exists.
|
20
roles/ensure-cabal/tasks/main.yaml
Normal file
20
roles/ensure-cabal/tasks/main.yaml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
- 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"
|
||||||
|
|
||||||
|
- name: Check package
|
||||||
|
stat:
|
||||||
|
path: "~/.cabal/packages"
|
||||||
|
register: _cabal_packages
|
||||||
|
|
||||||
|
- name: Update package list
|
||||||
|
command: cabal update
|
||||||
|
when: not _cabal_packages.stat.exists
|
11
roles/ensure-ghc/README.rst
Normal file
11
roles/ensure-ghc/README.rst
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
Ensure ghc is installed
|
||||||
|
|
||||||
|
Installs the specified ghc version and the cabal tool.
|
||||||
|
This role uses the Fedora package module.
|
||||||
|
|
||||||
|
**Role Variables**
|
||||||
|
|
||||||
|
.. zuul:rolevar:: ghc_version
|
||||||
|
:default: latest
|
||||||
|
|
||||||
|
The ghc version.
|
6
roles/ensure-ghc/defaults/main.yaml
Normal file
6
roles/ensure-ghc/defaults/main.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
ghc_version: latest
|
||||||
|
ghc_versions:
|
||||||
|
latest: "8.10"
|
||||||
|
8.10: "8.10"
|
||||||
|
8.8: "8.8"
|
||||||
|
8.6: "8.6"
|
25
roles/ensure-ghc/tasks/main.yaml
Normal file
25
roles/ensure-ghc/tasks/main.yaml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
- name: Make sure the role is run on Fedora
|
||||||
|
fail:
|
||||||
|
msg: "This role supports Fedora only"
|
||||||
|
when: "ansible_distribution != 'Fedora'"
|
||||||
|
|
||||||
|
- name: Check requested version
|
||||||
|
fail:
|
||||||
|
msg: |
|
||||||
|
Unknown ghc version: {{ ghc_version }}.
|
||||||
|
It needs to be defined in {{ opendev_url }}/roles/ensure-ghc/defaults/main.yaml
|
||||||
|
when: ghc_versions[ghc_version] is not defined
|
||||||
|
vars:
|
||||||
|
opendev_url: https://opendev.org/zuul/zuul-jobs/src/branch/master/
|
||||||
|
|
||||||
|
- name: Check ghc version
|
||||||
|
command: ghc --version
|
||||||
|
failed_when: false
|
||||||
|
register: _ghc_version
|
||||||
|
|
||||||
|
- name: Install ghc
|
||||||
|
dnf:
|
||||||
|
name: "@ghc:{{ ghc_versions[ghc_version]|string }}"
|
||||||
|
state: present
|
||||||
|
become: yes
|
||||||
|
when: "_ghc_version.rc != 0 or (ghc_versions[ghc_version]|string) not in _ghc_version.stdout"
|
6
test-playbooks/haskell/setup-project.yaml
Normal file
6
test-playbooks/haskell/setup-project.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
- hosts: all
|
||||||
|
tasks:
|
||||||
|
- name: Setup files
|
||||||
|
command: cabal init --non-interactive
|
||||||
|
args:
|
||||||
|
chdir: "{{ zuul.project.src_dir }}"
|
21
zuul-tests.d/haskell.yaml
Normal file
21
zuul-tests.d/haskell.yaml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
- job:
|
||||||
|
name: zuul-jobs-test-cabal-test
|
||||||
|
description: Test the cabal-test job and roles
|
||||||
|
parent: cabal-test
|
||||||
|
files:
|
||||||
|
- playbooks/haskell/.*
|
||||||
|
- roles/ensure-cabal/.*
|
||||||
|
- roles/ensure-ghc/.*
|
||||||
|
- roles/cabal-test/.*
|
||||||
|
pre-run: test-playbooks/haskell/setup-project.yaml
|
||||||
|
nodeset:
|
||||||
|
nodes:
|
||||||
|
- name: fedora-31
|
||||||
|
label: fedora-31
|
||||||
|
|
||||||
|
- project:
|
||||||
|
check:
|
||||||
|
jobs: &id001
|
||||||
|
- zuul-jobs-test-cabal-test
|
||||||
|
gate:
|
||||||
|
jobs: *id001
|
14
zuul.d/haskell-jobs.yaml
Normal file
14
zuul.d/haskell-jobs.yaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
- job:
|
||||||
|
name: cabal-test
|
||||||
|
description: |
|
||||||
|
Run cabal test for a Haskell project.
|
||||||
|
|
||||||
|
Responds to these variables:
|
||||||
|
|
||||||
|
.. zuul:jobvar:: ghc_version
|
||||||
|
|
||||||
|
Use the specified ghc version (``latest`` picks the latest).
|
||||||
|
run: playbooks/haskell/cabal.yaml
|
||||||
|
pre-run: playbooks/haskell/pre.yaml
|
||||||
|
vars:
|
||||||
|
ghc_version: latest
|
Loading…
Reference in New Issue
Block a user