diff --git a/.ci/test.sh b/.ci/test.sh index 39a94700..b09c8f52 100644 --- a/.ci/test.sh +++ b/.ci/test.sh @@ -3,18 +3,7 @@ set -e if [[ $TEST == "API" ]]; then - # Run code linters - flake8 . - isort . --check-only - # Run tests with code coverage - pytest -v tests/ --cov=m2cgen/ --cov-report=xml:coverage.xml --ignore=tests/e2e/ - # Upload code coverage - wget -q https://uploader.codecov.io/latest/linux/codecov -O codecov - chmod +x codecov - ./codecov -f coverage.xml -Z - # Generate code examples - python setup.py develop - python tools/generate_code_examples.py ./generated_code_examples + make flake8 isort-check test-api run-codecov generate-code-examples fi if [[ $TEST == "E2E" ]]; then @@ -24,6 +13,5 @@ if [[ $TEST == "E2E" ]]; then fi if [[ $RELEASE == "true" ]]; then - python setup.py bdist_wheel --plat-name=any --python-tag=py3 - python setup.py sdist + make package fi diff --git a/Makefile b/Makefile index 98f678f8..67320588 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,61 @@ DOCKER_IMAGE := m2cgen DOCKER_RUN_ARGS := docker run --rm -it -v "$$PWD":"/m2cgen" $(DOCKER_IMAGE) +TARGETS := ./m2cgen ./tests +clean: + rm -rf ./m2cgen.egg-info ./dist ./build -docker-build: - docker build -t $(DOCKER_IMAGE) . +flake8: + flake8 $(TARGETS) + +isort: + isort $(TARGETS) + +isort-check: + isort $(TARGETS) --check-only + +test-api: + pytest -v tests/ --cov=m2cgen/ --cov-report=xml:coverage.xml --ignore=tests/e2e/ + +package: + python setup.py bdist_wheel --plat-name=any --python-tag=py3 && \ + python setup.py sdist + +publish: clean package + python -m twine upload dist/* + +install-requirements: + pip install -r requirements-test.txt + +install-develop: + python setup.py develop -docker-test-all: - $(DOCKER_RUN_ARGS) +pre-pr: install-requirements flake8 isort test-api -docker-test-unit: - $(DOCKER_RUN_ARGS) bash -c "pytest -v --fast tests/ --ignore=tests/e2e/" +generate-code-examples: install-develop + python tools/generate_code_examples.py ./generated_code_examples + +download-codecov: + wget -q https://uploader.codecov.io/latest/linux/codecov -O codecov && \ + chmod +x codecov + +run-codecov: download-codecov + ./codecov -f coverage.xml -Z + +docker-build: + docker build -t $(DOCKER_IMAGE) . docker-generate-examples: - $(DOCKER_RUN_ARGS) bash -c "python setup.py develop && python tools/generate_code_examples.py generated_code_examples" + $(DOCKER_RUN_ARGS) make generate-code-examples docker-lint: - $(DOCKER_RUN_ARGS) bash -c "flake8 . && isort . --check-only" + $(DOCKER_RUN_ARGS) make flake8 isort-check + +docker-test-api: + $(DOCKER_RUN_ARGS) make test-api + +docker-pre-pr: + $(DOCKER_RUN_ARGS) make pre-pr docker-shell: $(DOCKER_RUN_ARGS) bash - -docker-pre-pr: docker-lint docker-test-all diff --git a/README.md b/README.md index ee250497..d075a050 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ **m2cgen** (Model 2 Code Generator) - is a lightweight library which provides an easy way to transpile trained statistical models into a native code (Python, C, Java, Go, JavaScript, Visual Basic, C#, PowerShell, R, PHP, Dart, Haskell, Ruby, F#, Rust, Elixir). * [Installation](#installation) +* [Development](#development) * [Supported Languages](#supported-languages) * [Supported Models](#supported-models) * [Classification Output](#classification-output) @@ -23,6 +24,15 @@ Supported Python version is >= **3.7**. pip install m2cgen ``` +## Development +Make sure the following command runs successfully before submitting a PR: +``` +make pre-pr +``` +Alternatively you can run the Docker version of the same command: +``` +make docker-build docker-pre-pr +``` ## Supported Languages diff --git a/m2cgen/VERSION.txt b/m2cgen/VERSION.txt index f374f666..57121573 100644 --- a/m2cgen/VERSION.txt +++ b/m2cgen/VERSION.txt @@ -1 +1 @@ -0.9.1 +0.10.1 diff --git a/requirements-test.txt b/requirements-test.txt index ff22e2c4..35b05695 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,3 +1,12 @@ +# Other stuff +numpy==1.23.3; python_version > "3.7" +numpy==1.21.5; python_version <= "3.7" +scipy==1.9.1; python_version > "3.7" +scipy==1.7.3; python_version <= "3.7" + +# Cython +Cython==0.29.32; sys_platform == 'darwin' and platform_machine == 'arm64' + # Supported models scikit-learn==1.0.2 xgboost==1.6.2 @@ -13,8 +22,5 @@ pytest-mock==3.8.2 pytest-cov==3.0.0 py-mini-racer==0.6.0 -# Other stuff -numpy==1.23.3; python_version > "3.7" -numpy==1.21.5; python_version <= "3.7" -scipy==1.9.1; python_version > "3.7" -scipy==1.7.3; python_version <= "3.7" +# Publishing +twine