Skip to content

Commit

Permalink
build: Massive dev updates
Browse files Browse the repository at this point in the history
- Update CI workflow with env vars
- Update docs requirements & pin Sphinx version to use
- Build docs with `sphinx-autobuild` at local environment
- Bump pre-commit hooks
- Commit `.python-version` into the repo (and update git ignore list)
  • Loading branch information
playpauseandstop committed Jun 8, 2020
1 parent 38cf321 commit 72f99cf
Show file tree
Hide file tree
Showing 11 changed files with 323 additions and 162 deletions.
38 changes: 20 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ on:
pull_request:
branches: ["master"]

env:
DEV_PYTHON_VERSION: "3.8"
POETRY_VERSION: "1.0.8"
TOX_GH_ACTIONS_VERSION: "1.2.0"
TOX_VERSION: "3.15.2"
TWINE_VERSION: "3.1.1"

jobs:
dev:
name: "Verify package is installed well"
Expand All @@ -23,12 +30,12 @@ jobs:
- name: "Install Python"
uses: "actions/[email protected]"
with:
python-version: "3.8"
python-version: "${{ env.DEV_PYTHON_VERSION }}"

- name: "Install poetry"
uses: "dschep/[email protected]"
with:
version: "1.0.5"
version: "${{ env.POETRY_VERSION }}"

- name: "Install package"
run: "poetry install --no-dev"
Expand Down Expand Up @@ -56,29 +63,28 @@ jobs:
- name: "Install poetry"
uses: "dschep/[email protected]"
with:
version: "1.0.5"
create_virtualenvs: true
version: "${{ env.POETRY_VERSION }}"

- name: "Install package"
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
poetry install
python -m pip install tox==3.14.5 tox-gh-actions==1.1.0
python -m pip install tox==${{ env.TOX_VERSION }} tox-gh-actions==${{ env.TOX_GH_ACTIONS_VERSION }}
- name: "Cache pre-commit"
if: "matrix.python-version == '3.8'"
uses: "actions/cache@v1.1.2"
if: "matrix.python-version == 'env.DEV_PYTHON_VERSION'"
uses: "actions/cache@v2.0.0"
with:
path: "~/.cache/pre-commit"
key: "pre-commit-${{ matrix.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}"

- name: "Run pre-commit"
if: "matrix.python-version == '3.8'"
if: "matrix.python-version == 'env.DEV_PYTHON_VERSION'"
uses: "pre-commit/[email protected]"

- name: "Run tests"
run: |
python -m tox
run: "python -m tox"

package:
needs: "test"
Expand All @@ -87,28 +93,24 @@ jobs:
runs-on: "ubuntu-latest"

steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v1"
with:
python-version: "3.8"
- uses: "actions/[email protected]"

- name: "Install Python"
uses: "actions/[email protected]"
with:
python-version: "3.8"
python-version: "${{ env.DEV_PYTHON_VERSION }}"

- name: "Install poetry"
uses: "dschep/[email protected]"
with:
version: "1.0.5"
create_virtualenvs: true
version: "${{ env.POETRY_VERSION }}"

- name: "Build package"
run: "poetry build"

