#82 Modernize project layout in various ways
Merged 4 years ago by adamwill. Opened 4 years ago by adamwill.

file removed
-6
@@ -1,6 +0,0 @@ 

- {

-     "project_id" : "fedora_openqa",

-     "conduit_uri" : "https://phab.qa.fedoraproject.org",

-     "arc.land.onto.default" : "master",

-     "arc.feature.start.default" : "master"

- }

file added
+4
@@ -0,0 +1,4 @@ 

+ exclude .gitignore

+ exclude MANIFEST.in

+ exclude .zuul.yaml

+ recursive-exclude ci *

file modified
+3 -3
@@ -80,15 +80,15 @@ 

      echo "fas_username fas_password" > /etc/fedora/credentials

      chmod 0600 /etc/fedora/credentials

  

- This tool has its own configuration file which can be installed to `/etc/fedora-openqa/schedule.conf` or `~/.config/fedora-openqa/schedule.conf`. In this config file you can specify the locations of the wiki and ResultsDB instance that will be used when reporting results with `fedora-openqa report`; by default, results will be reported to the [staging wiki](https://stg.fedoraproject.org/wiki/) and to a ResultsDB instance running on localhost port 5001 (which is what you get if you follow the instructions to do a local deployment of ResultsDB for testing). A sample config file is provided as `schedule.conf.sample`, which you can copy into place and modify.

+ This tool has its own configuration file which can be installed to `/etc/fedora-openqa/schedule.conf` or `~/.config/fedora-openqa/schedule.conf`. In this config file you can specify the locations of the wiki and ResultsDB instance that will be used when reporting results with `fedora-openqa report`; by default, results will be reported to the [staging wiki](https://stg.fedoraproject.org/wiki/) and to a ResultsDB instance running on localhost port 5001 (which is what you get if you follow the instructions to do a local deployment of ResultsDB for testing). A sample config file is provided as `sample-configs/schedule.conf.sample`, which you can copy into place and modify.

  

- You can configure the set of images from each compose which will be downloaded and tested. For more details on this, see the comments in `images.json.sample`.

+ You can configure the set of images from each compose which will be downloaded and tested. For more details on this, see the comments in `sample-configs/images.json.sample`.

  

  To run openQA jobs whenever a compose completes, and to report results to a ResultsDB instance and/or a wiki, you can use the fedora-messaging systemd service pattern.

  

  **PLEASE NOTE** that there should never be more than one Fedora production Wiki or ResultsDB reporter enabled in the world, and both of these are run in the Fedora infrastructure, so please don't enable these on your own deployments. Reporting to your own wiki or ResultsDB instance for testing is of course fine.

  

- First, you need to install one or more consumer configuration files to `/etc/fedora-messaging`. There are sample files provided in this directory for Fedora production and staging configurations for the job scheduler, ResultsDB reporter and Wiki reporter:

+ First, you need to install one or more consumer configuration files to `/etc/fedora-messaging`. There are sample files provided in `sample-configs/` for Fedora production and staging configurations for the job scheduler, ResultsDB reporter and Wiki reporter:

  

      fedora_openqa_resultsdb_reporter.stg.toml

      fedora_openqa_resultsdb_reporter.toml

file modified
+3
@@ -31,6 +31,9 @@ 

  from wikitcms import wiki

  from wikitcms.exceptions import NotFoundError, TooManyError

  

+ # add src subdirectory directory to module import path

+ sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'src'))

+ 

  from fedora_openqa.conf_test_suites import (TESTCASES, TESTSUITES)

  import fedora_openqa.report as report

  

file modified
+6
@@ -1,5 +1,11 @@ 

  #!/usr/bin/python3

  

+ import os

+ import sys

+ 

+ # add src subdirectory directory to module import path

+ sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'src'))

+ 

  from fedora_openqa.cli import main

  

  if __name__ == '__main__':

file added
+14
@@ -0,0 +1,14 @@ 

+ [build-system]

+ requires = ["setuptools>=40.6.0", "setuptools-git", "wheel"]

+ build-backend = "setuptools.build_meta"

+ 

+ [tool.coverage.run]

+ parallel = true

+ branch = true

+ source = ["fedora_openqa"]

+ 

+ [tool.coverage.paths]

+ source = ["src", ".tox/*/site-packages"]

+ 

+ [tool.coverage.report]

+ show_missing = true

sample-configs/fedora_openqa_resultsdb_reporter.stg.toml fedora_openqa_resultsdb_reporter.stg.toml
file renamed
file was moved with no change to the file
sample-configs/fedora_openqa_resultsdb_reporter.toml fedora_openqa_resultsdb_reporter.toml
file renamed
file was moved with no change to the file
sample-configs/fedora_openqa_scheduler.stg.toml fedora_openqa_scheduler.stg.toml
file renamed
file was moved with no change to the file
sample-configs/fedora_openqa_scheduler.toml fedora_openqa_scheduler.toml
file renamed
file was moved with no change to the file
sample-configs/fedora_openqa_wiki_reporter.stg.toml fedora_openqa_wiki_reporter.stg.toml
file renamed
file was moved with no change to the file
sample-configs/fedora_openqa_wiki_reporter.toml fedora_openqa_wiki_reporter.toml
file renamed
file was moved with no change to the file
file renamed
file was moved with no change to the file
file renamed
file was moved with no change to the file
file modified
+12 -46
@@ -1,50 +1,15 @@ 

