From dfd35aeee9402dba7e9c83d96571d4a5dfc3c171 Mon Sep 17 00:00:00 2001 From: Adrian Vladu Date: Tue, 3 Oct 2023 17:16:32 +0300 Subject: [PATCH] unit_tests: github_actions: add tox py3 run Added github actions run for Python 3.8-3.11 with working test-requirements.txt. --- .github/workflows/unit-tests.yml | 26 ++++++++++++------ .stestr.conf | 3 +++ test-requirements.txt | 15 ++++++----- tox.ini | 45 ++++++++++++++++---------------- 4 files changed, 52 insertions(+), 37 deletions(-) create mode 100644 .stestr.conf diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 1969f272a..5b38de01f 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -10,15 +10,25 @@ permissions: jobs: build: - - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11"] + architecture: ["x64"] steps: - - uses: actions/checkout@v3 - - name: Install dependencies + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + architecture: ${{ matrix.architecture }} + - name: Install python3 tox + shell: bash run: | - pip install -r requirements.txt - pip install -r test-requirements.txt - - name: Run unit tests + python3 -m pip install tox + - name: Run unit tests with tox + shell: bash run: | - python -m nose -v --nocapture --logging-level=ERROR coriolis/tests + tox -e py3 -v diff --git a/.stestr.conf b/.stestr.conf new file mode 100644 index 000000000..ba79c94c4 --- /dev/null +++ b/.stestr.conf @@ -0,0 +1,3 @@ +[DEFAULT] +test_path=${OS_TEST_PATH:-./coriolis/tests} +top_dir=./ diff --git a/test-requirements.txt b/test-requirements.txt index 387aeab36..fea111a77 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,7 +1,10 @@ -coverage -ddt -discover -nose -oslotest +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. + +hacking>=6.0.1,<=6.0.1 # Apache-2.0 +coverage!=4.4,>=4.0 # Apache-2.0 +ddt>=1.2.1 # MIT +oslotest>=3.8.0 # Apache-2.0 +stestr>=2.0.0 # Apache-2.0 -hacking>=0.12.0,<0.13 # Apache-2.0 diff --git a/tox.ini b/tox.ini index 74e3fba6d..a3f8b22ac 100644 --- a/tox.ini +++ b/tox.ini @@ -1,37 +1,36 @@ [tox] -minversion = 2.0 -envlist = py35,py27,pep8 +minversion = 4.0.2 +envlist = py3,pep8,flake8,cover skipsdist = True [testenv] usedevelop = True -whitelist_externals = rm -install_command = pip install {opts} {packages} -setenv = - VIRTUAL_ENV={envdir} - BRANCH_NAME=master - CLIENT_NAME=coriolis-core - DEFAULT_REPO=git@bitbucket.org:cloudbase - PYTHONWARNINGS=default::DeprecationWarning -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt -commands = - python setup.py test --slowest --testr-args='{posargs}' - rm -f .testrepository/times.dbm +setenv = VIRTUAL_ENV={envdir} +deps = + -r{toxinidir}/test-requirements.txt + -r{toxinidir}/requirements.txt +commands = stestr run --slowest {posargs} [testenv:pep8] commands = flake8 {posargs} +[testenv:cover] +setenv = + {[testenv]setenv} + PYTHON=coverage run --source coriolis --parallel-mode +commands = + stestr run --no-subunit-trace {posargs} + coverage combine + coverage report --fail-under=82 --skip-covered + coverage html -d cover + coverage xml -o cover/coverage.xml + [testenv:venv] commands = {posargs} -[testenv:cover] -commands = python setup.py test --coverage --testr-args='{posargs}' - [flake8] -# E123, E125 skipped as they are invalid PEP-8. +# E125 is deliberately excluded. See https://github.com/jcrocholl/pep8/issues/126 +# E251 Skipped due to https://github.com/jcrocholl/pep8/issues/301 -show-source = True -ignore = E123,E125 -builtins = _ -exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build +ignore = E125,E251,W503,W504,E305,E731,E117,W605,F632 +exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools