From e8df80b5d913a1ae239b0a2828732e0ad7391827 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Mon, 19 Dec 2022 15:14:54 -0800 Subject: [PATCH] Add inline comment support to nox Change-Id: I34c7e9eade807470d0ef573e780b40ffc0a8e284 --- roles/nox/README.rst | 6 ++++++ roles/nox/library/tox_parse_output.py | 1 + roles/nox/tasks/main.yaml | 23 ++++++++++++++++++++--- roles/tox/library/tox_parse_output.py | 3 +++ 4 files changed, 30 insertions(+), 3 deletions(-) create mode 120000 roles/nox/library/tox_parse_output.py diff --git a/roles/nox/README.rst b/roles/nox/README.rst index 782389297..3e441a297 100644 --- a/roles/nox/README.rst +++ b/roles/nox/README.rst @@ -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 diff --git a/roles/nox/library/tox_parse_output.py b/roles/nox/library/tox_parse_output.py new file mode 120000 index 000000000..4ad54a829 --- /dev/null +++ b/roles/nox/library/tox_parse_output.py @@ -0,0 +1 @@ +../../tox/library/tox_parse_output.py \ No newline at end of file diff --git a/roles/nox/tasks/main.yaml b/roles/nox/tasks/main.yaml index 260054827..f7d28e216 100644 --- a/roles/nox/tasks/main.yaml +++ b/roles/nox/tasks/main.yaml @@ -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 diff --git a/roles/tox/library/tox_parse_output.py b/roles/tox/library/tox_parse_output.py index af5ccc1e8..fc6fb05eb 100644 --- a/roles/tox/library/tox_parse_output.py +++ b/roles/tox/library/tox_parse_output.py @@ -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: