mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Update tests.yml, revert changes in test files
Add and improve step names Merge "Lint code" and "Check code-style" steps Don't install uvloop on macos when running on pypy Don't run tests with coverage on pypy Remove test timeout adjustments
This commit is contained in:
parent
9cdb5e8128
commit
b1e66a993e
3 changed files with 26 additions and 30 deletions
44
.github/workflows/tests.yml
vendored
44
.github/workflows/tests.yml
vendored
|
|
@ -52,7 +52,8 @@ jobs:
|
|||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@master
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
|
||||
uses: actions/setup-python@v4
|
||||
|
|
@ -69,17 +70,17 @@ jobs:
|
|||
installer-parallel: true
|
||||
|
||||
- name: Install and configure Poetry (PyPy on Windows)
|
||||
# Poetry installer raises an error on Windows PyPy, so it's a separate step
|
||||
if: "startswith(matrix.python-version, 'pypy') && matrix.os == 'windows-latest'"
|
||||
env:
|
||||
POETRY_VERSION: 1.1.11
|
||||
run: |
|
||||
set -eu
|
||||
pip install "poetry==$POETRY_VERSION"
|
||||
pip install "poetry==1.1.11"
|
||||
poetry config virtualenvs.create true
|
||||
poetry config virtualenvs.in-project true
|
||||
poetry config installer.parallel true
|
||||
|
||||
- name: Setup redis
|
||||
# Redis can't be used on GitHub Windows Runners
|
||||
if: ${{ matrix.os != 'windows-latest' }}
|
||||
uses: shogo82148/actions-setup-redis@v1
|
||||
with:
|
||||
|
|
@ -92,33 +93,36 @@ jobs:
|
|||
path: .venv
|
||||
key: venv-${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}-${{ secrets.CACHE_VERSION }}
|
||||
|
||||
- name: Project dependencies
|
||||
- name: Install project dependencies
|
||||
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
|
||||
env:
|
||||
# uvloop on macOS on PyPy doesn't compile
|
||||
INSTALL_FAST: ${{ matrix.os == 'macos-latest' && startswith(matrix.python-version, 'pypy') }}
|
||||
run: |
|
||||
export CFLAGS="$CFLAGS -Wno-error"
|
||||
poetry install --no-interaction -E fast -E redis -E proxy -E i18n -E docs
|
||||
flags=""
|
||||
[[ "$INSTALL_FAST" == "true" ]] && flags="$flags -E fast"
|
||||
poetry install --no-interaction -E redis -E proxy -E i18n -E docs $flags
|
||||
|
||||
- name: Lint code
|
||||
run: |
|
||||
poetry run flake8 aiogram
|
||||
poetry run mypy aiogram
|
||||
|
||||
- name: Check code-style (Black)
|
||||
run: |
|
||||
poetry run black --check --diff aiogram tests
|
||||
|
||||
- name: Run tests (with Redis)
|
||||
if: ${{ matrix.os != 'windows-latest' }}
|
||||
- name: Run tests
|
||||
env:
|
||||
USE_REDIS: ${{ matrix.os != 'windows-latest' }}
|
||||
# Coverage don't work well on PyPy with tests that have timeout
|
||||
USE_COVERAGE: ${{ !startswith(matrix.python-version, 'pypy') }}
|
||||
run: |
|
||||
poetry run pytest --cov=aiogram --cov-config .coveragerc --cov-report=xml --redis redis://localhost:6379/0
|
||||
flags=""
|
||||
[[ "$USE_COVERAGE" == "true" ]] && flags="$flags --cov=aiogram --cov-config .coveragerc --cov-report=xml"
|
||||
[[ "$USE_REDIS" == "true" ]] && flags="$flags --redis redis://localhost:6379/0"
|
||||
poetry run pytest $flags
|
||||
|
||||
- name: Run tests (without Redis)
|
||||
# Redis can't be used on GitHub Windows Runners
|
||||
if: ${{ matrix.os == 'windows-latest' }}
|
||||
run: |
|
||||
poetry run pytest --cov=aiogram --cov-config .coveragerc --cov-report=xml
|
||||
|
||||
- uses: codecov/codecov-action@v1
|
||||
- name: Upload coverage data
|
||||
if: "!startswith(matrix.python-version, 'pypy')"
|
||||
uses: codecov/codecov-action@v1
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
file: coverage.xml
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import asyncio
|
||||
import datetime
|
||||
import sys
|
||||
import time
|
||||
import warnings
|
||||
from collections import Counter
|
||||
|
|
@ -703,10 +702,7 @@ class TestDispatcher:
|
|||
dispatcher = Dispatcher()
|
||||
dispatcher.message.register(simple_message_handler)
|
||||
|
||||
# Running this test on PyPy with coverage pytest plugin makes the test run slower
|
||||
# than expected, so we adjust the timeout accordingly.
|
||||
timeout = 1 if sys.implementation.name == "pypy" else 0.3
|
||||
response = await dispatcher.feed_webhook_update(bot, RAW_UPDATE, _timeout=timeout)
|
||||
response = await dispatcher.feed_webhook_update(bot, RAW_UPDATE, _timeout=0.3)
|
||||
assert isinstance(response, dict)
|
||||
assert response["method"] == "sendMessage"
|
||||
assert response["text"] == "ok"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import asyncio
|
||||
import sys
|
||||
import time
|
||||
from asyncio import Event
|
||||
from dataclasses import dataclass
|
||||
|
|
@ -116,10 +115,7 @@ class TestSimpleRequestHandler:
|
|||
handler_event.clear()
|
||||
resp = await self.make_reqest(client=client)
|
||||
assert resp.status == 200
|
||||
# Running this test on PyPy with coverage pytest plugin makes the test run slower
|
||||
# than expected, so we adjust the timeout accordingly.
|
||||
timeout = 5 if sys.implementation.name == "pypy" else 1
|
||||
await asyncio.wait_for(handler_event.wait(), timeout=timeout)
|
||||
await asyncio.wait_for(handler_event.wait(), timeout=1)
|
||||
mocked_silent_call_request.assert_awaited()
|
||||
result = await resp.json()
|
||||
assert not result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue