Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymillergh committed Nov 17, 2021
2 parents 135c25f + 5eadf3e commit 3b59538
Show file tree
Hide file tree
Showing 53 changed files with 2,203 additions and 288 deletions.
149 changes: 143 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# http://editorconfig.org/#file-format-details
root = true

[*]
Expand All @@ -7,10 +6,148 @@ end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 120
tab_width = 4
ij_continuation_indent_size = 8
ij_formatter_off_tag = @formatter:off
ij_formatter_on_tag = @formatter:on
ij_formatter_tags_enabled = false
ij_smart_tabs = false
ij_visual_guides = none
ij_wrap_on_typing = false

[*.md]
trim_trailing_whitespace = false
[.editorconfig]
ij_editorconfig_align_group_field_declarations = false
ij_editorconfig_space_after_colon = false
ij_editorconfig_space_after_comma = true
ij_editorconfig_space_before_colon = false
ij_editorconfig_space_before_comma = false
ij_editorconfig_spaces_around_assignment_operators = true

[Makefile]
indent_style = tab
[{*.htm,*.html,*.ng,*.sht,*.shtm,*.shtml}]
ij_html_add_new_line_before_tags = body, div, p, form, h1, h2, h3
ij_html_align_attributes = true
ij_html_align_text = false
ij_html_attribute_wrap = normal
ij_html_block_comment_at_first_column = true
ij_html_do_not_align_children_of_min_lines = 0
ij_html_do_not_break_if_inline_tags = title, h1, h2, h3, h4, h5, h6, p
ij_html_do_not_indent_children_of_tags = html, body, thead, tbody, tfoot
ij_html_enforce_quotes = false
ij_html_inline_tags = a, abbr, acronym, b, basefont, bdo, big, br, cite, cite, code, dfn, em, font, i, img, input, kbd, label, q, s, samp, select, small, span, strike, strong, sub, sup, textarea, tt, u, var
ij_html_keep_blank_lines = 2
ij_html_keep_indents_on_empty_lines = false
ij_html_keep_line_breaks = true
ij_html_keep_line_breaks_in_text = true
ij_html_keep_whitespaces = false
ij_html_keep_whitespaces_inside = span, pre, textarea
ij_html_line_comment_at_first_column = true
ij_html_new_line_after_last_attribute = never
ij_html_new_line_before_first_attribute = never
ij_html_quote_style = double
ij_html_remove_new_line_before_tags = br
ij_html_space_after_tag_name = false
ij_html_space_around_equality_in_attribute = false
ij_html_space_inside_empty_tag = false
ij_html_text_wrap = normal

[{*.markdown,*.md}]
ij_markdown_force_one_space_after_blockquote_symbol = true
ij_markdown_force_one_space_after_header_symbol = true
ij_markdown_force_one_space_after_list_bullet = true
ij_markdown_force_one_space_between_words = true
ij_markdown_keep_indents_on_empty_lines = false
ij_markdown_max_lines_around_block_elements = 1
ij_markdown_max_lines_around_header = 1
ij_markdown_max_lines_between_paragraphs = 1
ij_markdown_min_lines_around_block_elements = 1
ij_markdown_min_lines_around_header = 1
ij_markdown_min_lines_between_paragraphs = 1

