forked from corvis/prana_rc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started to work on the new build system
- Loading branch information
Showing
6 changed files
with
207 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
name: Publish alpha version | ||
push: | ||
branches: | ||
- alpha | ||
|
||
jobs: | ||
run: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.7 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Lint with flake8 | ||
run: make | ||
|
||
- name: Build test packages | ||
run: make build ALPHA_VERSION=`date +%Y%m%d.%H%M` | ||
|
||
- name: Publish packages | ||
run: make publish PYPI_REPOSITORY_URL=https://test.pypi.org/legacy/ PYPI_API_KEY=${{ secrets.pypi_test_password }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
name: Lint source code and apply copyright | ||
on: push | ||
|
||
jobs: | ||
run: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.7 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Lint with flake8 | ||
run: make flake8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
VIRTUAL_ENV_PATH=venv | ||
SKIP_VENV="${NO_VENV}" | ||
PYPI_API_KEY := | ||
PYPI_REPOSITORY_URL := | ||
ALPHA_VERSION := | ||
|
||
.DEFAULT_GOAL := pre_commit | ||
|
||
pre_commit: copyright flake8 | ||
|
||
copyright: | ||
@( \ | ||
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \ | ||
echo "Applying copyright..."; \ | ||
./development/copyright-update; \ | ||
echo "DONE: copyright"; \ | ||
) | ||
|
||
flake8: | ||
@( \ | ||
set -e; \ | ||
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \ | ||
echo "Runing Flake8 checks..."; \ | ||
flake8 ./src/prana_rc --count --statistics; \ | ||
echo "DONE: Flake8"; \ | ||
) | ||
|
||
build: copyright format flake8 clean | ||
@( \ | ||
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \ | ||
echo "Building wheel package..."; \ | ||
bash -c "cd src && VERSION_OVERRIDE="$(ALPHA_VERSION)" python ./setup.py bdist_wheel --dist-dir=../dist --bdist-dir=../../build"; \ | ||
echo "DONE: wheel package"; \ | ||
) | ||
@( \ | ||
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \ | ||
echo "Building source distribution..."; \ | ||
bash -c "cd src && VERSION_OVERRIDE="$(ALPHA_VERSION)" python ./setup.py sdist --dist-dir=../dist"; \ | ||
echo "DONE: source distribution"; \ | ||
) | ||
@( \ | ||
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \ | ||
echo "Building client wheel package..."; \ | ||
bash -c "cd src && VERSION_OVERRIDE="$(ALPHA_VERSION)" python ./client_setup.py bdist_wheel --dist-dir=../dist --bdist-dir=../../build"; \ | ||
echo "DONE: wheel client package"; \ | ||
) | ||
|
||
clean: | ||
@(rm -rf src/build dist/* *.egg-info src/*.egg-info .pytest_cache) | ||
|
||
format: | ||
@( \ | ||
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \ | ||
echo "Runing Black code formater..."; \ | ||
black ./src/prana_rc; \ | ||
echo "DONE: Black"; \ | ||
) | ||
|
||
publish: | ||
@( \ | ||
set -e; \ | ||
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \ | ||
if [ ! -z $(PYPI_API_KEY) ]; then export TWINE_USERNAME="pypi"; export TWINE_PASSWORD="$(PYPI_API_KEY)"; fi; \ | ||
if [ ! -z $(PYPI_REPOSITORY_URL) ]; then export TWINE_REPOSITORY_URL="$(PYPI_REPOSITORY_URL)"; fi; \ | ||
echo "Uploading to PyPi"; \ | ||
twine upload -r pypi dist/*; \ | ||
echo "DONE: Publish"; \ | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[tool.black] | ||
line-length = 120 | ||
target-version = ['py37'] | ||
exclude = ''' | ||
( | ||
/( | ||
\.eggs # exclude a few common directories in the | ||
| \.git # root of the project | ||
| \.mypy_cache | ||
| \.tox | ||
| \.venv | ||
| _build | ||
| buck-out | ||
| build | ||
| dist | ||
)/ | ||
) | ||
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
[flake8] | ||
max-complexity = 12 | ||
max-line-length=127 | ||
|
||
exclude = | ||
# No need to traverse our git directory | ||
.git, | ||
# There's no value in checking cache directories | ||
__pycache__, | ||
# This contains our built documentation | ||
build, | ||
# This contains builds of flake8 that we don't want to check | ||
dist, | ||
*.egg-info | ||
|
||
ignore = | ||
# W291 trailing whitespace | ||
W291, | ||
# W391 blank line at end of file | ||
W391, | ||
# E501: line too long | ||
E501, | ||
# W503: Line break occurred before a binary operator | ||
W503, | ||
# E203: Whitespace before ':' | ||
E203, | ||
# D202 No blank lines allowed after function docstring | ||
D202, | ||
# W504 line break after binary operator | ||
W504 | ||
|
||
per-file-ignores = | ||
# imported but unused | ||
__init__.py: F401 | ||
|
||
[codespell] | ||
skip = *.po,*.ts,.pyc | ||
ignore-words-list = hass | ||
|
||
[mypy] | ||
python_version = 3.7 | ||
show_error_codes = true | ||
ignore_errors = false | ||
warn_return_any = true | ||
ignore_missing_imports = True | ||
disallow_any_generics = false | ||
pretty = true | ||
|
||
[mypy-examples] | ||
ignore_errors = true | ||
follow_imports = silent | ||
ignore_missing_imports = true |