Skip to content

Commit

Permalink
fix: exit code and add some make commands + README
Browse files Browse the repository at this point in the history
  • Loading branch information
roch1990 committed Jun 6, 2020
1 parent a680a64 commit 6b5b86c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repos:
- commit
- push
# - repo: https://github.com/roch1990/peon
# rev: '0.15-rc'
# rev: '0.15-rc-3'
# hooks:
# - id: peon
# stages:
Expand Down
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
.PHONY: local-run
local-run:
pre-commit try-repo ./

.PHONY: tests
tests:
pre-commit run --all
coverage run -m pytest ./peon/tests --disable-warnings
coverage xml -o coverage-report.xml
mutmut --paths-to-mutate ./peon/src --tests-dir ./peon/tests run || true
Expand All @@ -8,3 +13,11 @@ tests:
.PHONY: cov-report
cov-report:
coverage xml -o coverage-report.xml

.PHONY: help
help:
@echo "You can run this helpfull commands:"
@echo
@echo -e "\tmake local-run try your changes in pre-commit environment"
@echo -e "\tmake tests start tests"
@echo -e "\tmake cov-report generate coverage-report at cobertura format"
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- [Introduction](#introduction)
- [What is that](#what-is-that)
- [What eo principles i can check](#what-eo-principles-i-can-check)
- [Python versions compability](#python-versions-compability)
- [Use-cases](#use-cases)
- [Shell](#from-shell)
- [Pre-commit hook](#add-linter-to-pre-commit-hooks)
Expand Down Expand Up @@ -187,7 +188,13 @@ You can start local test:
make tests
```

this instruction starts both tests - unit and mutual.
this instruction starts - unit, mutual and security tests.

Yuo can test pre-commit integration:

```bash
make local-run
```

Show results of mutual tests:

Expand Down
4 changes: 3 additions & 1 deletion peon/src/lint/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def project(self):
reports.append(principles.no_statements_in_test_methods_except_assert())
reports.append(principles.no_inheritance())

report_done = False
if reports:
for report in reports:
report.send()
report_done = report_done or report.send()
if report_done:
sys.exit(1)
10 changes: 6 additions & 4 deletions peon/src/lint/report/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ def send(self):
elif self.channel == ReportChannels.file:
self.to_file()

def to_stdout(self):
def to_stdout(self) -> bool:
if not self.text:
return
return False
print(self.text, file=sys.stdout)
return True

def to_file(self):
def to_file(self) -> bool:
if not self.text:
return
return False
with open(ReportChannels.file, 'w') as result:
result.write(self.text)
return True

0 comments on commit 6b5b86c

Please sign in to comment.