Skip to content

Commit

Permalink
Clean up GH Actions and formatting (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
brettcannon committed Mar 15, 2020
1 parent 61b0d1a commit 3a9b74f
Show file tree
Hide file tree
Showing 23 changed files with 638 additions and 468 deletions.
2 changes: 0 additions & 2 deletions .coveragerc

This file was deleted.

66 changes: 45 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI

on:
pull_request:
paths: "**"
branches: master
push:
branches: master

Expand All @@ -11,27 +11,51 @@ jobs:
name: test w/ Python ${{ matrix.python_version }}

runs-on: ubuntu-latest

strategy:
matrix:
python_version: ['3.6', '3.7', '3.8']
python_version: ["3.6", "3.7", "3.8"]

steps:
- uses: actions/checkout@v1
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python_version }}
- run: pip install flit
- run: flit install --deps develop
- name: Run `pytest --cov`
run: pytest --cov --cov-report=xml:cov.xml
env:
PYTHONDEVMODE: 1
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./cov.xml

lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python_version }}
- run: pip install flit
- run: flit install --deps develop
- name: Run tests
run: pytest --cov=gidgethub --cov-config=.coveragerc --cov-fail-under=100 --cov-report=xml:cov.xml
env:
PYTHONDEVMODE: 1
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./cov.xml
- name: Check type hints
run: mypy --ignore-missing-imports --strict gidgethub/*.py
- name: Check docs
run: sphinx-build -nW -q -b html -b linkcheck -d docs/_build/doctrees docs docs/_build/html
- uses: actions/checkout@v1
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/setup-python@v1
with:
python-version: "3.8"
- run: pip install flit
- run: flit install --deps develop
- run: black --check .
- name: Check type hints
run: mypy --ignore-missing-imports --strict gidgethub/*.py
- name: Check docs
run: sphinx-build -nW -q -b html -b linkcheck -d docs/_build/doctrees docs docs/_build/html
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ nosetests.xml
coverage.xml
*,cover
.hypothesis/
cov.xml

# Translations
*.mo
Expand Down
82 changes: 41 additions & 41 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('.'))

sys.path.insert(0, os.path.abspath("."))


# -- General configuration ------------------------------------------------
Expand All @@ -31,41 +32,43 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.viewcode',
'customization',
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.doctest",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
"customization",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = 'gidgethub'
copyright = '2017, Brett Cannon'
author = 'Brett Cannon'
project = "gidgethub"
copyright = "2017, Brett Cannon"
author = "Brett Cannon"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The full version, including alpha/beta/rc tags.
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath(".."))
import gidgethub

release = gidgethub.__version__
del sys.path[0]
# The short X.Y version.
version = release[:release.index('.', 2)]
version = release[: release.index(".", 2)]


# The language for content autogenerated by Sphinx. Refer to documentation
Expand All @@ -78,10 +81,10 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -92,18 +95,18 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
#html_theme = 'alabaster'
# html_theme = 'alabaster'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
#html_theme_options = {
# html_theme_options = {
# "github_user": "brettcannon",
# "github_repo": "gidgethub",
# "github_type": "star",
# "github_banner": True,
#}
# }

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand All @@ -114,7 +117,7 @@
# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'gidgethubdoc'
htmlhelp_basename = "gidgethubdoc"


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -123,15 +126,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -141,19 +141,15 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'gidgethub.tex', 'gidgethub Documentation',
'Brett Cannon', 'manual'),
(master_doc, "gidgethub.tex", "gidgethub Documentation", "Brett Cannon", "manual"),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'gidgethub', 'gidgethub Documentation',
[author], 1)
]
man_pages = [(master_doc, "gidgethub", "gidgethub Documentation", [author], 1)]


# -- Options for Texinfo output -------------------------------------------
Expand All @@ -162,24 +158,28 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'gidgethub', 'gidgethub Documentation',
author, 'gidgethub', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"gidgethub",
"gidgethub Documentation",
author,
"gidgethub",
"One line description of project.",
"Miscellaneous",
),
]




# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/3/': None}
intersphinx_mapping = {"https://docs.python.org/3/": None}


html_sidebars = {
'**': [
'about.html',
'navigation.html',
'relations.html',
'searchbox.html',
'donate.html',
"**": [
"about.html",
"navigation.html",
"relations.html",
"searchbox.html",
"donate.html",
]
}
18 changes: 8 additions & 10 deletions docs/customization.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,29 @@


class PyCoroutine(PyClassmember):

def handle_signature(self, sig, signode):
ret = super().handle_signature(sig, signode)
signode.insert(0, addnodes.desc_annotation('coroutine ',
'coroutine '))
signode.insert(0, addnodes.desc_annotation("coroutine ", "coroutine "))
return ret

def run(self):
self.name = 'py:method'
self.name = "py:method"
return PyClassmember.run(self)


class PyAbstractCoroutine(PyCoroutine):

def handle_signature(self, sig, signode):
ret = super().handle_signature(sig, signode)
signode.insert(0, addnodes.desc_annotation('abstractmethod ',
'abstractmethod '))
signode.insert(
0, addnodes.desc_annotation("abstractmethod ", "abstractmethod ")
)
return ret

def run(self):
self.name = 'py:method'
self.name = "py:method"
return PyClassmember.run(self)


def setup(app):
app.add_directive_to_domain('py', 'coroutine', PyCoroutine)
app.add_directive_to_domain('py', 'abstractcoroutine', PyAbstractCoroutine)
app.add_directive_to_domain("py", "coroutine", PyCoroutine)
app.add_directive_to_domain("py", "abstractcoroutine", PyAbstractCoroutine)
7 changes: 4 additions & 3 deletions gidgethub/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""An async GitHub API library"""
__version__ = '3.3.0'
__version__ = "3.3.0"

import http
from typing import Any
Expand All @@ -13,6 +13,7 @@ class GitHubException(Exception):
class ValidationFailure(GitHubException):

"""An exception representing failed validation of a webhook event."""

# https://developer.github.com/webhooks/securing/#validating-payloads-from-github


Expand All @@ -38,6 +39,7 @@ class BadRequest(HTTPException):
Used for 4XX HTTP errors.
"""

# https://developer.github.com/v3/#client-errors


Expand All @@ -51,8 +53,7 @@ def __init__(self, rate_limit: Any, *args: Any) -> None:
self.rate_limit = rate_limit

if not args:
super().__init__(http.HTTPStatus.FORBIDDEN,
"rate limit exceeded")
super().__init__(http.HTTPStatus.FORBIDDEN, "rate limit exceeded")
else:
super().__init__(http.HTTPStatus.FORBIDDEN, *args)

Expand Down

0 comments on commit 3a9b74f

Please sign in to comment.