Commit Graph

18 Commits

Author SHA1 Message Date
James E. Blair e8df80b5d9 Add inline comment support to nox
Change-Id: I34c7e9eade807470d0ef573e780b40ffc0a8e284
2022-12-19 18:41:16 -08:00
James E. Blair 9e22cfdb0f Remove shebang from all python ansible modules
This commit in Ansible:
9142be2f6c

now allows Python modules to specify their interpreter with the shebang.
We expect our roles to use the discovered python interpreter on remote
nodes, and on the executor, we need them to use the virtualenv.  Removing
the specific shebang accomplishes this under Ansible 6, and has no effect
under older versions of Ansible.

Without this, for example, the log upload roles would not have access to
their cloud libraries.

Also update our ansible/cli check in our module files.  Many of our modules
can be run from the command line for ease of testing, but the check that we
perform to determine if the module is being invoked from the command line
or Ansible fails on Ansible 5.  Update it to a check that should work in
all 4 versions of Ansible that Zuul uses.

Change-Id: I4e6e85156459cca032e6c3e1d8a9284be919ccca
2022-09-15 13:48:10 -07:00
Andreas Jaeger 2654d0338c Revert "tox: update lint regex to not require column"
This reverts commit 53f2444dbb.

Revert to avoid regression:
https://review.opendev.org/710208 just gave a lot of new linting warnings that look new "py38: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()"

Change-Id: I26c862255cce6b6c99a69d9e3f5f4354db90f953
2020-05-18 12:23:56 +00:00
Albin Vass 53f2444dbb tox: update lint regex to not require column
This is needed to be able to parse output from ansible-lint.

Removes a testcase with a faulty assumption that if the column is
not present the output must be a warning and should not be returned.

It is probably better to allow the user to configure their linting
output themselves.

Also we don't need a separate matcher for sphinx.

Change-Id: I6d06dce921348d3c6fb5a56cdc1e4df675d685c2
2020-05-14 20:30:29 +02:00
James E. Blair a4cf5ca07e tox: Don't inline python warnings
The sphinx regex is picking up python warnings.  We can disambiguate
the two because sphinx doesn't emit a space before the message but
the python warnings module does.  This adjusts the regex to do that
and adds a test file that includes warnings output.

If we need/want to make this more robust, we could also simply filter
the sphinx output for messages that start with " ?\w+Warning:".

We could also decide that we want to include python warnings.

Change-Id: Ib58cc1a2d4f673a0ce3d2a9cae306004559f5b52
2020-04-08 14:13:48 -07:00
Andreas Jaeger 55e31dd996 tox-parse_output: Ignore .tox directory
We get many false positives on the .tox directory, ignore it.

Even better would be to only handle files under version control but that
is more involved, so use the simple heuristic for .tox for now since
that catches 90+ per cent of the cases.

Change-Id: Ibb17958454a4d6bf156020fe4d9f588f3c666cc7
2020-04-04 17:25:49 +02:00
Tobias Henkel 99ea9c94a0
Add test cases for tox line comment parsing
Tox line comment parsing had a few side effects at first so add
testing to it.

Change-Id: I9eb2aa00d6e467bd170fad80598728aec6949ee6
2020-04-03 19:34:24 +02:00
Tobias Henkel 92bb7ff535
Ignore absolute paths after stripping work dir
After stripping the work dir there should not be any absolute path
left that can be related to the repo. Thus filter them so they don't
produce mapping warnings in zuul.

Change-Id: Iadeac9b1faea63aa6009e2cfbc215853695abbe6
2020-04-02 19:39:58 +02:00
Tobias Henkel 7df5e55ebc
Strip source dir from file comments
Some programs like sphinx emit absolute paths in error messages. Those
cannot be processed by zuul so filter them if they're part of
zuul.project.

