Commit Graph

336 Commits

Author SHA1 Message Date
Zuul 0425c08f3d Merge "Hacking: Remove C306, C308 checks" 2024-02-21 16:00:04 +00:00
Zuul befc7277a1 Merge "mypy: Cleanup "noqa: H301" comments" 2023-12-18 19:38:37 +00:00
Eric Harney 349b0a1ccd mypy: Cleanup "noqa: H301" comments
We decided that H301 makes no sense for the "typing"
module, just set that in tox.ini instead of every
time it is used.

Change-Id: Id983fb0a9feef2311bf4b2e6fd70386ab60e974a
2023-12-14 16:29:27 +00:00
Eric Harney ccc2646a0c pylint: Upgrade to 3.0
pylint 3.0 is required to support Python 3.12.

Change-Id: I20a6d061260b8ddc6dd60fdcd98d9d1683acd068
2023-11-29 12:03:13 -05:00
Zuul e5b7b41ae9 Merge "Experiment with ruff" 2023-11-28 22:03:36 +00:00
Eric Harney 7f629facb4 Hacking: Remove C306, C308 checks
These block usage of methods that no longer
exist in oslo.utils 6.0.0+.  Since they have
been removed, we don't need a hacking check
for this.

Change-Id: If0345c863b1750eaca3097f240fde9b976ac442e
2023-09-14 15:18:58 -04:00
Eric Harney eea5293035 Stop sharing tox envdir between pep8 and fast8
tox is now too smart for this to work, so just drop it.

pep8: recreate env because env type changed from
  {'name': 'fast8', 'type': 'VirtualEnvRunner'} to
  {'name': 'pep8', 'type': 'VirtualEnvRunner'}

Change-Id: Ibcaa07a0899e71a06cdaa527c43c14789a16b6e4
2023-09-14 14:31:33 +00:00
Eric Harney 4092805978 Experiment with ruff
The cool new Python linting tool.

"tox -e ruff" to check and
"tox -e ruff -- --fix" to auto-fix code.

This isn't approved in openstack/requirements at this time,
but developers might like trying it out.

Change-Id: I7d39f9043d607b174a53d804a57235a62bbfa6d8
2023-04-19 11:26:12 -04:00
Eric Harney 55b0d5e668 Bump pylint to 2.17.0
Change-Id: Ia18c839e7a3c23b6b2e50699522128e30096e13f
2023-03-09 15:56:50 -05:00
Eric Harney dc283a4177 Add tools/coding_checks.sh to pylint tox env
This must be listed in allowlist_externals for
the pylint env to run.

Change-Id: Ic68f52e684102c080dd81cc9197e8064ae1d4850
2023-01-20 09:43:17 -05:00
Eric Harney 0a9dde4ff8 tox: Remove [testenv] basepython setting
This causes commands like "tox -e py38" to run
the wrong python version in tox4.

It no longer needs to be specified here.

Change-Id: I01e7d03cee797af0fb9a335389328143b63e32ef
2023-01-04 10:12:47 -05:00
Brian Rosmaita d110b26a59 Get ready for tox 4
Changes:
- eliminate whitespace in passenv values
- account for stricter allowlist checking
- removed skipsdist=True, which in tox 4 appears to prevent cinder
  from being installed in the testenvs
- made 4.0.0 the tox minversion, which means tox will have to update
  itself until it's available in distros, which in turn means that
  the default install_command needs to be used in the base testenv,
  which means a new base pyXX testenv is added to include our
  install_command that includes upper constraints
- added install_command to most testenvs since they don't inherit
  the correct one from the base testenv any more

Not strictly necessary for this patch, but I did them anyway:
- moved the api-ref and releasenotes testenvs to be closer to
  the docs testenv
- added reno as a dep for the 'venv' testenv, which our contributor
  docs say should be used to generate a new release note from the
  reno template, and which has apparently been broken for a while

This patch makes tox 4 the default so that we can hopefully catch
problems locally before they block the gate.

Change-Id: I75e36fa100925bd486c9d4fdf8a33dd58347ce81
2022-12-20 21:27:34 -05:00
Zuul dcec2f6f01 Merge "Add doc8 check to docs builds" 2022-11-09 19:10:27 +00:00
Zuul b56147e3c3 Merge "Tests: Randomize tests" 2022-09-13 09:36:04 +00:00
Gorka Eguileor 31cce0257a Tests: Randomize tests
We've had broken unit tests for a long time, and we don't realize
because they are always being executed in the same order, and when they
start failing it's harder to understand WHY it is happening.

