go: Use 'block: ... always: ...' and failed_when instead of ignore_errors

Change-Id: I11fc6ec69eda00f4ac824f27712acc82ec445f79
This commit is contained in:
Albin Vass 2020-04-27 20:47:07 +02:00
parent b1b2dca456
commit fff6843da0
2 changed files with 22 additions and 26 deletions

View File

@ -3,7 +3,7 @@
register: go_installed_version
environment:
PATH: "{{ ansible_env.PATH }}:{{ go_install_dir }}/go/bin"
ignore_errors: yes
failed_when: false
- name: Skip if correct version of go is installed
include_tasks: install-go.yaml

View File

@ -1,27 +1,23 @@
- 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
- block:
- name: Run golangci-lint
command: "golangci-lint run {{ golangci_lint_options }}"
args:
chdir: "{{ zuul_work_dir }}"
environment:
PATH: "{{ ansible_env.PATH }}:{{ go_bin_path }}"
register: _golangci_lint
- name: Look for output
golangci_lint_parse_output:
workdir: '{{ zuul_work_dir }}'
output: '{{ _golangci_lint.stdout }}'
register: _golangci_lint_parse_output
always:
- 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
- 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 }}'