Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Attempt to set up CI #1

Open
wants to merge 8 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Lint

on: [push, pull_request]

concurrency:
group: check-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: test with ${{ matrix.py }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
py:
- "3.8"
os:
- ubuntu-latest
- macos-latest
- windows-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup python for test ${{ matrix.py }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py }}
- name: Install tox
run: python -m pip install tox-gh>=1.2
- name: Setup test suite
run: tox -vv --notest
- name: Run test suite
run: tox --skip-pkg-install
63 changes: 63 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Based on
# https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/

name: Publish Python distribution to PyPI

on:
release:
types: [published]
push:
branches: [main]
pull_request:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build:
name: Build distribution
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install pypa/build
run: |
python -m pip install --upgrade build
python -m pip list
- name: Build a binary wheel and a source tarball
run: python -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python distribution to PyPI
if: github.event_name == 'release' # only publish to PyPI on releases
needs:
- build
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/compat-fork-hyper
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
4 changes: 2 additions & 2 deletions hyper/common/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

Contains hyper's structures for storing and working with HTTP headers.
"""
import collections
import collections.abc

from hyper.common.util import to_bytestring, to_bytestring_tuple


class HTTPHeaderMap(collections.MutableMapping):
class HTTPHeaderMap(collections.abc.MutableMapping):
"""
A structure that contains HTTP headers.

Expand Down
2 changes: 1 addition & 1 deletion hyper/http11/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import socket
import base64

from collections import Iterable, Mapping
from collections.abc import Iterable, Mapping

import collections
from hyperframe.frame import SettingsFrame
Expand Down
10 changes: 8 additions & 2 deletions hyper/http20/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
import threading
import itertools

try:
from h2.settings import ENABLE_PUSH
except ImportError:
from h2.settings import SettingCodes
ENABLE_PUSH = SettingCodes.ENABLE_PUSH

log = logging.getLogger(__name__)

DEFAULT_WINDOW_SIZE = 65535
Expand Down Expand Up @@ -403,7 +409,7 @@ def _connect_upgrade(self, sock):
with self._conn as conn:
conn.initiate_upgrade_connection()
conn.update_settings(
{h2.settings.ENABLE_PUSH: int(self._enable_push)}
{ENABLE_PUSH: int(self._enable_push)}
)
self._send_outstanding_data()

Expand All @@ -424,7 +430,7 @@ def _send_preamble(self):
with self._conn as conn:
conn.initiate_connection()
conn.update_settings(
{h2.settings.ENABLE_PUSH: int(self._enable_push)}
{ENABLE_PUSH: int(self._enable_push)}
)
self._send_outstanding_data()

Expand Down
3 changes: 2 additions & 1 deletion hyper/httplib_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

# The HTTPConnection object is currently always the underlying one.
HTTPConnection = httplib.HTTPConnection
HTTPSConnection = httplib.HTTPSConnection

# If we have NPN support, define our custom one, otherwise just use the
# default.
Expand Down Expand Up @@ -114,3 +113,5 @@ def _delayed_connect(self):
self._conn = tempconn

return
else:
HTTPSConnection = httplib.HTTPSConnection
18 changes: 2 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,11 @@ def run_tests(self):
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: Implementation :: CPython',
],
install_requires=[
'h2>=2.4,<3.0,!=2.5.0', 'hyperframe>=3.2,<4.0', 'rfc3986>=1.1.0,<2.0', 'brotlipy>=0.7.0,<1.0'
'h2>=2.4', 'hyperframe>=3.2', 'rfc3986>=1.1.0', 'brotlipy>=0.7.0'
],
tests_require=['pytest', 'requests', 'mock'],
cmdclass={'test': PyTest},
Expand All @@ -88,15 +84,5 @@ def run_tests(self):
},
extras_require={
'fast': ['pycohttpparser'],
# Fallback to good SSL on bad Python versions.
':python_full_version < "2.7.9"': [
'pyOpenSSL>=0.15', 'service_identity>=14.0.0'
],
# PyPy with bad SSL modules will likely also need the cryptography
# module at lower than 1.0, because it doesn't support CFFI v1.0 yet.
':platform_python_implementation == "PyPy" and python_full_version < "2.7.9"': [
'cryptography<1.0'
],
':python_version == "2.7" or python_version == "3.3"': ['enum34>=1.0.4, <2']
}
)
4 changes: 2 additions & 2 deletions test/test_http11.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from collections import namedtuple
from io import BytesIO, StringIO