Change-Id: Ie8af91017c26f39c3aa9ca098d4230f0688351ce
2020-04-02 19:39:58 +02:00
Tobias Henkel ecb2c55640
Don't silently ignore exceptions when parsing tox output
We shouldn't catch exceptions during parsing without having any
log. This makes debugging impossible. Since errors are now ignored we
can stop silently catching any exception and take the chance to harden
the parsing when we hit exceptions in the future.

Change-Id: Ie58acc4c7fbfcb7e44eef49883fb69f3bccef994
2020-04-02 19:39:58 +02:00
Tobias Henkel 00900e69ab
Support multiple matchers when parsing tox output
The regex used to filter for line comments needs to be fine tuned for
different linters. Instead having a huge complicated regex add support
for more specialized regexes. Start with a regex that matches spinx
output.

Change-Id: I516086bba315b8bb03a1103e1b33f1a819853be7
2020-04-02 19:39:58 +02:00
Monty Taylor 47a04533a2 Check that a file exists for inline comments
keystoneauth has some unit tests which output lines like:

  stdin:5:1: K333  'from oslo import utils' must be used instead of 'from oslo import utils'.

The stdin isn't a file, but we try to report it back.
Pass in zuul_work_dir and use it to check that the "file"
is a file that exists.

Change-Id: I2c2aeb4e68f7d50f15ea6c6128fec6050d476c64
2020-04-01 11:58:38 -05:00
Monty Taylor 71838cf556 Add tox_envlist to the inline comment
To make it clear which tox command a given comment came from
in the case where more than one job has messages, prepend the
tox_envlist parameter to the inline message.

Change-Id: I70228baa285c4e676dc1348c354d4bbf3a3825bc
2020-04-01 11:16:12 -05:00
Monty Taylor 2fa3d6d3b2 Strip ansi codes from pep8 message
Sometimes pep8 messages have ANSI color codes, as here:

https://review.opendev.org/#/c/697636/10/cinder/tests/unit/volume/drivers/vmware/test_fcd.py@567

Which is pretty noisy in a gerrit comment. Strip them.

Change-Id: I494ec23d05b9df54e31ff8a2c568309b0a01f98a
2020-04-01 09:01:06 -05:00
Mohammed Naser d311a4289a tox_parse_output: add no_log to tox_output
The `tox_parse_output` currently logs the entire output of tox
into the syslog as the natural Ansible behaviour, as part of doing
that, it also encodes it inside utf-8.  This results in errors
in the case that the the data contains surrogates and crashes the
entire job.

Given that this issue really occurs during logging and we don't
have a reason to log all of the tox output to the syslog, this
patch sets the module parameter to `no_log` which should skip the
encoding and logging for that parameter[0].

[0]: https://github.com/ansible/ansible/blob/stable-2.9/lib/ansible/module_utils/basic.py#L1945-L1957

Change-Id: I470cd35111a63662c43f779fc9e119aa8d78c838
2020-04-01 08:52:10 -04:00
Mohammed Naser 7668ec7c38 Revert "Revert "Extract pep8 messages for inline comments""
This reverts commit b35f47190a.

Change-Id: I71cd0520ff62c41e4e3ebe9eb9e8a3839147726e
2020-03-29 19:21:46 -04:00
Tobias Henkel b35f47190a Revert "Extract pep8 messages for inline comments"
There seems to be a problem with openstack-zuul-jobs [1].

This reverts commit 421f533b61.

[1] http://logs.openstack.org/86/610386/3/gate/openstack-zuul-jobs-linters/a8c857d/job-output.txt.gz#_2018-10-18_07_14_42_431592

Change-Id: Iac5236221e33df4613cc2f7a2edcffc323902320
2018-10-18 09:11:38 +00:00
Monty Taylor 421f533b61 Extract pep8 messages for inline comments
Move the zuul requirement from test-requirements into the linters
section of tox.ini because we need it as a src install in the tox
env, so that we can reference the ansible library location.

Change-Id: I089c69b539107bdbc25791f5730502a4f46e7cf6
2018-10-17 13:45:00 -07:00