Add inline comment support to nox

Change-Id: I34c7e9eade807470d0ef573e780b40ffc0a8e284
This commit is contained in:
James E. Blair 2022-12-19 15:14:54 -08:00 committed by Clark Boylan
parent 50fd134646
commit e8df80b5d9
4 changed files with 30 additions and 3 deletions

View File

@ -67,6 +67,12 @@ corresponding Zuul sibling projects and runs nox tests as follows:
Path to a pip constraints file. Will be provided to nox via
``NOX_CONSTRAINTS_FILE``.
.. zuul:rolevar:: nox_inline_comments
:default: true
Flag controlling whether to parse the output from the nox session
and return inline comments to Zuul. Defaults to True.
.. zuul:rolevar:: nox_install_siblings
:default: true

View File

@ -0,0 +1 @@
../../tox/library/tox_parse_output.py

View File

@ -78,6 +78,23 @@
# Even though any test environment in nox failed we want to
# return file comments produced so always run this.
always:
- name: TODO
debug:
msg: TODO
- name: Look for output
tox_parse_output:
tox_output: '{{ nox_output.stdout }}'
tox_envlist: '{{ nox_session | default(nox_keyword) | default(nox_tag) }}'
workdir: '{{ zuul_work_dir }}'
when: nox_inline_comments
register: file_comments
failed_when: false
- name: Return file comments to Zuul
when:
- nox_inline_comments
- file_comments.file_comments is defined
- file_comments.file_comments
delegate_to: localhost
zuul_return:
data:
zuul:
file_comments: '{{ file_comments.file_comments }}'
failed_when: false

View File

@ -119,6 +119,9 @@ def extract_file_comments(tox_output, workdir, tox_envlist=None):
# For now, skip .tox directory, we can enhance later.
if file_path.startswith('.tox'):
continue
# This library is shared with the nox role.
if file_path.startswith('.nox'):
continue
ret.setdefault(file_path, [])
if tox_envlist: