Skip to content

Commit

Permalink
Merge ab06ca4 into 4e1e762
Browse files Browse the repository at this point in the history
  • Loading branch information
agronholm committed Sep 29, 2020
2 parents 4e1e762 + ab06ca4 commit 7a5334d
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 91 deletions.
96 changes: 96 additions & 0 deletions .github/workflows/codeqa-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Python codeqa/test

on:
push:
branches: [master]
pull_request:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: pip-lint
- name: Install dependencies
run: pip install flake8
- name: Run flake8
run: flake8 cbor2 tests

test-py27:
needs: [lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 2.7
uses: actions/setup-python@v2
with:
python-version: 2.7
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: pip-test-2.7-ubuntu-latest
- name: Install dependencies
run: pip install -e .[test]
- name: Test with pytest
run: pytest

test:
needs: [lint]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, pypy3]
exclude:
- os: macos-latest
python-version: 3.7
- os: macos-latest
python-version: pypy3
- os: windows-latest
python-version: 3.7
- os: windows-latest
python-version: pypy3 # https://github.com/python-trio/trio/issues/1361
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: pip-test-${{ matrix.python-version }}-${{ matrix.os }}
- name: Install dependencies
run: pip install -e .[test] coveralls
- name: Test with pytest
run: pytest
- name: Upload Coverage
run: coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.test-name }}
COVERALLS_PARALLEL: true

coveralls:
name: Finish Coveralls
needs: test
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install dependencies
run: pip install coveralls
- name: Notify Coveralls
run: coveralls --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81 changes: 81 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Publish packages to PyPI

on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+[a-b][0-9]+"
- "[0-9]+.[0-9]+.[0-9]+rc[0-9]+"

jobs:
linux-wheels:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build manylinux Python wheels
uses: RalfG/python-wheels-manylinux-build@v0.3.1-manylinux2014_x86_64
- uses: actions/upload-artifact@v2
with:
name: linux-wheels
path: dist/*-manylinux*.whl

other-wheels:
strategy:
matrix:
os: [macos-latest, windows-latest]
python-version: [2.7, 3.6, 3.7, 3.8]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: pip-test-${{ matrix.python-version }}-${{ matrix.os }}
- name: Install dependencies
run: pip install pep517
- name: Create packages
run: python -m pep517.build --binary .
- uses: actions/upload-artifact@v2
with:
name: other-wheels
path: dist/*.whl

sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install dependencies
run: pip install pep517
- name: Create sdist
run: python -m pep517.build --source .
- uses: actions/upload-artifact@v2
with:
name: sdist
path: dist/*.tar.gz

publish:
needs:
- linux-wheels
- other-wheels
- sdist
runs-on: ubuntu-latest
steps:
- name: Download generated packaging artifacts
uses: actions/download-artifact@v2
- name: Move the packages to dist/
run: |
mkdir dist
mv */*.whl */*.tar.gz dist
- name: Upload packages
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
74 changes: 0 additions & 74 deletions .travis.yml

This file was deleted.

7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build-system]
requires = [
"setuptools >= 42",
"wheel >= 0.29.0",
"setuptools_scm[toml] >= 3.4"
]
build-backend = "setuptools.build_meta"
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ packages = find:
test =
pytest
pytest-cov
ipaddress; python_version == "2.7"

[tool:pytest]
addopts = -rsx --cov --tb=short
testpaths = tests

[coverage:run]
source = cbor2
relative_files = true

[coverage:report]
show_missing = true
Expand Down
12 changes: 4 additions & 8 deletions tests/test_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@
from email.message import Message
from fractions import Fraction
from io import BytesIO
from ipaddress import ip_address, ip_network
from uuid import UUID
try:
from ipaddress import ip_address, ip_network
except ImportError:
def ip_address(x): pass
def ip_network(x, strict): pass

import pytest

Expand Down Expand Up @@ -430,8 +426,8 @@ def test_uuid(impl):

@pytest.mark.skipif(sys.version_info < (3, 3), reason="Address decoding requires Py3.3+")
@pytest.mark.parametrize('payload, expected', [
('d9010444c00a0a01', ip_address('192.10.10.1')),
('d901045020010db885a3000000008a2e03707334', ip_address('2001:db8:85a3::8a2e:370:7334')),
('d9010444c00a0a01', ip_address(u'192.10.10.1')),
('d901045020010db885a3000000008a2e03707334', ip_address(u'2001:db8:85a3::8a2e:370:7334')),
('d9010446010203040506', (260, b'\x01\x02\x03\x04\x05\x06')),
], ids=[
'ipv4',
Expand Down Expand Up @@ -461,7 +457,7 @@ def test_bad_ipaddress(impl):
@pytest.mark.parametrize('payload, expected', [
('d90105a144c0a800641818', ip_network('192.168.0.100/24', False)),
('d90105a15020010db885a3000000008a2e000000001860',
ip_network('2001:db8:85a3:0:0:8a2e::/96', False)),
ip_network(u'2001:db8:85a3:0:0:8a2e::/96', False)),
], ids=[
'ipv4',
'ipv6',
Expand Down
14 changes: 5 additions & 9 deletions tests/test_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
from decimal import Decimal
from email.mime.text import MIMEText
from fractions import Fraction
from ipaddress import ip_address, ip_network
from uuid import UUID
try:
from ipaddress import ip_address, ip_network
except ImportError:
def ip_address(x): pass
def ip_network(x, strict): pass

import pytest

Expand Down Expand Up @@ -302,8 +298,8 @@ def test_uuid(impl):

@pytest.mark.skipif(sys.version_info < (3, 3), reason="Address encoding requires Py3.3+")
@pytest.mark.parametrize('value, expected', [
(ip_address('192.10.10.1'), 'd9010444c00a0a01'),
(ip_address('2001:db8:85a3::8a2e:370:7334'), 'd901045020010db885a3000000008a2e03707334'),
(ip_address(u'192.10.10.1'), 'd9010444c00a0a01'),
(ip_address(u'2001:db8:85a3::8a2e:370:7334'), 'd901045020010db885a3000000008a2e03707334'),
], ids=[
'ipv4',
'ipv6',
Expand All @@ -315,8 +311,8 @@ def test_ipaddress(impl, value, expected):

@pytest.mark.skipif(sys.version_info < (3, 3), reason="Network encoding requires Py3.3+")
@pytest.mark.parametrize('value, expected', [
(ip_network('192.168.0.100/24', False), 'd90105a144c0a800001818'),
(ip_network('2001:db8:85a3:0:0:8a2e::/96', False),
(ip_network(u'192.168.0.100/24', False), 'd90105a144c0a800001818'),
(ip_network(u'2001:db8:85a3:0:0:8a2e::/96', False),
'd90105a15020010db885a3000000008a2e000000001860'),
], ids=[
'ipv4',
Expand Down

0 comments on commit 7a5334d

Please sign in to comment.