diff --git a/Dockerfile b/Dockerfile index 26cead04..78b36546 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,19 +4,14 @@ RUN apk update \ && apk add --no-cache --virtual .build-deps git g++ postgresql-dev yaml-dev \ && apk add --no-cache libpq -WORKDIR /var/src/lnt +COPY . /var/src/lnt -COPY requirements*.txt setup.py . -# setup.py uses lnt.__version__ etc. -COPY lnt/__init__.py lnt/__init__.py -# we build the cperf extension during install -COPY lnt/testing/profile lnt/testing/profile +WORKDIR /var/src/lnt RUN pip3 install -r requirements.server.txt \ && apk --purge del .build-deps \ && mkdir /var/log/lnt -COPY . . COPY docker/docker-entrypoint.sh docker/wait_db /usr/local/bin/ VOLUME /var/log diff --git a/docs/developer_guide.rst b/docs/developer_guide.rst index dd6aea14..01eb0693 100644 --- a/docs/developer_guide.rst +++ b/docs/developer_guide.rst @@ -34,10 +34,8 @@ To run the tests, we recomment using ``tox`` in a virtual environment:: You can also run individual unit tests with ``lit`` directly:: - pip install lit - lit -sv ./tests - -However, that requires manually setting up the testing environment (``filecheck``, etc). + pip install ".[dev]" + lit -sv tests For simple changes, adding a regression test and making sure all regression tests pass, is often a good enough testing approach. For some changes, the diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index dda49c57..00000000 --- a/mypy.ini +++ /dev/null @@ -1,2 +0,0 @@ -[mypy] -plugins = sqlmypy diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..4a1f050a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,154 @@ +[build-system] +requires = ["setuptools >= 74.1"] +build-backend = "setuptools.build_meta" + +[project] +name = "LNT" +version = "0.4.2.dev0" +description = "LLVM Nightly Test Infrastructure" +readme = "README.md" +license = "LicenseRef-Apache-2.0-with-LLVM-exception" +license-files = ["LICENSE.TXT"] +authors = [ + { name = "Daniel Dunbar", email = "daniel@zuster.org" }, +] +maintainers = [] +keywords = ["web", "testing", "performance", "development", "llvm"] +classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Web Environment", + "Intended Audience :: Developers", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development :: Quality Assurance", + "Topic :: Software Development :: Testing", +] +requires-python = ">=3.10" +dependencies = [ + "aniso8601>=1.2.0", + "certifi", + "click>=8.1.0", + "Flask-RESTful>=0.3.10", + "Flask-WTF>=1.2.0", + "Flask>=3.1.0", + "Jinja2>=3.1.0", + "MarkupSafe>=3.0.0", + "python-gnupg>=0.3.7", + "PyYAML>=6.0.0", + "requests", + "SQLAlchemy==1.3.24", + "typing", + "Werkzeug>=3.1.0", + "WTForms>=3.2.0", +] + +[project.urls] +Homepage = "https://llvm.org" +Documentation = "https://llvm.org/docs/lnt" +Repository = "https://github.com/llvm/llvm-lnt" +"Bug Reports" = "https://github.com/llvm/llvm-lnt/issues" + +[project.scripts] +lnt = "lnt.lnttool:main" + +[project.optional-dependencies] +server = [ + "gunicorn>=19.9.0", + "psycopg2>=2.9.0", +] +dev = [ + "filecheck", + "Flake8-pyproject", + "flake8", + "lit", + "tox", +] + +[tool.setuptools] +ext-modules = [ + {name = "lnt.testing.profile.cPerf", sources = ["lnt/testing/profile/cPerf.cpp"]} +] + +[tool.setuptools.packages] +find = {namespaces = false} + +[tool.setuptools.package-data] +"lnt.server.ui" = [ + "static/*.ico", + "static/*.js", + "static/*.css", + "static/*.svg", + "static/bootstrap/css/*.css", + "static/bootstrap/js/*.js", + "static/bootstrap/img/*.png", + "static/flot/*.min.js", + "static/plotly/*.min.js", + "static/d3/*.min.js", + "static/jquery/**/*.min.js", + "templates/*.html", + "templates/reporting/*.html", + "templates/reporting/*.txt", +] +"lnt.server.db" = [ + "migrations/*.py" +] + +[tool.flake8] +ignore = ["E712", "E402", "E711", "E266", "W605", "E126", "E226", "W504"] +max-line-length = 120 +count = true + +[tool.mypy] +plugins = ["sqlmypy"] + +[tool.tox] +env_list = ["py3", "mypy", "flake8", "docs"] + +[tool.tox.env.py3] +description = "Run the unit tests" +allowlist_externals = ["rm", "lit"] +# TODO: Make it possible to run the tests without pinning down all dependencies +deps = [ + "-r requirements.txt", + ".[dev]", +] +commands = [ + ["rm", "-rf", "test_run_tmp"], + ["lit", "-sv", "tests"], +] + +[tool.tox.env.flake8] +description = "Run linter on the codebase" +deps = [".[dev]"] +commands = [["flake8", "--statistics", "--exclude=./lnt/external/", "./lnt/", "./tests/", "./deployment/"]] +skip_install = true + +[tool.tox.env.mypy] +description = "Typecheck the codebase" +# TODO: Make it possible to install [.dev] dependencies instead +deps = [ + "mypy >= 0.910", + "sqlalchemy-stubs", + "types-certifi", + "types-PyYAML", +] +# The option --no-incremental is currently needed to suppress warnings +# about UpdatedBase when running tests several times. Future versions of +# mypy should be checked to see if it can be removed and not get +# warnings after running tox several times. +commands = [["mypy", "--no-incremental", "--ignore-missing-imports", "lnt"]] +skip_install = true + +[tool.tox.env.docs] +description = "Build the documentation" +deps = [ + "sphinx==7", + "sphinx_bootstrap_theme", +] +allowlist_externals = ["make"] +commands = [["make", "-C", "{toxinidir}/docs/", "html"]] +skip_install = true diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 56afb0b8..00000000 --- a/setup.cfg +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -ignore = E712,E402,E711, E266, W605, E126, E226, W504 -max-line-length = 120 -count = True \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 10288863..00000000 --- a/setup.py +++ /dev/null @@ -1,134 +0,0 @@ -import lnt -import os -from sys import platform as _platform -import sys -from setuptools import setup, find_packages, Extension - -if sys.version_info < (3, 10): - raise RuntimeError("Python 3.10 or higher required.") - -cflags = [] - -if _platform == "darwin": - os.environ["CC"] = "xcrun --sdk macosx clang" - os.environ["CXX"] = "xcrun --sdk macosx clang" - cflags += ['-stdlib=libc++', '-mmacosx-version-min=10.7'] - -cPerf = Extension('lnt.testing.profile.cPerf', - sources=['lnt/testing/profile/cPerf.cpp'], - extra_compile_args=['-std=c++11'] + cflags) - -if "--server" in sys.argv: - sys.argv.remove("--server") - print("Use pip to install requirements.server.txt for a full server install:") - print("pip install -r ./requirements.server.txt") - sys.exit(1) - - -setup( - name="LNT", - version=lnt.__version__, - - author=lnt.__author__, - author_email=lnt.__email__, - url='https://llvm.org', - license='Apache-2.0 with LLVM exception', - - description="LLVM Nightly Test Infrastructure", - keywords='web testing performance development llvm', - long_description="""\ -*LNT* -+++++ - -About -===== - -*LNT* is an infrastructure for performance testing. The software itself -consists of two main parts, a web application for accessing and visualizing -performance data, and command line utilities to allow users to generate and -submit test results to the server. - -The package was originally written for use in testing LLVM compiler -technologies, but is designed to be usable for the performance testing of any -software. - - -Documentation -============= - -The official *LNT* documentation is available online at: - https://llvm.org/docs/lnt - - -Source -====== - -The *LNT* source is available in the llvm-lnt repository: - https://github.com/llvm/llvm-lnt -""", - - classifiers=[ - 'Development Status :: 4 - Beta', - 'Environment :: Web Environment', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: Apache-2.0 with LLVM exception', - 'Natural Language :: English', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Topic :: Software Development :: Quality Assurance', - 'Topic :: Software Development :: Testing', - ], - - zip_safe=False, - - # Additional resource extensions we use. - package_data={'lnt.server.ui': ['static/*.ico', - 'static/*.js', - 'static/*.css', - 'static/*.svg', - 'static/bootstrap/css/*.css', - 'static/bootstrap/js/*.js', - 'static/bootstrap/img/*.png', - 'static/flot/*.min.js', - 'static/plotly/*.min.js', - 'static/d3/*.min.js', - 'static/jquery/**/*.min.js', - 'templates/*.html', - 'templates/reporting/*.html', - 'templates/reporting/*.txt'], - 'lnt.server.db': ['migrations/*.py'], - }, - - packages=find_packages(), - - test_suite='tests.test_all', - - entry_points={ - 'console_scripts': [ - 'lnt = lnt.lnttool:main', - ], - }, - install_requires=[ - "aniso8601", - "certifi", - "click", - "Flask-RESTful", - "Flask-WTF", - "Flask", - "Jinja2", - "MarkupSafe", - "python-gnupg", - "pyyaml", - "requests", - "SQLAlchemy", - "typing", - "Werkzeug", - "WTForms", - ], - - ext_modules=[cPerf], - - python_requires='>=3.10', -) diff --git a/tox.ini b/tox.ini deleted file mode 100644 index daac030b..00000000 --- a/tox.ini +++ /dev/null @@ -1,63 +0,0 @@ -[tox] -envlist = py3 - mypy - flake8 - docs - -[testenv] -allowlist_externals = - rm - make - -commands = - rm -rf ./test_run_tmp - lit -sv ./tests/ - -[testenv:mypy] -basepython = python3 -skip_install = true -deps = - mypy >= 0.910 - sqlalchemy-stubs - types-PyYAML - types-certifi - -commands = - # The option --no-incremental is currently needed to suppress warnings - # about UpdatedBase when running tests several times. Future versions of - # mypy should be checked to see if it can be removed and not get - # warnings after running tox several times. - mypy --no-incremental --junit-xml=junit-{envname}.xml --ignore-missing-imports lnt - -[testenv:flake8] -skip_install = true -deps = - flake8 - -commands = - # Lets keep the clean files clean. - flake8 --statistics --exclude=./lnt/external/ ./lnt/ ./tests/ ./setup.py ./deployment/ - -[testenv:docs] -skip_install = true -deps = - sphinx==7 - sphinx_bootstrap_theme - -commands = - make -C {toxinidir}/docs/ html - -[testenv:py3] -deps = - -r requirements.txt - filecheck - lit - -[testenv:runserver] -# Don't use this for production. Just a handy target -# for local testing. -allowlist_externals = sh -commands = - sh -c "if [[ ! -e ./server_sandbox/ ]]; then lnt create ./server_sandbox/; fi" - - lnt runserver ./server_sandbox/