[{*.py,*.pyw}]
ij_python_align_collections_and_comprehensions = true
ij_python_align_multiline_imports = true
ij_python_align_multiline_parameters = true
ij_python_align_multiline_parameters_in_calls = true
ij_python_blank_line_at_file_end = true
ij_python_blank_lines_after_imports = 1
ij_python_blank_lines_after_local_imports = 0
ij_python_blank_lines_around_class = 1
ij_python_blank_lines_around_method = 1
ij_python_blank_lines_around_top_level_classes_functions = 2
ij_python_blank_lines_before_first_method = 0
ij_python_call_parameters_new_line_after_left_paren = false
ij_python_call_parameters_right_paren_on_new_line = false
ij_python_call_parameters_wrap = normal
ij_python_dict_alignment = 0
ij_python_dict_new_line_after_left_brace = false
ij_python_dict_new_line_before_right_brace = false
ij_python_dict_wrapping = 1
ij_python_from_import_new_line_after_left_parenthesis = false
ij_python_from_import_new_line_before_right_parenthesis = false
ij_python_from_import_parentheses_force_if_multiline = false
ij_python_from_import_trailing_comma_if_multiline = false
ij_python_from_import_wrapping = 1
ij_python_hang_closing_brackets = false
ij_python_keep_blank_lines_in_code = 1
ij_python_keep_blank_lines_in_declarations = 1
ij_python_keep_indents_on_empty_lines = false
ij_python_keep_line_breaks = true
ij_python_method_parameters_new_line_after_left_paren = false
ij_python_method_parameters_right_paren_on_new_line = false
ij_python_method_parameters_wrap = normal
ij_python_new_line_after_colon = false
ij_python_new_line_after_colon_multi_clause = true
ij_python_optimize_imports_always_split_from_imports = false
ij_python_optimize_imports_case_insensitive_order = false
ij_python_optimize_imports_join_from_imports_with_same_source = false
ij_python_optimize_imports_sort_by_type_first = true
ij_python_optimize_imports_sort_imports = true
ij_python_optimize_imports_sort_names_in_from_imports = false
ij_python_space_after_comma = true
ij_python_space_after_number_sign = true
ij_python_space_after_py_colon = true
ij_python_space_before_backslash = true
ij_python_space_before_comma = false
ij_python_space_before_for_semicolon = false
ij_python_space_before_lbracket = false
ij_python_space_before_method_call_parentheses = false
ij_python_space_before_method_parentheses = false
ij_python_space_before_number_sign = true
ij_python_space_before_py_colon = false
ij_python_space_within_empty_method_call_parentheses = false
ij_python_space_within_empty_method_parentheses = false
ij_python_spaces_around_additive_operators = true
ij_python_spaces_around_assignment_operators = true
ij_python_spaces_around_bitwise_operators = true
ij_python_spaces_around_eq_in_keyword_argument = false
ij_python_spaces_around_eq_in_named_parameter = false
ij_python_spaces_around_equality_operators = true
ij_python_spaces_around_multiplicative_operators = true
ij_python_spaces_around_power_operator = true
ij_python_spaces_around_relational_operators = true
ij_python_spaces_around_shift_operators = true
ij_python_spaces_within_braces = false
ij_python_spaces_within_brackets = false
ij_python_spaces_within_method_call_parentheses = false
ij_python_spaces_within_method_parentheses = false
ij_python_use_continuation_indent_for_arguments = false
ij_python_use_continuation_indent_for_collection_and_comprehensions = false
ij_python_use_continuation_indent_for_parameters = true
ij_python_wrap_long_lines = false

[{*.yaml,*.yml}]
indent_size = 2
ij_yaml_align_values_properties = do_not_align
ij_yaml_autoinsert_sequence_marker = true
ij_yaml_block_mapping_on_new_line = false
ij_yaml_indent_sequence_value = true
ij_yaml_keep_indents_on_empty_lines = false
ij_yaml_keep_line_breaks = true
ij_yaml_sequence_on_new_line = false
ij_yaml_space_before_colon = false
ij_yaml_spaces_within_braces = true
ij_yaml_spaces_within_brackets = true

[*.conf]
indent_size = 2
32 changes: 16 additions & 16 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build and Test

on:
pull_request: {}
pull_request: { }
push:
branches:
- 'main'
Expand All @@ -10,40 +10,40 @@ on:
- '**.md'
- '_config.yml'
- '**.tweet'
tags: "*"
tags: '*'

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2.2.2
with:
python-version: "3.10.0"
architecture: x64

- 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=100
- name: Import Sorting with [isort]
run: pipenv run isort --recursive --diff .
- name: Code Formatting with [black]
run: pipenv run black --check .
- name: Linting with [flake8]
run: pipenv run flake8
- name: Static type check with [mypy]
run: pipenv run mypy
- name: Python tests with [pytest]
run: pipenv run pytest --cov

