Commit Graph

44 Commits

Author SHA1 Message Date
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
Ian Wienand f76cfbab11 linters: fix spaces between filters
This fixes a number of places where we do not have spaces between
filters.  I think that this is a reasonable rule for readability (I
also think it probably was enforced, but maybe later versions got
better at detecting it?).

These are detected by a later version of Ansible lint; this change
should have no operational change to any roles but prepares us to
update in a follow-on change.

Change-Id: I07e1a109b87adce86f483d14d7e02fcecb8313d5
2022-07-27 17:13:39 +10:00
Jeremy Stanley 3d449a07df Add tox_config_file rolevar to tox
In some situations, projects may not keep a tox.ini in the root
directory of their repository, or may even have multiple tox
configuration files. Allow the location and name of the config to be
overridden explicitly through the use of a new rolevar.

Change-Id: I1927142e6d9fa75e96902ae001c8ca98d69c7443
2021-09-17 20:34:37 +00:00
Zuul 3d64b59f00 Merge "tox: envlist bugfixes" 2020-05-27 16:20:12 +00:00
Albin Vass 58b291b5cf tox: envlist bugfixes
Change-Id: I17e807aa544f6fb45e82604f35c027fe1f86c2f9
2020-05-27 12:32:07 +00:00
Zuul 8dbd1a79d5 Merge "tox: empty envlist should behave like tox -e ALL" 2020-05-26 13:56:09 +00:00
Albin Vass f47101e12b tox: update include to include_tasks
Change-Id: I8cf11ca347e537ef52b8c353b947a46afa701fe2
2020-05-26 07:59:38 +00:00
Albin Vass e0b27f7e59 tox: empty envlist should behave like tox -e ALL
Also we can parse the output from --showconfig to se which
testenvs we should act upon when installing siblings.

Change-Id: I438035c92d62102c80db9bed81e9f290e4c941b2
2020-05-22 20:40:45 +02:00
Albin Vass 86041d9914 Don't require tox_envlist
Since tox_envlist has a default value it cannot be undefined
so the fail task will never run. Instead handle the case when
tox_envlist is an empty string by getting the default configured
envlist from tox. Also handle the casewhen tox_envlist is 'ALL'.

This also updates tox_install_sibling_packages to correctly
handle multiple testenvs and uses configuration supplied by
'tox --showconfig -e <envlist>' instead of guessing where the
envdir and logdir are located.

We also cannot run tox inside python because it gets complicated
to know which tox_executable we should call during the python test
cases so run these commands in ansible and pass the output to
tox_install_sibling_packages.

Since role params have higher precedence than set_fact we set an
internal _tox_envlist fact that is a comma separated list of testenvs
that should be run.

Change-Id: I9e5a1b041f653cbcff7b8ed62e4a95a0a040fdd7
2020-05-19 14:32:26 +02:00
Albin Vass 3487b54baf tox: Use 'block: ... always: ...' instead of ignore_errors
Change-Id: Ifc9f420687538a0ed666b41fa707810b184b0c66
2020-04-28 16:20:20 +02:00
vass a32119249c tox: allow running default envlist in tox
Change-Id: I49638ab7949804fc967e337fa5ce21d2a3dc9d49
2020-04-24 18:23:05 +02:00
Tobias Henkel b758ca594a
Keep error status in tox run
The line comments needs to run after the tox run so we set failed_when
to true. However this task won't be shown as failed in the log
then. Instead ignore errors to let the playbook continue and keep the
erorr status.

Change-Id: I6f2a4043de982aa3de6e0cc4eb489914fd5805c2
2020-04-01 21:42:03 +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 e404589b84 Add flag for toggling inline comments for linters
Sometimes there are linters that are producing output where
people do not care about it enough to want to see it.

Change-Id: I0d58a3f6a4c51e1419b645a7ce1a81e6adee57d3
2020-04-01 09:01:06 -05:00
Tobias Henkel a3c7c22c06
Ignore errors when parsing tox output
Retrieving file comments is not an essential part of the job and
should not fail the job if something goes wrong.

Change-Id: Ide13343c6eda3a1fd0f45cb33cba35f3b048ece6
2020-04-01 14:35:48 +02:00
James E. Blair 2961a8f30e Remove lint skip in tox iniline comment parser
This isn't necessary any more since we added the fake zuul_return
module to this repo.

Change-Id: Ib7ac96cd38d2e987f884a086cb29d9807f275c60
2020-03-31 07:49:52 -07: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
Dirk Mueller df3a9882df Switch to TOX_CONSTRAINTS_FILE
This allows to use lower-constraints.txt more easily as input
when everyone has switched over.

