Skip to content

Commit

Permalink
Merge branch 'release/4.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymillergh committed Sep 18, 2022
2 parents 48d2269 + 2843b0d commit 6fe606b
Show file tree
Hide file tree
Showing 19 changed files with 512 additions and 157 deletions.
9 changes: 9 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# .coveragerc to control coverage.py
# https://coverage.readthedocs.io/en/latest/config.html
# https://github.com/nedbat/coveragepy/blob/master/doc/config.rst
[run]
data_file = ./build/.coverage
source = python_boilerplate
omit = python_boilerplate/__main__.py
python_boilerplate/__init__.py
tests/*

[report]
exclude_lines =
Expand All @@ -18,3 +24,6 @@ exclude_lines =
# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:

[html]
directory = ./build/htmlcov
16 changes: 7 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,33 @@ on:
- '**.md'
- '_config.yml'
- '**.tweet'
tags: "*"

jobs:
compilation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.10.6"
architecture: x64
# https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#caching-packages
cache: "pipenv"

- name: Install Dependencies with pipenv
run: |
pip install pipenv
pipenv install --deploy --dev
- run: pipenv run isort --recursive --diff .
- run: pipenv run black --check .
- run: pipenv run flake8
- run: pipenv run mypy
- name: Python tests with pytest
run: pipenv run pytest --cov --cov-fail-under=70 --capture=no --log-cli-level=INFO
- name: Build docker image
run: docker build . -t python_boilerplate:smoke-test-tag
- name: Smoke test docker image
- name: Python Tests with pytest
run: pipenv run pytest --cov --cov-fail-under=85 --capture=no --log-cli-level=INFO -n auto
- name: Build Docker Image
run: |
docker build . -t python_boilerplate:smoke-test-tag
docker inspect python_boilerplate:smoke-test-tag
- name: Smoke Test Docker Image
run: |
docker run --rm python_boilerplate:smoke-test-tag param_3_from_command_line
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*.gz
logs/
data/
build/

### PyCharm ###
.idea
Expand Down Expand Up @@ -67,6 +68,7 @@ pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.pytest_report/
.tox/
.nox/
.coverage
Expand Down
110 changes: 59 additions & 51 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,53 +1,61 @@
# See https://pre-commit.com/ for usage and config
repos:
- repo: local
hooks:
- id: isort
name: isort
stages: [commit]
language: system
entry: pipenv run isort
types: [python]

- id: black
name: black
stages: [commit]
language: system
entry: pipenv run black
types: [python]

- id: flake8
name: flake8
stages: [commit]
language: system
entry: pipenv run flake8
types: [python]
exclude: setup.py

- id: mypy
name: mypy
stages: [commit]
language: system
entry: pipenv run mypy
types: [python]
require_serial: true

- id: pytest
name: pytest
stages: [commit]
language: system
# https://github.com/pytest-dev/pytest/issues/5502#issuecomment-1020761655
# Prevent Pytest logging error like: ValueError: I/O operation on closed file.
entry: pipenv run pytest --cov --cov-report html --capture=no --log-cli-level=DEBUG
types: [python]
pass_filenames: false

- id: pytest-cov
name: pytest
stages: [push]
language: system
# https://github.com/pytest-dev/pytest/issues/5502#issuecomment-1020761655
# Prevent Pytest logging error like: ValueError: I/O operation on closed file.
entry: pipenv run pytest --cov --cov-fail-under=85 --capture=no --log-cli-level=INFO
types: [python]
pass_filenames: false
# https://github.com/pre-commit/pre-commit-hooks/releases/tag/v4.3.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: mixed-line-ending
args: [ --fix, lf ]
- id: check-yaml
- id: debug-statements
- id: name-tests-test
args: [ --pytest-test-first ]
- id: detect-private-key
- repo: local
hooks:
- id: isort
name: isort
stages: [ commit ]
language: system
entry: pipenv run isort
types: [ python ]
- id: black
name: black
stages: [ commit ]
language: system
entry: pipenv run black
types: [ python ]
- id: flake8
name: flake8
stages: [ commit ]
language: system
entry: pipenv run flake8
types: [ python ]
exclude: setup.py
- id: mypy
name: mypy
stages: [ commit ]
language: system
entry: pipenv run mypy
types: [ python ]
require_serial: true
- id: pytest
name: pytest
stages: [ commit ]
language: system
# https://github.com/pytest-dev/pytest/issues/5502#issuecomment-1020761655
# Prevent Pytest logging error like: ValueError: I/O operation on closed file.
entry: pipenv run pytest --cov --cov-report html --html=./build/.pytest_report/report.html --self-contained-html --log-cli-level=DEBUG -n auto
types: [ python ]
pass_filenames: false
- id: pytest-cov
name: pytest
stages: [ push ]
language: system
# https://github.com/pytest-dev/pytest/issues/5502#issuecomment-1020761655
# Prevent Pytest logging error like: ValueError: I/O operation on closed file.
entry: pipenv run pytest --cov --cov-fail-under=85 --capture=no --log-cli-level=INFO -n auto
types: [ python ]
pass_filenames: false
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# [4.0.0](https://github.com/johnnymillergh/muscle-and-fitness-server/compare/3.0.0...4.0.0) (2022-09-18)


### Features

* **$async:** support decorate function with `@async_function` ([44a0a7e](https://github.com/johnnymillergh/python_boilerplate/commit/44a0a7eaf5ecf68ff0b8e170c0cb7c9c836b1fa9))
* **$flake8:** add more code constraints ([b978b9b](https://github.com/johnnymillergh/python_boilerplate/commit/b978b9b0d43dfb84ccc9e48b5ed51094baf531a6))
* **$GitHooks:** add more hooks for pre-commit ([5114647](https://github.com/johnnymillergh/python_boilerplate/commit/5114647115151d74f68f3855281487e753899215))
* **$loguru:** display process id in log ([5a0177b](https://github.com/johnnymillergh/python_boilerplate/commit/5a0177b6517ea64e296d855057e35f91c028d4ab))
* **$pandas:** add usage example of using pandas DataFrame to generate CSV ([161c7ba](https://github.com/johnnymillergh/python_boilerplate/commit/161c7bae5f0c95fc9e4d888cb2721567251cff09))
* **$pandas:** multiple conditions filter ([b25b7a6](https://github.com/johnnymillergh/python_boilerplate/commit/b25b7a63d755d8412023d03daf0c47b4eaab2bb1))
* move all artifacts under `build` directory ([50e6c46](https://github.com/johnnymillergh/python_boilerplate/commit/50e6c46b8d3ff5303aaf17b8b0a93a3391addf11))


### Performance Improvements

* **$profiling:** replace process_time() -> perf_counter() ([99ca066](https://github.com/johnnymillergh/python_boilerplate/commit/99ca066915c76498394fcbb90d50295577b98c16))
* **$profiling:** user `process_time()` for time profiling ([a55a4c7](https://github.com/johnnymillergh/python_boilerplate/commit/a55a4c7583f319a89626e18972bd0c0e1436c2fa))
* **$pytest:** distribute tests across multiple CPUs to speed up test execution ([b16b2db](https://github.com/johnnymillergh/python_boilerplate/commit/b16b2db587e99c1f253dd351218e42d4d60f17fd))



# [3.0.0](https://github.com/johnnymillergh/muscle-and-fitness-server/compare/2.0.0...3.0.0) (2022-09-06)


Expand Down
11 changes: 11 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,15 @@ matplotlib = "==3.5.3"
# Black is the uncompromising Python code formatter. By using it, you agree to cede control over minutiae of
# hand-formatting. https://pypi.org/project/black/
black = "==22.6.0"
# Naming Convention checker for Python. https://github.com/PyCQA/pep8-naming
pep8-naming = "==0.13.2"
# Linting & toolkit for checking your code base against coding style (PEP8). https://pypi.org/project/flake8/
flake8 = "==5.0.4"
# https://github.com/DmytroLitvinov/awesome-flake8-extensions
flake8-quotes = "==3.3.1"
flake8-print = "==5.0.0"
flake8-use-fstring = "==1.4"
flake8-comprehensions = "==3.10.0"
# isort your imports, so you don't have to. https://pypi.org/project/isort/
isort = "==5.10.1"
# Add type annotations to your Python programs, and use mypy to type check them. https://pypi.org/project/mypy/
Expand All @@ -60,5 +67,9 @@ pytest = "==7.1.2"
pytest-mock = "==3.8.2"
# This plugin produces coverage reports. https://pypi.org/project/pytest-cov/
pytest-cov = "==3.0.0"
# Plugin for generating HTML reports for pytest results. https://github.com/pytest-dev/pytest-html/
pytest-html = "==3.1.1"
# pytest xdist plugin for distributed testing and loop-on-failing modes. https://github.com/pytest-dev/pytest-xdist/
pytest-xdist = "==2.5.0"
# Call stack profiler for Python. Shows you why your code is slow! https://github.com/joerick/pyinstrument
pyinstrument = "==4.3.0"
Loading

0 comments on commit 6fe606b

Please sign in to comment.