Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LC_ALL=C.UTF-8
LANG=C.UTF-8
27 changes: 16 additions & 11 deletions .github/workflows/style_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.7]
python-version: [3.8]

steps:
- uses: actions/checkout@v2
Expand All @@ -24,25 +24,30 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install black
python -m pip install --upgrade pip pipenv
pipenv install --dev --skip-lock
- name: Black pep8 style
run: |
black ./ --check
make check-style-python

cpp-style-check:

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install python dependencies
run: |
python -m pip install --upgrade pip pipenv
pipenv install --dev --skip-lock
- name: Lint with clang-format
run: |
# lint files (all .cpp and .h files) inplace
find ./src/bindings/ -iname *.hpp -o -iname *.cpp -o -iname *.h -o -iname *.cc | xargs clang-format -i -style='file'
# print changes
git diff src
# already well formated if 'git diff' doesn't output
! ( git diff src | grep -q ^ ) || exit
make check-style-cpp
27 changes: 6 additions & 21 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,17 @@ jobs:
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install coverage
pip install wheel
- name: Set up submodules
run: |
git submodule update --init --recursive
rm -rf third_party/differential-privacy/java
rm -rf third_party/differential-privacy/examples/java
- name: Set environment variables
uses: allenevans/set-env@v1.0.0
with:
PIPENV_DEFAULT_PYTHON_VERSION: ${{ matrix.python-version }}
- name: Install pre-requisites
run: |
sudo apt-get update
bash ./prereqs_linux.sh
export PATH="$PATH:$HOME/bin"
- name: Build pydp lib
run: |
bazel build src/python:bindings_test --verbose_failures
rm -f pydp.so
cp -f ./bazel-bin/src/bindings/pydp.so ./pydp
bash ./build_PyDP.sh
- name: Run tests
run: |
pip install pycodestyle
pip install pytest
python setup.py test
- name: Check test coverage
run: |
coverage run --source pydp setup.py test
coverage report --ignore-errors --fail-under 95 -m
make run-tests-only
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ __pycache__/
*$py.class

# Distribution / packaging
Pipfile.lock
.Python
env/
build/
Expand All @@ -37,7 +38,6 @@ wheels/

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
Expand All @@ -46,4 +46,4 @@ coverage.xml
*.cover
.hypothesis/
.pytest_cache/
.mypy_cache/
.mypy_cache/
54 changes: 29 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
endef
export BROWSER_PYSCRIPT

# check for python version
python_version_full := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1)))
python_version_major := $(word 1,${python_version_full})

ifeq ($(python_version_major), 2)
python_var := python3
else
python_var := python
endif

define PRINT_HELP_PYSCRIPT
import re, sys

Expand All @@ -34,10 +24,13 @@ for line in sys.stdin:
endef
export PRINT_HELP_PYSCRIPT

BROWSER := python -c "$$BROWSER_PYSCRIPT"
BROWSER := pipenv run python -c "$$BROWSER_PYSCRIPT"

help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
@pipenv run python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)

build: ## compile bindings and genearte Python module
./build_PyDP.sh

clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts

Expand All @@ -55,30 +48,41 @@ clean-pyc: ## remove Python file artifacts
find . -name '__pycache__' -exec rm -fr {} +

clean-test: ## remove test and coverage artifacts
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/
rm -fr .pytest_cache

test: ## run tests quickly with the default Python
${python_var} setup.py test
format-style-python: ## format Python files code style in-place
@ pipenv run black ./

format-style-cpp: ## format C++ files code style in-place
@ find ./src/bindings/ -iname *.hpp -o -iname *.cpp -o -iname *.h -o -iname *.cc | \
xargs clang-format -i -style='file'

check-style-python:
@ echo "\e[36mChecking Python code style.\e[0m" && \
pipenv run black ./ --check --diff || \
( echo "\e[33mRun \e[36mmake format-style-python\e[33m to fix style errors.\e[0m"; \
exit 1 )

check-style-cpp:
@ echo "\e[36mChecking C++ code style.\e[0m" && \
pipenv run ./run-clang-format.py -r src/bindings/ || \
( echo "\e[33mRun \e[34mmake format-style-cpp\e[33m to fix style errors.\e[0m"; \
exit 1 )

test-all: ## run tests on every Python version with tox
tox
run-tests-only: install
pipenv run pytest tests

coverage: ## check code coverage quickly with the default Python
coverage run --source pydp setup.py test
coverage report -m
coverage html
$(BROWSER) htmlcov/index.html
test: check-style-python check-style-cpp run-tests-only ## check style and run tests

release: dist ## package and upload a release
twine upload dist/*

dist: clean ## builds source and wheel package
${python_var} setup.py sdist
${python_var} setup.py bdist_wheel
pipenv run python setup.py sdist
pipenv run python setup.py bdist_wheel
ls -l dist

install: clean ## install the package to the active Python's site-packages
${python_var} setup.py install
pipenv run python setup.py install
4 changes: 1 addition & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ verify_ssl = true
[dev-packages]
setuptools = "*"
bumpversion = "==0.5.3"
tox = "==3.5.2"
pytest = "*"
pycodestyle = "*"
black = "*"
twine = "*"
coverage = "*"

[packages]
Loading