Depends-On: https://review.opendev.org/660823

Change-Id: I3f957187ed4f29fcf88db99cb79fb33b21a8dd8d
2019-05-22 22:30:14 +02: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
Monty Taylor d7cba9d7d5
Combine tox-siblings and tox roles
There is a bunch of duplicate logic between tox and tox-siblings, the
tox-siblings logic is already protected with a flag - and having them be
split already led to not doing the right thing with constraints files in
siblings when we did it right in tox itself.

Combine them into one role.

This means the siblings code will run as part of run instead of as part
of pre- but that's how things have worked for years anyway until
siblings was introduced - and is also the behavior is the siblings flag
is false -so it's more consistent overall.

Leave a no-op tox-siblings role so that we can gracefully remove the use of
tox-siblings from castellan, python-openstacksdk, shade and tacker.

Change-Id: Id61ae52d48b28cfc2221cb556a1c1f7c6dfd60dd
2017-11-29 15:34:08 -06:00
Monty Taylor b2befeb2b4
Emit a message about the final tox invocation
In the tox job it's nice to see what it is that we're gonna run. It's in
the json file, but that's a little bit hidden.

Change-Id: Iebe4b4c67d00ebc21be9038e06f1ee09badb4eb1
2017-09-27 16:36:59 -05:00
Monty Taylor bc18b5478b
Rename tox_upper_constraints_file to tox_constraints_file
Make the new variable default to the old variable for backwards compat.

Change-Id: I75d5e576276d68bfa23006d7ad4c2a86cb7f5050
2017-09-22 10:23:40 -05:00
Monty Taylor 022832a1d7
Add UPPER_CONSTRAINTS_FILE file if it exists
Create a parameter called tox_upper_constraints. The parameter points
to a file on the system. If the file exists, it will be passed to the
tox invocation in the UPPER_CONSTRAINTS_FILE environment variable.

This allows a global setting in a base job of a known file to be the
UPPER_CONSTRAINTS_FILE file, or for that to be overridden on a per-job
basis. For people who do not know or care what an
UPPER_CONSTRAINTS_FILE file is, the behavior should be a no-op.

Also, collapse tox_environment and tox_environment_defaults.
zuul already does variable merging on parent and child jobs, so we don't
need to do it in the playbook.

While we're in there, clean up a few small things in the yaml. Notably,
jlk says we should not put variables in task names, and we don't need
quotes around strings if they don't have special characters.

Change-Id: Ibede59ca6f85914952da175c77ea29391ef9a88c
2017-09-07 10:09:23 -05:00
Paul Belanger f21bd3e57e
Simplify run tox task
Remove large chuck of run-tests.sh that was copypasta inside our
ansible tox role.

Change-Id: I53f2619a99e93be0ac210bf4254e37e441a7aaa2
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-08-01 18:24:44 -04:00
Jenkins 6cc5da8281 Merge "Move subunit processing into fetch-testr-output" 2017-07-26 18:34:50 +00:00
Paul Belanger d2d4abedc5
Move subunit processing into fetch-testr-output
This logic makes more sense in the fetch-testr-output role. I've also
left a few TODO action for a followup patch.  Specifically, this
still depends some openstack-infra configuration.

Change-Id: Iea8968708e3e80f0d21434ec08fff5e4ee7bdf4d
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-07-26 14:29:26 -04:00
Jenkins 94cd547fea Merge "Create tox_environment_defaults variable for tox based jobs" 2017-07-25 20:20:36 +00:00
Paul Belanger 9c60767c9f
Create tox_environment_defaults variable for tox based jobs
Expose the ability for tox jobs to define a default set of
environmental variables to pass to the tox role.  We also do a few new
things.

Check to see if tox_environment and tox_environment_defaults are
defined, if so combined tox_environment_defaults with
tox_environment creating a new my_tox_environment variable.
Variables defined in tox_environment take priority when we combine
variables.

Change-Id: Ic4a5644e79ca7000cbdaee40467619a6832c8332
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-07-25 10:43:50 -04:00
Jenkins 0507ed9ddc Merge "Remove .txt suffix from tox logs" 2017-07-24 16:22:12 +00:00
Paul Belanger 4ba5f093d7
Remove .txt suffix from tox logs
This was legacy code needed for openstack-infra logging servers.  We
can stop doing this in our tox role.

It is possible a job would want to do this, but it now makes more
sense to hav this happen as a post-run task in the job.