- import os

- import sys

- from setuptools import setup, find_packages

- from setuptools.command.test import test as TestCommand

+ from os import path

+ from setuptools import setup

  

+ HERE = path.abspath(path.dirname(__file__))

  

- class PyTest(TestCommand):

-     user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]

- 

-     def initialize_options(self):

-         TestCommand.initialize_options(self)

-         self.pytest_args = ''

-         self.test_suite = 'tests'

- 

-     def run_tests(self):

-         #import here, cause outside the eggs aren't loaded

-         import pytest

-         errno = pytest.main(self.pytest_args.split())

-         sys.exit(errno)

- 

- # Utility function to read the README file.

- # Used for the long_description.  It's nice, because now 1) we have a top level

- # README file and 2) it's easier to type in the README file than to put a raw

- # string in below. Stolen from

- # https://pythonhosted.org/an_example_pypi_project/setuptools.html

- def read(fname):

-     return open(os.path.join(os.path.dirname(__file__), fname)).read()

- 

- # this is sloppy and wrong, see https://stackoverflow.com/a/4792601

- # discussion, but should be okay for our purposes. the problem here

- # is that if you run 'python3 setup.py install' with all the install

- # requires in place, setuptools installs scripts from several of the

- # deps to /usr/local/bin , overriding the system copies in /usr/bin.

- # This seems to happen when the copy in /usr/bin is for Python 2 not

- # Python 3 - e.g. because /usr/bin/fedmsg-logger is Python 2, if you

- # do 'python3 setup.py install' here, due to the fedmsg dep, you get

- # a /usr/local/bin/fedmsg-logger which is Python 3...we want to be

- # able to avoid this, so hack up a 'no deps'

- if "--nodeps" in sys.argv:

-     INSTALLREQS = []

-     sys.argv.remove("--nodeps")

- else:

-     INSTALLREQS = open('install.requires').read().splitlines()

+ # Get the long description from the README file

+ with open(path.join(HERE, 'README.md'), encoding='utf-8') as f:

