zuul-jobs/roles/golangci-lint/tasks/main.yaml
Ian Wienand 6d23d20f2f linters: add names to blocks
This is preparation for a later version of ansbile-lint, which finds
missing names on blocks.  This seems a reasonable rule, and the
Ansible manual says [1]

  Names for blocks have been available since Ansible 2.3. We recommend
  using names in all tasks, within blocks or elsewhere, for better
  visibility into the tasks being executed when you run the playbook.

This simply adds a name tag for blocks that are missing it.  This
should have no operational change, but allows us to update the linter
in a follow-on change.

[1] https://docs.ansible.com/ansible/latest/user_guide/playbooks_blocks.html

Change-Id: I92ed4616775650aced352bc9088a07e919f1a25f
2022-07-27 17:13:39 +10:00

25 lines
727 B
YAML

- name: Run 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
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 }}'