Change-Id: I981eb99468a352386f268fe6b8911291a93957ef
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-07-24 11:43:48 -04:00
Paul Belanger 4cc1191190
Remove nodepool DIB specific logic
We no longer want to depend on these files directly. So lets remove
them.

Change-Id: Id9b91de774253bd0c33d8d2c9fd840528edac976
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-07-20 17:05:19 -04:00
Paul Belanger cd6902638f
Remove OOM check from tox role
This is something we did in openstack-infra but not sure it make sense
for default tox jobs.  It is possible we want to make this an ansible
role for playbooks to opt into post-run. But with properly logging on
a job, it should be straightforward to determine why a tox test
failed.

Change-Id: I746fae586a3df40a07ceca9c0bebe579f9f74f34
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-07-19 19:28:37 -04:00
Paul Belanger ab2caa3fa4
Require tox_envlist for tox role
Make this variable a hard requirement, since we depend on it so much.
Also removes inline bash script logic.

Change-Id: Ic3e8831fd81e408e1cc7b393182ba15b953e8ce0
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-07-18 19:06:21 -04:00
Paul Belanger 9b52406207
Remove pip freeze logic
Tox 2.4 will do this today by default:

  http://tox.readthedocs.io/en/latest/config.html#confval-list_dependencies_command

It also means it is much easier for tox jobs to change pip freeze to
some other command (eg: pbr freeze).

Change-Id: I862a783500c46db99ac0971c88631764a2f982f2
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-07-18 18:27:49 -04:00
Paul Belanger c267740024
Remove check_sudo_usage logic from tox
This doesn't make much sense in an ansible only world. There is my
ways today to block sudo or check if sudo failed with ansible. No need
to include our custom bash script for this check.

If a job wants sudo, they can either not use the revoke-sudo role or
write another job.

Change-Id: I267541a813b5ff6e7301f50421af46a0db33304d
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-07-18 17:35:42 -04:00
Paul Belanger aefae32107
Compress testrepository.subunit in fetch-testr-output
It make sense to compress subunit file we want from tox before
uploading it to our log server.

Change-Id: Ibb1b6cedce0350f8c2baf40718a909f30ce954d7
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-07-18 17:35:41 -04:00
Paul Belanger 05bebdfb29
Remove subunit file size check for tox role
This is openstack specific code and not needed in our role tox.

Change-Id: I7c963944e94f427836a643f86bde8881cb9383d0
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-07-18 17:35:39 -04:00
Paul Belanger f49f3f641d
Remove export commands from tox based roles
This logic is very specific to openstack-infra and now that we have
exposed tox_environment, it is much easier for jobs to pass into shell
variables into our tox based roles.

Change-Id: I6c5897088158e1e4917d29d72f523f853c254314
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-07-18 17:35:37 -04:00
Paul Belanger 79dd919742
Create tox_environment to allow users access to shell variables
Because we run tox using the shell task, it is possible users will
need to pass custom shell variables to their tox.ini files. Expose a
way for users to do just that.

Change-Id: I0a0c15d85d91fe0a23cf688f0b0f228133922264
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-07-17 09:09:43 -04:00
Paul Belanger 9258e5b6d8
Update to tox_envlist variable
Rename tox_environment to tox_envlist to better map with tox --help
documentation. This also allows the following patch to support shell
environmental variables.

Change-Id: I2fb4e1c167ef93ad2948f2d328beff5e39ac52b7
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-07-14 11:49:20 -04:00
Monty Taylor 055de47b4e
Add zuul_work_dir default to one-project roles
We'd like to be able to make some jobs that run tox on other projects
for ease of testing. This should allow us to do that.

Change-Id: I774a76eaaea16d8ea218b439a099b5c9335c2fc5
2017-07-07 17:04:46 -05:00
Monty Taylor 4b9fc09a1c
Port in tox jobs from openstack-zuul-jobs
The original idea was that we'd have a "python27" job. But it turns out
that "python27" isn't actually as universal as you might think.
"tox-py27" on the other hand is a thing that can and should always work
for people who want to run tox with the py27 env.

Port in the jobs we had in openstack-zuul-jobs.

Also, copy in the text of the old shell scripts so that we can iterate on
them and make them better piecemeal.

These are named zuul-tox not tox because we already have tox jobs
defined elsewhere. We'll need to do the naming dance while we work on
them.

Change-Id: I813f3f2ae138c07918556bc81655518023527131
2017-07-06 11:18:47 -05:00