hlint: add haskell source code suggestions job

This change adds a new job to run hlint on haskell source files.

Change-Id: Ibf76c5552acecd68dfc56c4f31d8045ca5b233f1
This commit is contained in:
Tristan Cacqueray 2020-04-23 13:00:11 +00:00
parent 42edd207f9
commit 2e82d88589
11 changed files with 84 additions and 1 deletions

View File

@ -2,3 +2,4 @@ Haskell Jobs
============
.. zuul:autojob:: cabal-test
.. zuul:autojob:: hlint

View File

@ -3,4 +3,6 @@ Haskell Roles
.. zuul:autorole:: ensure-cabal
.. zuul:autorole:: ensure-ghc
.. zuul:autorole:: ensure-hlint
.. zuul:autorole:: cabal-test
.. zuul:autorole:: hlint

View File

@ -0,0 +1,3 @@
- hosts: all
roles:
- hlint

View File

@ -0,0 +1,3 @@
- hosts: all
roles:
- ensure-hlint

View File

@ -0,0 +1,3 @@
Ensure hlint is installed
Installs the hlint tool using the distro package.

View File

@ -0,0 +1,11 @@
- name: Check hlint version
command: hlint --version
failed_when: false
register: _hlint_version
- name: Install hlint
package:
name: "hlint"
state: present
become: yes
when: "_hlint_version.rc != 0"

13
roles/hlint/README.rst Normal file
View File

@ -0,0 +1,13 @@
Run the hlint command.
**Role Variables**
.. zuul:rolevar:: hlint_report_name
:default: hlint.html
The name of the report.
.. zuul:rolevar:: zuul_work_dir
:default: {{ zuul.project.src_dir }}
Directory to run the hlint command in.

View File

@ -0,0 +1,3 @@
hlint_report_name: "hlint.html"
zuul_work_dir: "{{ zuul.project.src_dir }}"

View File

@ -0,0 +1,16 @@
- block:
- name: Run hlint
command: "hlint --report={{ report_location }} ."
vars:
report_location: "{{ ansible_user_dir }}/zuul-output/logs/{{ hlint_report_name }}"
args:
chdir: "{{ zuul_work_dir }}"
always:
- name: Return report to Zuul
zuul_return:
data:
zuul:
artifacts:
- name: "HLint report"
url: "{{ hlint_report_name }}"

View File

@ -3,7 +3,8 @@
description: Test the cabal-test job and roles
parent: cabal-test
files:
- playbooks/haskell/.*
- playbooks/haskell/cabal.yaml
- playbooks/haskell/pre.yaml
- roles/ensure-cabal/.*
- roles/ensure-ghc/.*
- roles/cabal-test/.*
@ -13,9 +14,27 @@
- name: fedora-31
label: fedora-31
- job:
name: zuul-jobs-test-hlint
description: Test the hlint job and roles
parent: hlint
files:
- playbooks/haskell/hlint.yaml
- playbooks/haskell/pre-hlint.yaml
- roles/ensure-hlint/.*
- roles/hlint/.*
pre-run:
- playbooks/haskell/pre.yaml
- test-playbooks/haskell/setup-project.yaml
nodeset:
nodes:
- name: fedora-31
label: fedora-31
- project:
check:
jobs: &id001
- zuul-jobs-test-cabal-test
- zuul-jobs-test-hlint
gate:
jobs: *id001

View File

@ -12,3 +12,12 @@
pre-run: playbooks/haskell/pre.yaml
vars:
ghc_version: latest
- job:
name: hlint
description: |
Run haskell source code suggestions.
This job produces an hlint.html report.
run: playbooks/haskell/hlint.yaml
pre-run: playbooks/haskell/pre-hlint.yaml