File tree Expand file tree Collapse file tree 7 files changed +48
-24
lines changed Expand file tree Collapse file tree 7 files changed +48
-24
lines changed Original file line number Diff line number Diff line change 3535 uses : actions/setup-python@v2
3636 with :
3737 python-version : ${{ matrix.python-version }}
38+ - name : Pre-commit Checks
39+ run : |
40+ pip -q install pre-commit
41+ pre-commit run --all-files
3842 - name : Start from clean state
3943 run : make clean
4044 - name : Run tests
Original file line number Diff line number Diff line change 22* .swp
33.DS_Store
44.idea /
5+ .venv-pre-commit /
56__pycache__
67build /
78case_utils.egg-info /
Original file line number Diff line number Diff line change 1+ repos :
2+ - repo : https://github.com/psf/black
3+ rev : 22.3.0
4+ hooks :
5+ - id : black
Original file line number Diff line number Diff line change @@ -33,3 +33,14 @@ make check
3333git commit -m " Build CASE 0.6.0 monolithic .ttl files" case_utils/ontology/case-0.6.0-subclasses.ttl case_utils/ontology/case-0.6.0.ttl
3434git commit -m " Update CASE ontology pointer to version 0.6.0" dependencies/CASE case_utils/ontology/version_info.py
3535```
36+
37+ This project uses [ the ` pre-commit ` tool] ( https://pre-commit.com/ ) for linting The easiest way to install it is with ` pip ` :
38+ ``` bash
39+ pip install pre-commit
40+ pre-commit --version
41+ ```
42+
43+ The ` pre-commit ` tool hooks into Git's commit machinery to run a set of linters and static analyzers over each change. To install ` pre-commit ` into Git's hooks, run:
44+ ``` bash
45+ pre-commit install
46+ ```
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ $(error Unable to determine CASE version)
2121endif
2222
2323all : \
24- .ontology.done.log
24+ .ontology.done.log \
25+ .venv-pre-commit/var/.pre-commit-built.log
2526
2627.PHONY : \
2728 download
@@ -54,8 +55,32 @@ all: \
5455 test -r case_utils/ontology/case-$(case_version)-subclasses.ttl
5556 touch $@
5657
58+ # This virtual environment is meant to be built once and then persist, even through 'make clean'.
59+ # If a recipe is written to remove this flag file, it should first run `pre-commit uninstall`.
60+ .venv-pre-commit/var/.pre-commit-built.log :
61+ rm -rf .venv-pre-commit
62+ test -r .pre-commit-config.yaml \
63+ || (echo " ERROR:Makefile:pre-commit is expected to install for this repository, but .pre-commit-config.yaml does not seem to exist." >&2 ; exit 1)
64+ $(PYTHON3 ) -m venv \
65+ .venv-pre-commit
66+ source .venv-pre-commit/bin/activate \
67+ && pip install \
68+ --upgrade \
69+ pip \
70+ setuptools \
71+ wheel
72+ source .venv-pre-commit/bin/activate \
73+ && pip install \
74+ pre-commit
75+ source .venv-pre-commit/bin/activate \
76+ && pre-commit install
77+ mkdir -p \
78+ .venv-pre-commit/var
79+ touch $@
80+
5781check : \
58- .ontology.done.log
82+ .ontology.done.log \
83+ .venv-pre-commit/var/.pre-commit-built.log
5984 $(MAKE) \
6085 PYTHON3=$(PYTHON3) \
6186 --directory tests \
Original file line number Diff line number Diff line change @@ -67,17 +67,6 @@ check: \
6767 --ignore case_utils \
6868 --log-level=DEBUG
6969
70- # TODO - Need to settle on policy for incorporating this and 'format' recipe into CI.
71- # https://case.atlassian.net/browse/AC-215
72- # https://case.atlassian.net/browse/AC-216
73- check-black : \
74- .venv.done.log
75- source venv/bin/activate \
76- && black \
77- --check \
78- $(top_srcdir)/case_utils \
79- $$PWD
80-
8170check-case_utils : \
8271 .venv.done.log
8372 $(MAKE) \
@@ -114,13 +103,3 @@ clean:
114103
115104download : \
116105 .venv.done.log
117-
118- # TODO - Need to settle on policy for incorporating this and 'check-black' recipe into CI.
119- # https://case.atlassian.net/browse/AC-215
120- # https://case.atlassian.net/browse/AC-216
121- format : \
122- .venv.done.log
123- source venv/bin/activate \
124- && black \
125- $(top_srcdir)/case_utils \
126- $$PWD
Original file line number Diff line number Diff line change 11PyLD
2- black
32mypy
43pytest
54python-dateutil
You can’t perform that action at this time.
0 commit comments