23236c12fa
This patch adds a roles and jobs to run golangci-lint against a a Golang project. It's a very popular tool for linting go code. It also adds a simple framework which allows us to create dynamic tests for file comments by defining a simple YAML file. Change-Id: Ic8358541adaf7c3279383f0279cd3da7b446a6e0
28 lines
777 B
YAML
28 lines
777 B
YAML
- name: Run golangci-lint
|
|
command: "golangci-lint run {{ golangci_lint_options }}"
|
|
args:
|
|
chdir: "{{ zuul_work_dir }}"
|
|
environment:
|
|
PATH: "{{ ansible_env.PATH }}:{{ go_bin_path }}"
|
|
ignore_errors: true
|
|
register: _golangci_lint
|
|
|
|
- name: Look for output
|
|
golangci_lint_parse_output:
|
|
workdir: '{{ zuul_work_dir }}'
|
|
output: '{{ _golangci_lint.stdout }}'
|
|
register: _golangci_lint_parse_output
|
|
|
|
- name: Return file comments to Zuul
|
|
when: _golangci_lint_parse_output.comments
|
|
delegate_to: localhost
|
|
zuul_return:
|
|
data:
|
|
zuul:
|
|
file_comments: '{{ _golangci_lint_parse_output.comments }}'
|
|
|
|
- name: Return golangci-lint status
|
|
fail:
|
|
msg: 'golangci-lint exited with return code {{ _golangci_lint.rc }}'
|
|
when: _golangci_lint.rc != 0
|