diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000..db24720 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1 @@ +comment: off diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..3fb28ae --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# Who is automatically assigned to the new PRs based on their content. +* @nolar diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..884e310 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: nolar diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..e06d419 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,9 @@ +## Long story short + + + + +## Description + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..4b01699 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,15 @@ + diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..7688b1e --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,86 @@ +name: CI +on: + pull_request: + branches: + - main + - release/** + workflow_dispatch: {} + +jobs: + linters: + name: Linting and static analysis + runs-on: ubuntu-20.04 + timeout-minutes: 5 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: "3.10" + - run: pip install -r requirements.txt + - run: pre-commit run --all-files + - run: mypy pytest_instant --strict + + unit-tests: + strategy: + fail-fast: false + matrix: + python-version: [ "3.7", "3.8", "3.9", "3.10" ] + name: Python ${{ matrix.python-version }} + runs-on: ubuntu-20.04 + timeout-minutes: 5 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - run: pip install -r requirements.txt + - run: pip install -e . + - run: pytest --color=yes --cov=pytest_instant --cov-branch + + - name: Publish coverage to Coveralls.io + if: success() + run: coveralls --service=github + env: + GITHUB_TOKEN: ${{ secrets.github_token }} + continue-on-error: true + - name: Publish coverage to CodeCov.io + uses: codecov/codecov-action@v1 + if: success() + env: + PYTHON: ${{ matrix.python-version }} + with: + flags: unit + env_vars: PYTHON + continue-on-error: true + + # No coverage: PyPy performs extremely poorly with tracing/coverage. + pypy-tests: + strategy: + fail-fast: false + matrix: + python-version: [ "pypy-3.7", "pypy-3.8" ] + name: Python ${{ matrix.python-version }} + runs-on: ubuntu-20.04 + timeout-minutes: 5 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - run: pip install -r requirements.txt + - run: pip install -e . + - run: pytest --color=yes --no-cov + + coveralls-finish: + name: Finalize coveralls.io + needs: [unit-tests] + runs-on: ubuntu-20.04 + steps: + - uses: actions/setup-python@v2 + - run: pip install coveralls + - run: coveralls --service=github --finish + env: + GITHUB_TOKEN: ${{ secrets.github_token }} + continue-on-error: true diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..1a2f551 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,26 @@ +name: Publish to PyPI +on: + release: + types: + - published +# push: +# tags: +# - "[0-9]+.[0-9]+*" + workflow_dispatch: {} + +jobs: + publish: + name: Build and publish + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: "3.10" + - run: pip install --upgrade setuptools wheel twine + - run: python setup.py sdist bdist_wheel + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.pypi_token }} + skip_existing: true diff --git a/.github/workflows/thorough.yaml b/.github/workflows/thorough.yaml new file mode 100644 index 0000000..ee7e7fd --- /dev/null +++ b/.github/workflows/thorough.yaml @@ -0,0 +1,88 @@ +name: Thorough tests +on: + push: + branches: + - main + - release/** + schedule: + - cron: "13 3 * * 6" + workflow_dispatch: {} + +jobs: + linters: + name: Linting and static analysis + runs-on: ubuntu-20.04 + timeout-minutes: 5 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: "3.10" + - run: pip install -r requirements.txt + - run: pre-commit run --all-files + - run: mypy pytest_instant --strict + + unit-tests: + strategy: + fail-fast: false + matrix: + python-version: [ "3.7", "3.8", "3.9", "3.10" ] + name: Python ${{ matrix.python-version }} + runs-on: ubuntu-20.04 + timeout-minutes: 5 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - run: pip install -r requirements.txt + - run: pip install -e . + - run: pytest --color=yes --cov=pytest_instant --cov-branch + + - name: Publish coverage to Coveralls.io + if: success() + run: coveralls --service=github + env: + GITHUB_TOKEN: ${{ secrets.github_token }} + continue-on-error: true + - name: Publish coverage to CodeCov.io + uses: codecov/codecov-action@v1 + if: success() + env: + PYTHON: ${{ matrix.python-version }} + with: + flags: unit + env_vars: PYTHON + continue-on-error: true + + # No coverage: PyPy performs extremely poorly with tracing/coverage. + pypy-tests: + strategy: + fail-fast: false + matrix: + python-version: [ "pypy-3.7", "pypy-3.8" ] + name: Python ${{ matrix.python-version }} + runs-on: ubuntu-20.04 + timeout-minutes: 5 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - run: pip install -r requirements.txt + - run: pip install -e . + - run: pytest --color=yes --no-cov + + coveralls-finish: + name: Finalize coveralls.io + needs: [unit-tests] + runs-on: ubuntu-20.04 + steps: + - uses: actions/setup-python@v2 + - run: pip install coveralls + - run: coveralls --service=github --finish + env: + GITHUB_TOKEN: ${{ secrets.github_token }} + continue-on-error: true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..02b7604 --- /dev/null +++ b/.gitignore @@ -0,0 +1,34 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# Distribution / packaging +build/ +dist/ +.eggs/ +*.egg-info/ +*.egg + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +.pytest_cache +nosetests.xml +coverage.xml +junit.xml +*.cover +.hypothesis/ +.mypy_cache + +# Documentation +docs/_build +docs/packages + +# VirtualEnv +env + +# VSCode +.vscode diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 0000000..118c0dc --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,6 @@ +[settings] +line_length = 100 +multi_line_output = 11 +balanced_wrapping = true +combine_as_imports = true +case_sensitive = true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..8d7f392 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,65 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +exclude: | + (?x)^( + docs/.*\.xml| + docs/.*\.png + ) +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.4.0 + hooks: + - id: check-ast + - id: trailing-whitespace + - id: end-of-file-fixer + - id: fix-byte-order-marker + - id: check-xml + - id: check-toml + - id: check-yaml + args: [--allow-multiple-documents] + - id: check-json + - id: pretty-format-json + - id: check-added-large-files + - id: check-builtin-literals + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-vcs-permalinks + - id: check-docstring-first + - id: check-merge-conflict + - id: check-symlinks + - id: destroyed-symlinks + - id: debug-statements + - id: detect-aws-credentials + args: [--allow-missing-credentials] + - id: detect-private-key + exclude: ^tests/authentication/test_credentials.py$ + - id: fix-encoding-pragma + args: [--remove] + - id: forbid-new-submodules + - id: mixed-line-ending + args: [--fix=auto] + - id: name-tests-test + args: [--django] + - id: requirements-txt-fixer + + # Intentionally disabled: + # - id: double-quote-string-fixer + + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.8.0 + hooks: + - id: python-check-blanket-noqa + - id: python-check-mock-methods + - id: python-no-eval + - id: python-no-log-warn + - id: python-use-type-annotations + - id: rst-backticks + - id: rst-directive-colons + - id: rst-inline-touching-normal + - id: text-unicode-replacement-char + + - repo: https://github.com/PyCQA/isort + rev: 5.8.0 + hooks: + - id: isort + name: isort-source-code diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..da5eec2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Sergey Vasilyev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/MAINTAINERS b/MAINTAINERS new file mode 100644 index 0000000..a5c8e23 --- /dev/null +++ b/MAINTAINERS @@ -0,0 +1 @@ +Sergey Vasilyev diff --git a/README.md b/README.md new file mode 100644 index 0000000..153f37e --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# Fast-forward asyncio event loop time (in tests) + +[![CI](https://github.com/nolar/looptime/workflows/Thorough%20tests/badge.svg)](https://github.com/nolar/looptime/actions/workflows/thorough.yaml) +[![codecov](https://codecov.io/gh/nolar/looptime/branch/main/graph/badge.svg)](https://codecov.io/gh/nolar/looptime) +[![Coverage Status](https://coveralls.io/repos/github/nolar/looptime/badge.svg?branch=main)](https://coveralls.io/github/nolar/looptime?branch=main) +[![Total alerts](https://img.shields.io/lgtm/alerts/g/nolar/looptime.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/nolar/looptime/alerts/) +[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/nolar/looptime.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/nolar/looptime/context:python) +[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..f08da66 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1 @@ +In case you detect any security issues, contact nolar@nolar.info. diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 0000000..fc40ca5 --- /dev/null +++ b/mypy.ini @@ -0,0 +1,3 @@ +[mypy] +warn_unused_configs = True +ignore_missing_imports = True diff --git a/notime/__init__.py b/notime/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/notime/py.typed b/notime/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e451dfd --- /dev/null +++ b/requirements.txt @@ -0,0 +1,15 @@ +# Everything needed to develop (test, debug) the framework. +# The runtime dependencies of the framework, as if via `pip install kopf`. +-e . +async-timeout +codecov +coverage +coveralls +isort +pre-commit +pytest +pytest-asyncio +pytest-cov +pytest-mock +# Mypy requires typed-ast, which is broken on PyPy 3.7 (could work in PyPy 3.8). +mypy==0.910; implementation_name == "cpython" diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..05dca8d --- /dev/null +++ b/setup.py @@ -0,0 +1,43 @@ +import os.path + +from setuptools import find_packages, setup + +with open(os.path.join(os.path.dirname(__file__), 'README.md')) as f: + LONG_DESCRIPTION = f.read() + DESCRIPTION = LONG_DESCRIPTION.splitlines()[0].lstrip('#').strip() + +PROJECT_URLS = { + 'Bug Tracker': 'https://github.com/nolar/looptime/issues', + 'Source Code': 'https://github.com/nolar/looptime', +} + +setup( + name='looptime', + use_scm_version=True, + + url=PROJECT_URLS['Source Code'], + project_urls=PROJECT_URLS, + description=DESCRIPTION, + long_description=LONG_DESCRIPTION, + long_description_content_type='text/markdown', + author='Sergey Vasilyev', + author_email='nolar@nolar.info', + maintainer='Sergey Vasilyev', + maintainer_email='nolar@nolar.info', + keywords=['asyncio', 'event loop', 'time', 'python', 'pytest'], + license='MIT', + + zip_safe=True, + packages=find_packages(), + include_package_data=True, + entry_points={ + }, + + python_requires='>=3.7', + setup_requires=[ + 'setuptools_scm', + ], + install_requires=[ + ], + package_data={"pytest_instant": ["py.typed"]}, +)