import mock
from unittest import mock
import pytest

import hyper
Expand Down Expand Up @@ -986,7 +986,7 @@ def send(self, data):

self.queue.append(data)

def recv(self, l):
def recv(self, l): # noqa: E741
data = self._buffer.read(l)
self._read_counter += len(data)
return memoryview(data)
Expand Down
2 changes: 1 addition & 1 deletion test/test_http20.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Unit tests for hyper's HTTP/2.0 implementation.
"""
import pytest
from mock import patch
from unittest.mock import patch

from server import SocketLevelTest

Expand Down
12 changes: 9 additions & 3 deletions test/test_hyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
WindowUpdateFrame, HeadersFrame, ContinuationFrame, GoAwayFrame,
PingFrame, FRAME_MAX_ALLOWED_LEN
)
from hpack.hpack_compat import Encoder
from hpack.hpack import Encoder
from hyper.common.connection import HTTPConnection
from hyper.http20.connection import HTTP20Connection
from hyper.http20.response import HTTP20Response, HTTP20Push
Expand All @@ -29,6 +29,12 @@
import brotli
from io import BytesIO

try:
from h2.settings import INITIAL_WINDOW_SIZE
except ImportError:
from h2.settings import SettingCodes
INITIAL_WINDOW_SIZE = SettingCodes.INITIAL_WINDOW_SIZE

TEST_DIR = os.path.abspath(os.path.dirname(__file__))
TEST_CERTS_DIR = os.path.join(TEST_DIR, 'certs')
CLIENT_PEM_FILE = os.path.join(TEST_CERTS_DIR, 'nopassword.pem')
Expand Down Expand Up @@ -766,7 +772,7 @@ def test_incrementing_window_after_close(self):
# the default max frame size (16,384 bytes). That will, on the third
# frame, trigger the processing to increment the flow control window,
# which should then not happen.
f = SettingsFrame(0, settings={h2.settings.INITIAL_WINDOW_SIZE: 100})
f = SettingsFrame(0, settings={INITIAL_WINDOW_SIZE: 100})

c = HTTP20Connection('www.google.com')
c._sock = DummySocket()
Expand Down Expand Up @@ -1660,7 +1666,7 @@ def send(self, data):

sendall = send

def recv(self, l):
def recv(self, l): # noqa: E741
data = self._buffer.read(l)
self._read_counter += len(data)
return memoryview(data)
Expand Down
2 changes: 1 addition & 1 deletion test/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import pytest
from socket import timeout as SocketTimeout
from contextlib import contextmanager
from mock import patch
from unittest.mock import patch
from concurrent.futures import ThreadPoolExecutor, TimeoutError
from h2.frame_buffer import FrameBuffer
from hyper.compat import ssl
Expand Down
2 changes: 0 additions & 2 deletions test_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ pytest>=3.0
pytest-xdist
pytest-cov
requests
mock
futures; python_version < '3.0'
12 changes: 8 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
[tox]
envlist = py{27,34,35,36}, pypy, lint
envlist = py38, pypy, lint

[testenv]
deps= -r{toxinidir}/test_requirements.txt
commands=
coverage run -m py.test {toxinidir}/test/
coverage run -m pytest {toxinidir}/test/
coverage report

[testenv:pypy]
# temporarily disable coverage testing on PyPy due to performance problems
commands= py.test {toxinidir}/test/
commands= pytest {toxinidir}/test/

[testenv:lint]
basepython=python3
deps = flake8==2.5.4
deps = flake8==7.1.1
commands = flake8 hyper test

[gh]
python =
3.8 = py38,lint
Loading