This patch forces all our unit tests runs to execute tests in a
randomized order to ensure we find bad tests faster.

Change-Id: I1d3107652b6bb9c9f83a54e307165aaa41f100fb
2022-08-29 17:10:02 +02:00
Gorka Eguileor 9dc820f2ae TOX: Document install_command usage
This patch documents in tox.ini the change introduced by change-id
Ic9a6ac412a334710eb5e45935cd301ca80a5edb9 where we use "install_command"
to prevent installing dependencies without constraints.

We document it to prevent people from thinking that just adding the
constraints in "deps" is enough and removing the "install_command" line.

Change-Id: Iccd84cb5d4db78e4953d58a05392c61b08988d4e
2022-08-24 17:46:00 +02:00
Brian Rosmaita 4bfd1c93a5 Add doc8 check to docs builds
Currently, doc8 only runs in the pep8 testenv.  Add it to the docs
testenv to make it easier not to submit a patch with an error.

Change-Id: Id8f348109443a7829b5dae91c74dd03c1ea89376
2022-07-21 17:38:59 -04:00
Zuul b24de11cea Merge "Move bandit requirements to tox.ini" 2022-07-11 18:28:48 +00:00
Eric Harney befa5b5be8 Move bandit requirements to tox.ini
This makes bandit requirements work like our
pylint requirements.  (Neither are handled
in the typical way by openstack/requirements.)

This prevents needless installation of bandit
for each unit test job run.

Change-Id: I513de53520a4531067cea4e7a225fb1ad2e9ba06
2022-06-27 10:51:48 -04:00
Stephen Finucane 238e7f8920 tests: Enable SQLAlchemy 2.0 deprecation warnings
Well, sort of. We enable them but immediately filter out the ones we're
actually seeing, the rationale being that we can address these in a
piecemeal fashion without the risk of introducing new issues.

There's a lot more to be done here. However, the work done in oslo.db
[1] should provide a guide for how to resolve the outstanding issues.

[1] https://review.opendev.org/q/topic:"sqlalchemy-20"+project:openstack/oslo.db

Change-Id: I9e8d3e3a82c51c3c008ef7380f2f619ed492205e
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2022-06-16 13:04:50 +01:00
Eric Harney 7851d9173d tox.ini: combine functional-py* envs
We can use tox's generative envlists instead
of duplicating these entries.

Change-Id: I992a0866abf36595821014f66cc437c3db52d898
2022-05-24 10:47:37 -04:00
Ghanshyam Mann 7755f8cdd4 Add releasenotes to drop python3.6|7
As per testing runtime for Zed cycle, below patch dropped the
support for python 3.6|7 and having a releasenotes for that will
be helpful for users.

- https://review.opendev.org/c/openstack/cinder/+/839469

[1] https://governance.openstack.org/tc/reference/runtimes/zed.html

Change-Id: I088d48efa1de74a24a365990a9396514a3a76ad2
2022-05-10 19:33:08 -05:00
Zuul d582844956 Merge "Stop removing .pyc files for unit test runs" 2022-04-29 17:59:56 +00:00
Zuul a4720d39a9 Merge "Run pylint tox env on all files by default" 2022-04-29 16:51:33 +00:00
Eric Harney 91085df702 Run pylint tox env on all files by default
The pylint tox env and job currently only run
on the files changed in HEAD.  This is confusing,
because changes regularly merge which introduce new
pylint errors, which will not show up in a pylint
run until another patch touches that file.

Instead, just run pylint on all of Cinder to get
consistent output.

Depends-On: Icb4c0b5cbba02c42e9e2ee381dc9152f1c1de22c
Depends-On: I3e17c6a2a7f252a9d324a1fea616e22869e55702
Change-Id: I98fd7f76e5d3d096970d6c5f1652e9ee2abeebd6
2022-04-27 12:42:04 -04:00
Eric Harney 5dbd94c73a Bump pylint to 2.13.4
Closes-Bug: #1968048
Change-Id: Ib5381834edf23a468ae05514a9accf22843b34f5
2022-04-06 11:24:27 -04:00
Eric Harney d54e6cc6b3 Stop removing .pyc files for unit test runs
We no longer need to do this.  If you run
"tox -e py38", "tox -e py39", and "tox -e py310",
you will see:

