Commit Graph

19 Commits

Author SHA1 Message Date
Hervé Beraud 2f4cb354f7 Adding pre-commit
Introduced changes:
- pre-commit config and rules
- Add pre-commit to pep8 gate, Flake8 is covered in the pre-commit hooks.
- Applying fixes for pre-commit compliance in all code.

Also commit hash will be used instead of version tags in pre-commit to
prevend arbitrary code from running in developer's machines.

pre-commit will be used to:
- trailing whitespace;
- Replaces or checks mixed line ending (mixed-line-ending);
- Forbid files which have a UTF-8 byte-order marker (check-byte-order-marker);
- Checks that non-binary executables have a proper
  shebang (check-executables-have-shebangs);
- Check for files that contain merge conflict strings (check-merge-conflict);
- Check for debugger imports and py37+ breakpoint()
  calls in python source (debug-statements);
- Attempts to load all yaml files to verify syntax (check-yaml);
- Run flake8 checks (flake8) (local)

For further details about tests please refer to:
https://github.com/pre-commit/pre-commit-hooks

Change-Id: Icd2a9bded756b2bcba1fb7da6abe48503fd9b2d6
Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
2020-09-15 17:10:31 +02:00
Hervé Beraud 5a0d3c2fa5 Stop to use the __future__ module.
The __future__ module [1] was used in this context to ensure compatibility
between python 2 and python 3.

We previously dropped the support of python 2.7 [2] and now we only support
python 3 so we don't need to continue to use this module and the imports
listed below.

Imports commonly used and their related PEPs:
- `division` is related to PEP 238 [3]
- `print_function` is related to PEP 3105 [4]
- `unicode_literals` is related to PEP 3112 [5]
- `with_statement` is related to PEP 343 [6]
- `absolute_import` is related to PEP 328 [7]

[1] https://docs.python.org/3/library/__future__.html
[2] https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html
[3] https://www.python.org/dev/peps/pep-0238
[4] https://www.python.org/dev/peps/pep-3105
[5] https://www.python.org/dev/peps/pep-3112
[6] https://www.python.org/dev/peps/pep-0343
[7] https://www.python.org/dev/peps/pep-0328

Change-Id: Ia9cdcfb75cc91dc5f93f02d07ad389c8c7d622fe
2020-06-02 20:42:08 +02:00
Stephen Finucane 90d1c48143 tools: Default to Python 3
It's nearly 2020. This should be the default now.

Change-Id: Ia43fb5bf3c7eede7a8f1cf254cd6de8dace25bd8
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-12-18 14:45:34 +00:00
Thomas Goirand 644a3e4376 Invoke correct python version in shell scripts
The oslotest shell scripts were using /usr/bin/python by default, and did
take into account the $PYTHON variable, so one could choose to use
Python 3 instead of Python 2.

This patch looks if a $PYTHON variable exists. If not, then it sets it
to "python" by default, otherwise, it uses whatever exists, so it is now
possible to do PYTHON=python3 oslo_debug_helper for starting tests.

Change-Id: I6df0ac0d84fd964251a1af9e27dadb954a2ad691
2019-12-18 14:45:15 +00:00
Andreas Jaeger 88dc78c494 Avoid tox_install.sh for constraints support
We do not need tox_install.sh, pip can handle constraints itself
and install the project correctly. Thus update tox.ini and remove
the now obsolete tools/tox_install.sh file.

This follows https://review.openstack.org/#/c/508061 to remove
tools/tox_install.sh.

Change-Id: Iafae5f3111c968a4ec2adf63e447459f3ccc41ae
2017-12-01 09:54:17 +01:00
Tony Breeds 4fbb2c86e3 Add Constraints support
Adding constraints support to libraries is slightly more complex than
services as the libraries themselves are listed in upper-constraints.txt
which leads to errors that you can't install a specific version and a
constrained version.

This change adds constraints support by also adding a helper script to
edit the constraints to remove oslotest.

Change-Id: I21e2d0555334a1bd7ad8aa37796f599292b30ed0
2016-12-20 14:37:57 +11:00
Doug Hellmann ac796613b4 always rebuild cross-test venv
Always rebuild the environment where the test is running in case the
requirements list for the project has changed.

Change-Id: I02148398389656d7cf5b811d94ebbbdc32c417fa
2015-06-16 14:21:51 +00:00
Doug Hellmann ff9b38ecf4 Fix argument handling in oslo_run_cross_tests
If there are no arguments the shift call fails, aborting before we can
report the proper usage instructions. Update the script to check the
argument count before trying to do anything with them.

