Skip to content

Commit

Permalink
Merge 3c4402e into 1816df8
Browse files Browse the repository at this point in the history
  • Loading branch information
shawalli committed Jul 22, 2020
2 parents 1816df8 + 3c4402e commit c545fc4
Show file tree
Hide file tree
Showing 19 changed files with 368 additions and 150 deletions.
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
max-line-length = 120
max-complexity = 10
exclude =
tests
6 changes: 6 additions & 0 deletions .github/auto_assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
addReviewers: true

addAssignees: author

reviewers:
- shawalli
123 changes: 123 additions & 0 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Build, Lint, Test

on:
pull_request:
branches:
- master
types:
- opened
- reopened
- synchronize

jobs:
lint:
name: ️⚒️ & 👕

strategy:
matrix:
python-version: [3.6.7, 3.7, 3.8]

runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
uses: dschep/install-poetry-action@v1.3
with:
create_virtualenvs: true

- name: Cache Poetry virtualenv
uses: actions/cache@v2
id: cache
with:
path: ~/.virtualenvs
key: poetry-${{ github.ref }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
poetry-${{ github.ref }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
- name: Set Poetry config
run: |
poetry config virtualenvs.in-project false
poetry config virtualenvs.path ~/.virtualenvs
- name: Install Dependencies
run: poetry install

- name: Run pre-commit
if: github.event_name == 'pull_request'
run: |
git fetch origin master:master
poetry run pre-commit run --from-ref master --to-ref HEAD
test:
name: 🧪
needs: lint

strategy:
matrix:
python-version: [3.6.7, 3.7, 3.8]

runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
uses: dschep/install-poetry-action@v1.3
with:
create_virtualenvs: true

- name: Cache Poetry virtualenv
uses: actions/cache@v2
id: cache
with:
path: ~/.virtualenvs
key: poetry-${{ github.ref }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
poetry-${{ github.ref }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
- name: Set Poetry config
run: |
poetry config virtualenvs.in-project false
poetry config virtualenvs.path ~/.virtualenvs
- name: Install Dependencies
run: poetry install

- name: Unit Test
run: poetry run python -m pytest --cov=src --cov-branch tests/

- name: Submit Code Coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: py-${{ matrix.python-version }}
COVERALLS_PARALLEL: true
run: poetry run coveralls

test-finish:
name: 🚪
needs: test

runs-on: ubuntu-latest
container: python:3-slim

steps:
- name: Finished
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pip3 install coveralls
coveralls --finish
10 changes: 10 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Assign Reviewers
on:
pull_request:

jobs:
add-reviewers:
name: 👪
runs-on: ubuntu-latest
steps:
- uses: kentaro-m/auto-assign-action@v1.1.1
73 changes: 73 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Package, Ship

on:
push:
branches:
- master

jobs:
package:
name: 📦 & 🚢

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: '0'

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Get next package version
id: bumpversion
uses: anothrNick/github-tag-action@1.23.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: false
DRY_RUN: true

- name: Install poetry
uses: dschep/install-poetry-action@v1.3
with:
create_virtualenvs: true

- name: Bump release version
run: poetry version ${{ steps.bumpversion.outputs.new_tag }}

- name: Build package
run: poetry build

- name: Publish package (Test PyPI)
run: |
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry config pypi-token.testpypi ${{ secrets.TEST_PYPI_PASSWORD }}
poetry publish -r testpypi
- name: Publish package (PyPI)
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_PASSWORD }}
poetry publish
- name: Generate release message
id: release_message
run: |
# Get (squashed) commit summaries since last tag, convert to list,
# escape multi-lines into a format GitHub Actions respect, and set as output
export NOTES=`git log --pretty=format:'%s' $(git describe --tags --abbrev=0 HEAD^)..HEAD | tr '\n' '\0' | xargs -0 -I{} echo '- {}'`
export NOTES_ENCODED_NEWLINES="${NOTES//$'\n'/'%0A'}"
echo "::set-output name=message::$NOTES_ENCODED_NEWLINES"
- name: Create release
uses: actions/create-release@v1.1.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.bumpversion.outputs.new_tag }}
release_name: ${{ steps.bumpversion.outputs.new_tag }}
body: ${{ steps.release_message.outputs.message}}
draft: false
prerelease: false
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@ venv.bak/
.mypy_cache/

# Editors
.vscode/
.vscode/
4 changes: 4 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[settings]
known_third_party = github_webhook
multi_line_output=3
include_trailing_comma=True
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
repos:
- repo: https://gitlab.com/smop/pre-commit-hooks
rev: v1.0.0
hooks:
- id: check-poetry
- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config
args:
- --exclude=tests/.*\.py
- repo: https://github.com/psf/black
rev: 19.10b0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.0.9
hooks:
- id: isort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
hooks:
- id: check-yaml
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
hooks:
- id: flake8
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ def pullrequest_handler(data):
print('Received the following PULL-REQUEST event:{}'.format(data))
```

## Versions
Version 0.1.x supports `^2.7` and `^3.4`.

Versions 0.2+ supports `^3.6.7`. This is primarily due to Python version
constraints on the package and test tools. For instance, here are some
dependencies and their supported Python versions: `poetry=^3.4`,
`coveralls=^3.5`, `pre-commit=^3.6.1`, and `pytest=^3.6`. Due to these
constraints, the decision was made to drop official support for `2.7`, `3.4`
and `3.5`. However, `flask-github-webhook=^0.1.x` should work for older
Python versions.

## Configuration
The extension has the same configurations available as the `python-github-webhook` package. However, unlike referenced package, this extension reads those configurations from the Flask application, not initialization arguments. The values below should be configured in the Flask application (app.config) prior to initializing the extension.

Expand All @@ -62,6 +73,6 @@ Contributions are welcomed! If you would like to improve or modify Flask-Github-
This package is released under an open source MIT License. Flask-Github-Webhook was originally written by [Shawn Wallis](https://github.com/shawalli).

## References
* [python-github-webhook](https://github.com/bloomberg/python-github-webhook)
* [python-github-webhook](https://github.com/bloomberg/python-github-webhook)
* [GitHub Webhook Development Guide](https://developer.github.com/webhooks)
* [Flask Extension Pattern](http://flask.pocoo.org/docs/latest/patterns/appfactories/#factories-extensions)
60 changes: 60 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[tool.poetry]
name = "flask-github-webhook"
version = "0.2.0"
description = "Flask extension for github-webhooks"
readme = "README.md"
homepage = "https://github.com/shawalli/flask-github-webhook"
repository = "https://github.com/shawalli/flask-github-webhook"
authors = ["Shawn Wallis <shawn.p.wallis@gmail.com>"]
license = "Apache License 2.0"
classifiers = [
"Development Status :: 3 - Alpha",
"Framework :: Flask",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Version Control :: Git"
]
include = [
"LICENSE.md",
]

[tool.poetry.dependencies]
python = "^3.6.7"
github-webhook = "^1.0.2"

[tool.poetry.dev-dependencies]
coveralls = "^2.1.1"
pre-commit = "^2.6.0"
pytest = "^5.4.3"
pytest-cov = "^2.10.0"

[tool.black]
line-length = 120
target-version = ["py36", "py37", "py38"]
include = "\\.pyi?$"
exclude = """
/(
\\.eggs
| \\.git
| \\.hg
| \\.mypy_cache
| \\.tox
| \\.venv
| _build
| buck-out
| build
| dist
)/
"""

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
8 changes: 0 additions & 8 deletions requirements.txt

This file was deleted.

0 comments on commit c545fc4

Please sign in to comment.