$ ls -l cinder/__pycache__/context*
 cinder/__pycache__/context.cpython-310.pyc
 cinder/__pycache__/context.cpython-38.pyc
 cinder/__pycache__/context.cpython-39.pyc

See PEP-3147 for details on this.

This is different from the older behavior, which
would generate cinder/context.pyc and collide between
different versions of Python.  In the versions of
Python that we support, no such collisions happen.

Change-Id: I1262c3ab355dfeabfa57184b6496d7fddd1e8055
2022-03-21 16:29:04 -04:00
Brian Rosmaita e87bc62f17 Update doc8 ignore-path
Ignore the entire .eggs directory.  It contains eggs downloaded by
setuptools to build, test, and run plugins, but more to the point,
it contains a README.TXT that violates D001 (Line too long).

Change-Id: I8f3f4bfb7d720e78d242fbb63d5bf457d8cfb2e2
2022-03-11 13:20:26 -05:00
Stephen Finucane 52370e58fe docs: Remove unnecessary 'blockstorage-' prefix
These are in the cinder doc tree so of course they're block
storage-related.

Change-Id: Ic1950ff89021a89de397619eef17f8100eb3d847
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2022-02-20 19:06:32 +00:00
Stephen Finucane 31303ed65e docs: Add whereto for testing redirect rules
Use whereto to test that the redirect rules do what we expect. This has
been used in nova-land for years and is helpful as things move around.

Change-Id: I4697c4ce53eb8d67d2f7593085e3eb88f239d1dd
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2022-02-20 19:05:46 +00:00
Takashi Kajinami a03e10ceb0 Use LOG.warning instead of deprecated LOG.warn
The LOG.warn method is deprecated[1] and the LOG.warning method should
be used instead.

[1] https://docs.python.org/3/library/logging.html#logging.warning

Change-Id: I87d33f215a064a70cea989d524dc26affeea0c3e
2022-02-09 08:29:02 +09:00
Ghanshyam Mann c064de2992 Updating python testing as per Yoga testing runtime
Yoga testing runtime[1] has been updated to add py39
testing as voting and as we are testing py3.6 and py3.9
we do not need to test py3.7|8 explicitly. Unit tests update are
handled by the job template change in openstack-zuul-job

- https://review.opendev.org/c/openstack/openstack-zuul-jobs/+/820286

this commit makes other required changes in zuul.yaml and
update the classifier in setup.cfg file.

[1] https://governance.openstack.org/tc/reference/runtimes/yoga.html

Change-Id: I9fe6187ea8c849812a508b48b342226e50fca831
2021-12-14 02:31:27 +00:00
Eric Harney 7135699870 pylint: Update to 2.11.1
pylint 2.7.4 fails to install due to dependency
conflicts.

Change-Id: I084a97fd8264a503f78082f0c05507c3aed82026
2021-11-11 10:53:35 -05:00
Brian Rosmaita c8c4fc953c Add installation of mypy stubs packages
The cinder-mypy job is failing because library stubs aren't installed
for requests [0].  Modify the mypywrap.sh to accept options specified
in an environment variable named OS_MYPY_OPTS to the mypy invocation,
and set this var in tox.ini.

The value is "--install-types --non-interactive" which is suitable for
CI purposes, and seems to make sense for local tox use as well [1].
The downside is it basically runs mypy twice, once to determine
whether there are any library stubs missing and then install them, and
againto do the actual check.  If we don't want this setting in
tox.ini, we can move it to .zuul.yaml for the cinder-mypy job run.

Also, update the version of mypy in test-requirements to a version
that supports the above options.

And, run mypy in its own env (instead of reusing pep8) so that the
tox logs are preserved during CI runs.

[0] https://zuul.opendev.org/t/openstack/build/b66ee6c21e594940941585b0e9e5082a
[1] https://mypy.readthedocs.io/en/stable/running_mypy.html#library-stubs-not-installed

Change-Id: Id69cb519ee7300b33ff087de4e7d46cdad67d162
2021-07-15 10:33:36 -04:00
Yandong Xuan b604a3bf66 Drop lower-constraints jobs
Change-Id: I994af226743a50f11d89373868e588d0d0313785
2021-07-07 16:30:03 -04:00
Eric Harney 91b133d825 Update to pylint 2.7.4
Change-Id: Ia183937b80a28fcf0335c3adcbcab04a78810c21
2021-04-07 10:51:16 -04:00
tushargite96 7576313b9e Changed whitelist to allowlist in tox
Replace tox's whitelist_externals by allowlist_externals option:
https://github.com/tox-dev/tox/blob/master/docs/changelog.rst#v3180-2020-07-23

