Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviml committed Nov 28, 2020
2 parents c7eec66 + 08adfe0 commit 088f7ef
Show file tree
Hide file tree
Showing 82 changed files with 1,545 additions and 1,075 deletions.
7 changes: 0 additions & 7 deletions .coveragerc

This file was deleted.

3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ dmypy.json
.pyre/

#VSCode
.vscode/
.vscode/*
!.vscode/settings.json
.idea

# Ignoring Pipfile.lock since we support python 3.6, 3.7 and 3.8
Expand Down
40 changes: 19 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
fail_fast: true
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: check-json
- id: pretty-format-json
args:
- --autofix
- --indent
- '4'
- repo: local
hooks:
- id: isort
name: isort
entry: pipenv run isort
language: python
types: [python]
args: []
require_serial: false
- id: black
name: black
entry: pipenv run black apps/controllerx tests
language: system
pass_filenames: false
always_run: true
entry: pipenv run black
language: python
types: [python]
- id: flake8
name: flake8
entry: pipenv run flake8 apps/controllerx tests
language: system
pass_filenames: false
always_run: true
entry: pipenv run flake8
language: python
types: [python]
- id: mypy
name: mypy
entry: pipenv run mypy apps/controllerx
language: system
entry: pipenv run mypy apps/controllerx/ tests/
language: python
types: [python]
pass_filenames: false
always_run: true
- id: pytest
name: pytest
entry: pipenv run pytest
language: system
language: python
types: [python]
pass_filenames: false
always_run: true
22 changes: 22 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 100,
"python.testing.pytestEnabled": true,
"editor.formatOnSave": true,
"python.formatting.provider": "black",
"python.analysis.typeCheckingMode": "basic",
"python.analysis.diagnosticMode": "workspace",
"python.analysis.stubPath": "apps/controllerx",
"python.testing.pytestArgs": [
"tests"
],
"python.languageServer": "Pylance",
"python.linting.mypyEnabled": true,
"python.linting.mypyCategorySeverity.note": "Error",
"python.linting.flake8Enabled": true,
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
}
57 changes: 45 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,70 @@
This project uses pipenv as python management tool. Run the following commands to install dependencies and hooking up the pre-commit to git

```
pipenv install --dev
pipenv install --dev --python python3.6
pipenv shell
pre-commit install
```

_Note: I recommend working with Python 3.6 since is the minimum version supported_

## Adding a new controller

New controllers need to be added into the `apps/controllerx/devices/` and you will need to define the mapping for the integration you are adding support to.

Note that this project will only accept the mapping that the original controller would follow with its original hub.

## Imports

Run the following to fix imports order:

```shell
pipenv run isort apps/controllerx/ tests/
```

## Format

Run the following to fix formatting:

```shell
pipenv run black apps/controllerx/ tests/
```

## Typing

Run the following to check consistency in the typings:

```
pipenv run mypy apps/controllerx
```shell
pipenv run mypy apps/controllerx/ tests/
```

## Linting

Run the following to check for stylings:

```
pipenv run flake8 apps/controllerx
```shell
pipenv run flake8 apps/controllerx/ tests/
```

## Test

Run the following command for the tests:

```
```shell
pipenv run pytest --cov=apps
```

or the following to get a report of the missing lines to be tested:

```
```shell
pytest --cov-report term-missing --cov=apps
```

## Pre-commit

Once you have the code ready, pre-commit will run some checks to make sure the code follows the format and the tests did not break. If you want to run the check for all files at any point, run:

```
```shell
pipenv run pre-commit run --all-files
```

Expand All @@ -62,13 +80,13 @@ You can use the tool `commitizen` to commit based in a standard. If you are in t

[Install Jekyll](https://jekyllrb.com/docs/) and run the documentation locally with:

```
```shell
cd docs
bundle install
bundle exec jekyll serve
```

## Pull request
## Pull Request

Feel free to open a PR on GitHub. When submitting the PR several points will be checked:

Expand All @@ -77,17 +95,32 @@ Feel free to open a PR on GitHub. When submitting the PR several points will be
- Typing (with mypy)
- Formatting (with black)

## How to change someone else's PR code

If you have the permission to change code from the source branch of the PR, then you can do the following to change it. First, you will need to add the remote:

```shell
git remote add <username> git@github.com:<username>/controllerx.git
```

Then you will need to fetch, create and checkout the branch:

```shell
git fetch <username> <remote-branch>
git checkout -b <username>-<remote-branch> <username>/<remote-branch>
```

## Deployment

Thanks to the Azure Pipelines, we are able to deploy by just creating a new tag on git. So first, we will need to bump version with `commitizen` by running the following line in the `master` branch:

```
```shell
cz bump --no-verify
```

`--prerelease beta` tag can be added to create a pre-release. Note that you can also add `--dry-run` to see which version will bump without commiting anything. Then, we can directly push the tags:

```
```shell
git push origin master --tags
```

Expand Down
23 changes: 12 additions & 11 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@ url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
black = "==19.10b0"
pytest = "~=6.0"
pytest-asyncio = "~=0.12"
pytest-cov = "~=2.8"
pytest-mock = "~=3.1"
mock = "~=4.0"
pre-commit = "~=2.4"
commitizen = "~=1.22"
mypy = "~=0.770"
flake8 = "~=3.8"
black = "==20.8b1"
pytest = "==6.1.2"
pytest-asyncio = "==0.14.0"
pytest-cov = "==2.10.1"
pytest-mock = "==3.3.1"
mock = "==4.0.2"
pre-commit = "==2.9.2"
commitizen = "==2.8.2"
mypy = "==0.790"
flake8 = "==3.8.4"
isort = "==5.6.4"
controllerx = {path = ".", editable = true}

[packages]
appdaemon = "~=4.0"
appdaemon = "==4.0.5"

[pipenv]
allow_prereleases = true
1 change: 1 addition & 0 deletions apps/controllerx/controllerx.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
from cx_devices.osram import *
from cx_devices.phillips import *
from cx_devices.smartthings import *
from cx_devices.sonoff import *
from cx_devices.trust import *
1 change: 0 additions & 1 deletion apps/controllerx/cx_const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Any, Awaitable, Callable, Dict, Tuple, Union


ActionFunction = Callable[..., Awaitable[Any]]
TypeAction = Union[ActionFunction, Tuple, str]
ActionEvent = Union[str, int]
Expand Down

0 comments on commit 088f7ef

Please sign in to comment.