Change-Id: I3eb7cdf96dcbe6368e2ad0fbc9d0514798292e8e
2015-06-04 17:43:30 +00:00
Doug Hellmann f74e974084 Force rebuild egg-info before running cross tests
Sometimes we don't get the latest version of the source list if we don't
force it to be rebuilt.

Change-Id: Ia80a71762a3824bc6c9a63a834e54100b649bd66
2015-02-23 12:59:30 -05:00
Doug Hellmann 9f502535e4 Restore missing module for pre-release test script
Restore a module missing from the pre-release test script so the version
in oslotest is usable.

Change-Id: I300318c9e051204677824d52afaa211a91e97bc0
2015-02-20 12:47:00 -05:00
Doug Hellmann c69ddb9396 Move the script for running pre-releases into oslotest
Rather than maintaining the pre-release runner in oslo-incubator, put it
in oslotest where it can be installed with the rest of the library.

Change-Id: Idd58bfe3950d01725e239608f263dab5a0c9c908
2015-01-30 15:03:09 -05:00
Doug Hellmann e50b8b390e Publish cross-test runner as part of oslotest
Move the latest version of run_cross_test.sh from the incubator here to
oslotest and rename it so we can publish it as a tool that comes with
oslotest instead of syncing it into the other projects.

Change-Id: I1aec3bda9e46b1667cfd7b68aa2d654327d1c8fb
2015-01-30 12:15:19 -05:00
Davanum Srinivas baf76c5986 Fix for mktemp failure on osx
Closes-Bug: #1404422
Change-Id: I445c2a24850059897b4e76ff29ef77f3baf84021
2014-12-19 19:43:11 -05:00
Steve Martinelli e5c14b74d3 Add an extra parameter for test directory in debugger script
The `python-*client`'s usually give back the full package name
i.e. python-keystoneclient, and the script assumes thats where
the tests are, but most clients have their tests under just
*client, or in this case keystoneclient.
Oslo projects have a similar issue.
Change the debug script to accept an optional argument that can
be used to override the guesstimated value.

Change-Id: If0a25ae7ab9f854f87271a377dd228e2ebfb107f
2014-09-29 21:50:41 -04:00
Steve Martinelli b2f8b9dd9b Drop .sh extension from oslo_debug_helper.sh
To be compliant with Debian policy on naming binary files, the
shell file should not have a .sh extension.

Change-Id: I4549c6942b1367c7e490e48ed275ff6a3bcddfa5
Closes-Bug: #1370488
2014-09-18 21:42:32 -04:00
Steve Martinelli 48955949b3 Add documentation for running oslo_debug_heler.sh
Removed inline comments from the shell file and added them to
the developer docs.

Change-Id: Iac0f969165883e173389a42e1bd1b0bc5d513553
2014-08-25 17:18:11 -04:00
Steve Martinelli b371ea2373 Add pdb support to tox with debug helper shell script
The Keystone team has been using a home brewed `debug_helper.sh`
file to run tests with pdb support, it's now being also used by
pycadf too. As noted by bnemec [1] we should move this to oslo.
[1] https://bugs.launchpad.net/pycadf/+bug/1354192

To run any test in particular, run tox with -e debug:
  `tox -e debug`

It also supports passing in a specific test module, class or case.
The shell file runs testtools underneath the covers to get pdb
support.

Change-Id: Idb715bc137459a2f6d16ac3f65c718a567df49ff
Co-Authored-By: Brant Knudson <bknudson@us.ibm.com>
2014-08-25 12:36:02 -04:00
Doug Hellmann 588fba7bde Import run_cross_tests.sh from oslo-incubator
Replace the local version of run_cross_tests.sh with
the version in oslo-incubator.

Depends on https://review.openstack.org/#/c/83411/
and https://review.openstack.org/#/c/83412/

Change-Id: I3d3e25f92ab6337432b54967a381662f32902a6d
2014-03-27 08:02:02 -07:00
Doug Hellmann 9cec897ed1 Add tool to run cross-project tests
Provide a script for the devstack-gate hook to run tests to
ensure that changes in this project do not break unit tests
in consuming projects.

See https://review.openstack.org/#/c/76381 for the script
addition in the gate configuration.

Change-Id: I08d8380183c2128c62fa0ca52306950d8076f3c2
2014-02-27 09:05:04 -08:00