+     LONGDESC = f.read()

  

  setup(

      name="fedora_openqa",

-     version="3.0.0",

+     version="3.1.0",

      entry_points={

          'console_scripts': [

              'fedora-openqa = fedora_openqa.cli:main',
@@ -57,10 +22,11 @@ 

      keywords="fedora openqa test qa",

      url="https://pagure.io/fedora-qa/fedora_openqa",

      packages=["fedora_openqa"],

-     install_requires=INSTALLREQS,

-     tests_require=open('tests.requires').read().splitlines(),

-     cmdclass={'test': PyTest},

-     long_description=read('README.md'),

+     package_dir={"": "src"},

+     install_requires=open('install.requires').read().splitlines(),

+     python_requires="!=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4",

+     long_description=LONGDESC,

+     long_description_content_type='text/markdown',

      classifiers=[

          "Development Status :: 5 - Production/Stable",

          "Topic :: Utilities",

@@ -0,0 +1,22 @@ 

+ # Copyright (C) 2020 Red Hat

+ #

+ # This file is part of fedora_openqa.

+ #

+ # fedora_openqa is free software; you can redistribute it

+ # and/or modify it under the terms of the GNU General Public License

+ # as published by the Free Software Foundation, either version 3 of

+ # the License, or (at your option) any later version.

+ #

+ # This program is distributed in the hope that it will be useful,

+ # but WITHOUT ANY WARRANTY; without even the implied warranty of

+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ # GNU General Public License for more details.

+ #

+ # You should have received a copy of the GNU General Public License

+ # along with this program.  If not, see <http://www.gnu.org/licenses/>.

+ #

+ # Author(s):    Adam Williamson <awilliam@redhat.com>

+ 

+ """Fedora openQA scheduler and result reporter."""

+ 

+ __version__ = "3.1.0"

src/fedora_openqa/cli.py fedora_openqa/cli.py
file renamed
file was moved with no change to the file
src/fedora_openqa/conf_test_suites.py fedora_openqa/conf_test_suites.py
file renamed
file was moved with no change to the file
src/fedora_openqa/config.py fedora_openqa/config.py
file renamed
file was moved with no change to the file
src/fedora_openqa/consumer.py fedora_openqa/consumer.py
file renamed
file was moved with no change to the file
src/fedora_openqa/report.py fedora_openqa/report.py
file renamed
file was moved with no change to the file
src/fedora_openqa/schedule.py fedora_openqa/schedule.py
file renamed
file was moved with no change to the file
file modified
-1
@@ -1,2 +1,1 @@ 

  pytest

- mock

file modified
+1 -1
@@ -25,10 +25,10 @@ 

  # stdlib imports

  import json

  import os

+ from unittest import mock

  

  # external imports

  import fedfind.release

- import mock

  import pytest

  

  

file modified
+1 -1
@@ -26,9 +26,9 @@ 

  from __future__ import print_function

  

  # stdlib imports

+ from unittest import mock

  

  # external imports

- import mock

  import pytest

  

  # 'internal' imports

file modified
+1 -1
@@ -27,10 +27,10 @@ 

  

  # stdlib imports

  import copy

+ from unittest import mock

  

  # external imports

  from fedora_messaging.api import Message

- import mock

  import pytest

  

  # 'internal' imports

file modified
+1 -1
@@ -27,9 +27,9 @@ 

  

  # stdlib imports

  import copy

+ from unittest import mock

  

  # external imports

- import mock

  import openqa_client.client

  import pytest

  import resultsdb_api

file modified
+1 -1
@@ -26,11 +26,11 @@ 

  from __future__ import print_function

  

  # stdlib imports

+ from unittest import mock

  

  # external imports

  import fedfind.release

  import openqa_client

- import mock

  import pytest

  

  # 'internal' imports

file modified
+6 -5
@@ -1,7 +1,8 @@ 

  [tox]

- skipsdist = True

  envlist = py37,py38,py39

  skip_missing_interpreters = true

+ isolated_build = true

+ 

  [testenv]

  deps =

      -r{toxinidir}/install.requires
@@ -9,9 +10,9 @@ 

      -r{toxinidir}/tox.requires

  

  commands=

-     py.test

-     py.test --cov-report term-missing --cov-report xml --cov fedora_openqa

+     coverage run -m pytest {posargs}

+     coverage combine

+     coverage report

+     coverage xml

      diff-cover coverage.xml --fail-under=90

      diff-quality --violations=pylint --fail-under=90

- setenv =

-     PYTHONPATH = {toxinidir}

file modified
-1
@@ -1,4 +1,3 @@ 

  coverage

  diff-cover

  pylint

- pytest-cov

This PR contains various modernizations to the project layout, setup.py, CI config etc. to try and adopt current best practices for Python projects and drop some old clunky bits we don't need any more.

Build failed.

7 new commits added

  • Bump version to 3.1.0, add proper __init__.py
  • Simplify and modernize setup.py, drop setup.py test support
  • Import mock from stdlib
  • Remove Phabricator-remnant .arcconfig
  • Add a MANIFEST.in to exclude various things from the sdist
  • Move module under src/, add pyproject.toml, drop pytest-cov
  • Move sample configs to a subdirectory
4 years ago

Build succeeded.

Pull-Request has been merged by adamwill

4 years ago
Changes Summary 31
-6
file removed
.arcconfig
+4
file added
MANIFEST.in
+3 -3
file changed
README.md
+3 -0
file changed
checkwiki
+6 -0
file changed
fedora-openqa.py
-0
file removed
fedora_openqa/__init__.py
+14
file added
pyproject.toml
+0 -0
file renamed
fedora_openqa_resultsdb_reporter.stg.toml
sample-configs/fedora_openqa_resultsdb_reporter.stg.toml
+0 -0
file renamed
fedora_openqa_resultsdb_reporter.toml
sample-configs/fedora_openqa_resultsdb_reporter.toml
+0 -0
file renamed
fedora_openqa_scheduler.stg.toml
sample-configs/fedora_openqa_scheduler.stg.toml
+0 -0
file renamed
fedora_openqa_scheduler.toml
sample-configs/fedora_openqa_scheduler.toml
+0 -0
file renamed
fedora_openqa_wiki_reporter.stg.toml
sample-configs/fedora_openqa_wiki_reporter.stg.toml
+0 -0
file renamed
fedora_openqa_wiki_reporter.toml
sample-configs/fedora_openqa_wiki_reporter.toml
+0 -0
file renamed
images.json.sample
sample-configs/images.json.sample
+0 -0
file renamed
schedule.conf.sample
sample-configs/schedule.conf.sample
+12 -46
file changed
setup.py
+22
file added
src/fedora_openqa/__init__.py
+0 -0
file renamed
fedora_openqa/cli.py
src/fedora_openqa/cli.py
+0 -0
file renamed
fedora_openqa/conf_test_suites.py
src/fedora_openqa/conf_test_suites.py
+0 -0
file renamed
fedora_openqa/config.py
src/fedora_openqa/config.py
+0 -0
file renamed
fedora_openqa/consumer.py
src/fedora_openqa/consumer.py
+0 -0
file renamed
fedora_openqa/report.py
src/fedora_openqa/report.py
+0 -0
file renamed
fedora_openqa/schedule.py
src/fedora_openqa/schedule.py
+0 -1
file changed
tests.requires
+1 -1
file changed
tests/conftest.py
+1 -1
file changed
tests/test_cli.py
+1 -1
file changed
tests/test_consumers.py
+1 -1
file changed
tests/test_report.py
+1 -1
file changed
tests/test_schedule.py
+6 -5
file changed
tox.ini
+0 -1
file changed
tox.requires