Skip to content

Commit 9784632

Browse files
authored
Improve the development flow and extend the README with steps recommended before submitting a PR (#544)
1 parent 9b8e5db commit 9784632

5 files changed

Lines changed: 72 additions & 30 deletions

File tree

.ci/test.sh

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,7 @@
33
set -e
44

55
if [[ $TEST == "API" ]]; then
6-
# Run code linters
7-
flake8 .
8-
isort . --check-only
9-
# Run tests with code coverage
10-
pytest -v tests/ --cov=m2cgen/ --cov-report=xml:coverage.xml --ignore=tests/e2e/
11-
# Upload code coverage
12-
wget -q https://uploader.codecov.io/latest/linux/codecov -O codecov
13-
chmod +x codecov
14-
./codecov -f coverage.xml -Z
15-
# Generate code examples
16-
python setup.py develop
17-
python tools/generate_code_examples.py ./generated_code_examples
6+
make flake8 isort-check test-api run-codecov generate-code-examples
187
fi
198

209
if [[ $TEST == "E2E" ]]; then
@@ -24,6 +13,5 @@ if [[ $TEST == "E2E" ]]; then
2413
fi
2514

2615
if [[ $RELEASE == "true" ]]; then
27-
python setup.py bdist_wheel --plat-name=any --python-tag=py3
28-
python setup.py sdist
16+
make package
2917
fi

Makefile

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,61 @@
11
DOCKER_IMAGE := m2cgen
22
DOCKER_RUN_ARGS := docker run --rm -it -v "$$PWD":"/m2cgen" $(DOCKER_IMAGE)
3+
TARGETS := ./m2cgen ./tests
34

5+
clean:
6+
rm -rf ./m2cgen.egg-info ./dist ./build
47

5-
docker-build:
6-
docker build -t $(DOCKER_IMAGE) .
8+
flake8:
9+
flake8 $(TARGETS)
10+
11+
isort:
12+
isort $(TARGETS)
13+
14+
isort-check:
15+
isort $(TARGETS) --check-only
16+
17+
test-api:
18+
pytest -v tests/ --cov=m2cgen/ --cov-report=xml:coverage.xml --ignore=tests/e2e/
19+
20+
package:
21+
python setup.py bdist_wheel --plat-name=any --python-tag=py3 && \
22+
python setup.py sdist
23+
24+
publish: clean package
25+
python -m twine upload dist/*
26+
27+
install-requirements:
28+
pip install -r requirements-test.txt
29+
30+
install-develop:
31+
python setup.py develop
732

8-
docker-test-all:
9-
$(DOCKER_RUN_ARGS)
33+
pre-pr: install-requirements flake8 isort test-api
1034

11-
docker-test-unit:
12-
$(DOCKER_RUN_ARGS) bash -c "pytest -v --fast tests/ --ignore=tests/e2e/"
35+
generate-code-examples: install-develop
36+
python tools/generate_code_examples.py ./generated_code_examples
37+
38+
download-codecov:
39+
wget -q https://uploader.codecov.io/latest/linux/codecov -O codecov && \
40+
chmod +x codecov
41+
42+
run-codecov: download-codecov
43+
./codecov -f coverage.xml -Z
44+
45+
docker-build:
46+
docker build -t $(DOCKER_IMAGE) .
1347

1448
docker-generate-examples:
15-
$(DOCKER_RUN_ARGS) bash -c "python setup.py develop && python tools/generate_code_examples.py generated_code_examples"
49+
$(DOCKER_RUN_ARGS) make generate-code-examples
1650

1751
docker-lint:
18-
$(DOCKER_RUN_ARGS) bash -c "flake8 . && isort . --check-only"
52+
$(DOCKER_RUN_ARGS) make flake8 isort-check
53+
54+
docker-test-api:
55+
$(DOCKER_RUN_ARGS) make test-api
56+
57+
docker-pre-pr:
58+
$(DOCKER_RUN_ARGS) make pre-pr
1959

2060
docker-shell:
2161
$(DOCKER_RUN_ARGS) bash
22-
23-
docker-pre-pr: docker-lint docker-test-all

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
**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).
1111

1212
* [Installation](#installation)
13+
* [Development](#development)
1314
* [Supported Languages](#supported-languages)
1415
* [Supported Models](#supported-models)
1516
* [Classification Output](#classification-output)
@@ -23,6 +24,15 @@ Supported Python version is >= **3.7**.
2324
pip install m2cgen
2425
```
2526

27+
## Development
28+
Make sure the following command runs successfully before submitting a PR:
29+
```
30+
make pre-pr
31+
```
32+
Alternatively you can run the Docker version of the same command:
33+
```
34+
make docker-build docker-pre-pr
35+
```
2636

2737
## Supported Languages
2838

m2cgen/VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.1
1+
0.10.1

requirements-test.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# Other stuff
2+
numpy==1.23.3; python_version > "3.7"
3+
numpy==1.21.5; python_version <= "3.7"
4+
scipy==1.9.1; python_version > "3.7"
5+
scipy==1.7.3; python_version <= "3.7"
6+
7+
# Cython
8+
Cython==0.29.32; sys_platform == 'darwin' and platform_machine == 'arm64'
9+
110
# Supported models
211
scikit-learn==1.0.2
312
xgboost==1.6.2
@@ -13,8 +22,5 @@ pytest-mock==3.8.2
1322
pytest-cov==3.0.0
1423
py-mini-racer==0.6.0
1524

16-
# Other stuff
17-
numpy==1.23.3; python_version > "3.7"
18-
numpy==1.21.5; python_version <= "3.7"
19-
scipy==1.9.1; python_version > "3.7"
20-
scipy==1.7.3; python_version <= "3.7"
25+
# Publishing
26+
twine

0 commit comments

Comments
 (0)