docker-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Build Docker Image
# https://www.guru99.com/smoke-testing.html
- name: Build Docker Image for Smoke Test
run: docker build . -t home_guardian:test

- name: Smoke Test Docker Image
run: |
docker run --rm home_guardian:test 10
# docker run --rm home_guardian:test
run: docker --version
17 changes: 9 additions & 8 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Publish to GitHub packages
uses: whoan/docker-build-with-cache-action@v2
with:
registry: docker.pkg.github.com
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
image_name: ${{ github.repository }}/home_guardian
- name: Publish to GitHub packages
uses: whoan/docker-build-with-cache-action@v5
with:
registry: docker.pkg.github.com
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
image_name: ${{ github.repository }}/home_guardian
push_git_tag: true
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
# Created by https://www.gitignore.io/api/python
# Edit at https://www.gitignore.io/?templates=python

### Project ###
*.db
*.gz
logs/
data/

### PyCharm ###
.idea
*.iml
out
gen

### VisualStudioCode template
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/


### Python ###
# Byte-compiled / optimized / DLL files
Expand Down
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ repos:
types: [python]
pass_filenames: false

- id: pytest-cov
name: pytest
stages: [push]
language: system
entry: pipenv run pytest --cov --cov-fail-under=100
types: [python]
pass_filenames: false
# - id: pytest-cov
# name: pytest
# stages: [push]
# language: system
# entry: pipenv run pytest --cov --cov-fail-under=100
# types: [python]
# pass_filenames: false
47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 1.0.0 (2021-11-17)


### Features