Change-Id: I4e85c700278fbd68ea38b0c5b036db2c2a72ef76
2021-03-17 11:08:56 +05:30
Zuul 63a79f2071 Merge "Add virtualenv requirement to tox.ini" 2021-03-16 21:13:21 +00:00
Gorka Eguileor 5ad7fe9269 Always constraint dependencies in tox
For most of our tox jobs we use the usedevelop, which means that tox
will do a pip install -e on our source code on its own.

This means that first it will install deps (which has the constraints)
and then cinder without constraints, since they are defined in deps, and
will pull cinder dependencies ignoring the constraints.

This patch changes how we install dependencies for all tox jobs except
the lower-constraints one, and will make sure that they are always
properly constrained by changing our install_command to include the -c
option.

Change-Id: Ic9a6ac412a334710eb5e45935cd301ca80a5edb9
2021-03-16 17:13:36 +01:00
Brian Rosmaita 6ff5591fce Add virtualenv requirement to tox.ini
We're getting divergence between local test runs and the gate based
on what version of pip is being used by tox, which depends on what
version of virtualenv (which specifies the versions of pip,
setuptools, and wheel) that tox uses in your local environment.  To
eliminate guesswork, tell tox what version of virtualenv it should
use.  Also specify a minversion of tox that can do this.

Change-Id: I01451ec27d3ad6e759636902e497272a89cf6d16
2021-03-15 23:28:04 -04:00
zhangboye dc938a4056 Use TOX_CONSTRAINTS_FILE
UPPER_CONSTRAINTS_FILE is old name and deprecated
This allows to use upper-constraints file as more
readable way instead of UPPER_CONSTRAINTS_FILE=<lower-constraints file>.

Change-Id: I6fad95580906434feeaf5a51e172ed7045f0e7f4
2021-02-19 23:22:37 +01:00
Zuul ebc6a0431c Merge "Remove install unnecessary packages" 2021-02-19 22:18:30 +00:00
Zuul 3d67140cb7 Merge "tox mypy: Call mypywrap.sh directly" 2021-02-19 21:26:28 +00:00
Eric Harney 2563dd3a12 Bump pylint to 2.6.0
Upgrade from pylint 2.3.0 to 2.6.0.

Fixes a small bug revealed in test_lvm_driver.py.

Change-Id: Ia7eec6440c88246cdc6018f2f238c1b90b1d1b48
2021-02-11 13:55:50 -05:00
Eric Harney d9c90cf488 tox mypy: Call mypywrap.sh directly
Tox issues a warning because bash is not
in whitelist_externals and indicates that this
will fail in tox 4+.

Just call mypywrap.sh directly to prevent this.

Change-Id: I3c1747b255338d189806b331ae6a3c1b37e6d744
2021-01-05 09:50:07 -05:00
Zuul b7b40ca1b7 Merge "tox: remove bash from whitelist_externals" 2020-11-03 19:27:54 +00:00
Zuul 2fa889e2f1 Merge "Make docs build parallel" 2020-10-26 22:36:42 +00:00
Sean McGinnis e68d33ef68
Make docs build parallel
This updates our thread extension and tox command for docs builds to use
the available number of cores to multithread the docs build. This can
speed things up significantly.

Depends-on: https://review.opendev.org/741026

Change-Id: I1ba656390094b4e1c6d3fb7bb3028eadb11c4d08
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-10-22 10:28:01 -05:00
Eric Harney 6e53c264b6 Add mypy tox env
Add a "mypy" tox environment which runs mypy
type checking against Cinder code.

Taken from Stephen Finucane's Nova work at
https://review.opendev.org/#/c/676208/

Added "show_error_codes" and "pretty" options.

Generates an html report in ./mypy-report/

This adds stubs for oslo.i18n, so that _() calls
are annotated as intended.  It may be possible to
do this with less .pyi files carried along here.

Change-Id: I2589d22c1f16f2e177d34730a520591743c0c1e3
2020-10-14 08:24:13 -04:00
Zuul 0d65472cf1 Merge "Stop configuring install_command in tox." 2020-10-06 18:26:08 +00:00