- name: "Check package"
run: |
python -m pip install twine==3.1.1
python -m pip install twine==${{ env.TWINE_VERSION }}
python -m twine check dist/*
- name: "Publish package"
Expand Down
17 changes: 15 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

# Created by https://www.toptal.com/developers/gitignore/api/python
# Edit at https://www.toptal.com/developers/gitignore?templates=python

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -82,7 +87,7 @@ profile_default/
ipython_config.py

# pyenv
.python-version
#.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
Expand Down Expand Up @@ -128,5 +133,13 @@ dmypy.json
# Pyre type checker
.pyre/

# Test uploads
# pytype static type analyzer
.pytype/

# End of https://www.toptal.com/developers/gitignore/api/python

# make install target
.install

# Test Uploads
tests/test-uploads/
27 changes: 18 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
minimum_pre_commit_version: "1.17.0"
repos:
- repo: "https://github.com/commitizen-tools/commitizen"
rev: "v1.22.0"
rev: "v1.22.2"
hooks:
- id: "commitizen"
language_version: "python3.8"
Expand All @@ -26,7 +26,7 @@ repos:
- "black==19.10b0"

- repo: "https://github.com/pre-commit/pre-commit-hooks"
rev: "v2.5.0"
rev: "v3.1.0"
hooks:
- id: "end-of-file-fixer"
- id: "trailing-whitespace"
Expand All @@ -35,18 +35,18 @@ repos:
- id: "check-yaml"

- repo: "https://gitlab.com/PyCQA/flake8"
rev: "3.8.1"
rev: "3.8.2"
hooks:
- id: "flake8"
name: "Lint code (flake8)"
language_version: "python3.8"
additional_dependencies:
- "flake8==3.8.1"
additional_dependencies: &flake8_additional_dependencies
- "flake8==3.8.2"
- "flake8-broken-line==0.2.0"
- "flake8-bugbear==20.1.4"
- "flake8-builtins==1.5.2"
- "flake8-comprehensions==3.2.2"
- "flake8-eradicate==0.3.0"
- "flake8-builtins==1.5.3"
- "flake8-comprehensions==3.2.3"
- "flake8-eradicate==0.4.0"
- "flake8-import-order==0.18.1"
- "flake8-mutable==1.2.0"
- "flake8-pie==0.5.0"
Expand All @@ -57,8 +57,17 @@ repos:
- "pep8-naming==0.10.0"
exclude: ^docs/.*$

- repo: "https://github.com/asottile/yesqa"
rev: "v1.2.0"
hooks:
- id: yesqa
name: "Lint code (yesqa)"
language_version: "python3.8"
additional_dependencies: *flake8_additional_dependencies
exclude: ^docs/.*$

- repo: "https://github.com/pre-commit/mirrors-mypy"
rev: "v0.770"
rev: "v0.780"
hooks:
- id: "mypy"
name: "Lint code (mypy)"
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8.3
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
=========
ChangeLog
Changelog
=========

1.0.0rc1 (2020-04-02)
Expand Down
19 changes: 9 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
coveralls \
distclean \
docs \
example \
install \
lint \
lint-only \
list-outdated \
open-docs \
test \
test-app \
test-only

# Project constants
Expand All @@ -20,10 +19,13 @@ DOCS_DIR = ./docs
POETRY ?= poetry
PRE_COMMIT ?= pre-commit
PYTHON ?= $(POETRY) run python
SPHINXBUILD ?= $(POETRY) run sphinx-build
TOX ?= tox

# Example constants
# Docs vars
DOCS_HOST ?= localhost
DOCS_PORT ?= 8242

# Example vars
AIOHTTP_PORT ?= 8300

all: install
Expand All @@ -36,7 +38,7 @@ distclean: clean

docs: .install
$(PYTHON) -m pip install -r docs/requirements.txt
$(MAKE) -C docs/ SPHINXBUILD="$(SPHINXBUILD)" html
$(POETRY) run sphinx-autobuild -B -H $(DOCS_HOST) -p $(DOCS_PORT) -b html $(DOCS_DIR)/ $(DOCS_DIR)/_build/

example: .install
ifeq ($(EXAMPLE),)
Expand All @@ -48,7 +50,7 @@ endif

install: .install
.install: pyproject.toml poetry.lock
$(POETRY) config virtualenvs.in-project true
$(POETRY) config --local virtualenvs.in-project true
$(POETRY) install
touch $@

Expand All @@ -60,11 +62,8 @@ lint-only:
list-outdated: install
$(POETRY) show -o

open-docs: docs
open $(DOCS_DIR)/_build/html/index.html

test: install clean lint test-only

test-only:
rm -rf tests/test-uploads/
-rm -rf tests/test-uploads/
TOXENV=$(TOXENV) $(TOX) $(TOX_ARGS) -- $(TEST_ARGS)
2 changes: 1 addition & 1 deletion docs/requirements.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
aiohttp
sphinx
Sphinx==3.0.4
sphinx_autodoc_typehints
18 changes: 9 additions & 9 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,30 @@ alabaster==0.7.12 # via sphinx
async-timeout==3.0.1 # via aiohttp
attrs==19.3.0 # via aiohttp
babel==2.8.0 # via sphinx
certifi==2019.11.28 # via requests
certifi==2020.4.5.2 # via requests
chardet==3.0.4 # via aiohttp, requests
docutils==0.16 # via sphinx
idna==2.9 # via requests, yarl
imagesize==1.2.0 # via sphinx
jinja2==2.11.1 # via sphinx
jinja2==2.11.2 # via sphinx
markupsafe==1.1.1 # via jinja2
multidict==4.7.5 # via aiohttp, yarl
packaging==20.3 # via sphinx
multidict==4.7.6 # via aiohttp, yarl
packaging==20.4 # via sphinx
pygments==2.6.1 # via sphinx
pyparsing==2.4.6 # via packaging
pytz==2019.3 # via babel
pyparsing==2.4.7 # via packaging
pytz==2020.1 # via babel
requests==2.23.0 # via sphinx
six==1.14.0 # via packaging
six==1.15.0 # via packaging
snowballstemmer==2.0.0 # via sphinx
sphinx-autodoc-typehints==1.10.3 # via -r docs/requirements.in
sphinx==2.4.4 # via -r docs/requirements.in, sphinx-autodoc-typehints
sphinx==3.0.4 # via -r docs/requirements.in, sphinx-autodoc-typehints
sphinxcontrib-applehelp==1.0.2 # via sphinx
sphinxcontrib-devhelp==1.0.2 # via sphinx
sphinxcontrib-htmlhelp==1.0.3 # via sphinx
sphinxcontrib-jsmath==1.0.1 # via sphinx
sphinxcontrib-qthelp==1.0.3 # via sphinx
sphinxcontrib-serializinghtml==1.1.4 # via sphinx
urllib3==1.25.8 # via requests
urllib3==1.25.9 # via requests
yarl==1.4.2 # via aiohttp

# The following packages are considered to be unsafe in a requirements file:
Expand Down
Loading

0 comments on commit 72f99cf

Please sign in to comment.