* **$common:** refine [@debounce](https://github.com/debounce) and [@throttle](https://github.com/throttle) decorators ([46dce1d](https://github.com/johnnymillergh/home_guardian/commit/46dce1d0b53b2b9522bf7e03e31e00492722771b))
* **$conf:** support dynamic environment variable configuration ([0a00573](https://github.com/johnnymillergh/home_guardian/commit/0a005736e425a603614482faedab7c25ad228857))
* **$Decorator:** create elapsed time decorator ([0c18b70](https://github.com/johnnymillergh/home_guardian/commit/0c18b70d9210aeb41e6aa97f1f44e33b7c0fe8f9))
* **$loguru:** integrate loguru for logging ([180f824](https://github.com/johnnymillergh/home_guardian/commit/180f824140adc65871c77c0daa15f5ec6948507c))
* **$Loguru:** set default log level as "INFO" ([1b71e45](https://github.com/johnnymillergh/home_guardian/commit/1b71e4585c88237d70f7d1a2ae9f81b72182ba01))
* **$message:** send warning email when detecting face ([7e7450a](https://github.com/johnnymillergh/home_guardian/commit/7e7450aa40b34a59aced003129e431eec80e8695))
* **$message:** support configurable muting email ([5894748](https://github.com/johnnymillergh/home_guardian/commit/589474819c463a301ceaa8f6be040149a32a5a2f))
* **$Message:** support sending email ([e101760](https://github.com/johnnymillergh/home_guardian/commit/e101760f4dc4b2ec67238070a35dbf3e0fa80aec))
* **$message:** support sending redered HTML in email ([f423fec](https://github.com/johnnymillergh/home_guardian/commit/f423fec3bd3b7f4c2bd004674b92176c1f7e7ccb))
* **$OpenCV:** detect face and save the image asynchronously ([4651abb](https://github.com/johnnymillergh/home_guardian/commit/4651abb90277fe467bb1d08c12f9e93e095334ef))
* **$opencv:** persistence detected face info ([1bec964](https://github.com/johnnymillergh/home_guardian/commit/1bec964080c7eb3931f3132133b9b9f52722a269))
* **$OpenCV:** support face training and recognition ([9fd983d](https://github.com/johnnymillergh/home_guardian/commit/9fd983d5851aed81769cc82451de3ec1b1016c35))
* **$OpenCV:** tell headless or not ([b3097eb](https://github.com/johnnymillergh/home_guardian/commit/b3097eb6fee51a00f7fc2daee954634ac027b757))
* **$startup:** define multiple startup mode identified by runtime arguments ([a19bf5e](https://github.com/johnnymillergh/home_guardian/commit/a19bf5e2b2a98a92e5caa6a7d8a37f5c8e883f26))
* **$template:** add Jinjia2 dependency ([6f63176](https://github.com/johnnymillergh/home_guardian/commit/6f631768db36556e197dc28ee94ee4ef1ab983cc))
* integrate peewee as ORM library ([ae56fe5](https://github.com/johnnymillergh/home_guardian/commit/ae56fe5fa3076059a15912322064abe37c489790))
* new startup mode for collecting data ([01872b5](https://github.com/johnnymillergh/home_guardian/commit/01872b53df72cd82ac5891a86aff5cdfbc0e7a0c))


### Performance Improvements

* **$Async:** add async debounce decorator ([661f1ac](https://github.com/johnnymillergh/home_guardian/commit/661f1ac88e8675054ef9a623daf0e670ba4044c9))
* **$db:** refine ORM log when initializing db ([5fd5b1f](https://github.com/johnnymillergh/home_guardian/commit/5fd5b1f3f3d81f9dc46eb55d5448fb5c75f140e0))
* **$email:** only login and logout from the email server once ([cef9cf9](https://github.com/johnnymillergh/home_guardian/commit/cef9cf926eb9868f59f2d26552018c4310a869bf))
* **$Executor:** cleanup thread pool executor when exiting program ([b254d41](https://github.com/johnnymillergh/home_guardian/commit/b254d418f4eddde5aff63fa494243170402df5a9))
* **$loguru:** abstract function for loguru configuration ([b1433d1](https://github.com/johnnymillergh/home_guardian/commit/b1433d19fabc1f127f33f4acadab8975c6c51b88))
* **$loguru:** override default console log format ([71181d5](https://github.com/johnnymillergh/home_guardian/commit/71181d590ad346610d99fcb26117e0a813279a40))
* **$OpenCV:** change dependency to opencv-python-headless==4.5.4.58 ([fe471dd](https://github.com/johnnymillergh/home_guardian/commit/fe471dd2adbb8f3a6bc2de8175c2d6351fdac63b))
* **$OpenCV:** multi-threading for OpenCV ([bbfecda](https://github.com/johnnymillergh/home_guardian/commit/bbfecda78cd71ee6a86f9830a856544dfd988c00))
* **$OpenCV:** read embedded xml resource ([a0c818e](https://github.com/johnnymillergh/home_guardian/commit/a0c818eb461f4367dff96fa6d0272fadd8f328c6))
* **$Python:** support pooled multi thread ([cc27bce](https://github.com/johnnymillergh/home_guardian/commit/cc27bce3aa884262ab0f7b89d99661e1ecb3be34))
* support function's debounce and throttle ([e3aa552](https://github.com/johnnymillergh/home_guardian/commit/e3aa552488669be85172f1b29b04ca6eb074681b))
* upgrade dependencies ([a07af6a](https://github.com/johnnymillergh/home_guardian/commit/a07af6a94b1c324705ac82a3c6bf916bc6d73c8f))


### BREAKING CHANGES

* **$OpenCV:** if it's not headless, show capture window
* **$OpenCV:** support face training and recognition
* **$OpenCV:** use parallelism (multi-thread) to work with CPU bound operation
* **$message:** support sending redered HTML in email
* **$template:** support template rendering
8 changes: 3 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ FROM base AS runtime
COPY --from=python-deps /.venv /.venv
ENV PATH="/.venv/bin:$PATH"

# Create and switch to a new user
RUN useradd --create-home appuser
WORKDIR /home/appuser
USER appuser
# Has to use "root" user to run this application
WORKDIR /app

# Install application into container
COPY . .

# Run the executable
ENTRYPOINT ["python", "-m", "home_guardian"]
CMD ["10"]
CMD ["detect"]
Loading

1 comment on commit 3b59538

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.