Skip to content

Commit

Permalink
Started to work on the new build system
Browse files Browse the repository at this point in the history
  • Loading branch information
corvis committed Nov 13, 2020
1 parent 82d1416 commit 15c6de6
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/deploy-alpha.yml
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 }}
26 changes: 26 additions & 0 deletions .github/workflows/sanity-check.yml
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
68 changes: 68 additions & 0 deletions Makefile
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"; \
)
9 changes: 9 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ do
bash -c "cd src && python ./$module sdist --dist-dir=../dist"
echo "done"
;;
build-client)
module="client_setup.py"
echo "Applying copyright..."
./development/copyright-update
echo "done"
echo "Building wheel package..."
bash -c "cd src && python ./$module bdist_wheel --dist-dir=../dist --bdist-dir=../../build"
echo "done"
;;
publish)
echo "Uploading packages on PyPi"
twine upload -r pypi dist/*
Expand Down
18 changes: 18 additions & 0 deletions pyproject.toml
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
)/
)
'''
52 changes: 52 additions & 0 deletions setup.cfg
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

0 comments on commit 15c6de6

Please sign in to comment.