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 35
35
uses : actions/setup-python@v2
36
36
with :
37
37
python-version : ${{ matrix.python-version }}
38
+ - name : Pre-commit Checks
39
+ run : |
40
+ pip -q install pre-commit
41
+ pre-commit run --all-files
38
42
- name : Start from clean state
39
43
run : make clean
40
44
- name : Run tests
Original file line number Diff line number Diff line change 2
2
* .swp
3
3
.DS_Store
4
4
.idea /
5
+ .venv-pre-commit /
5
6
__pycache__
6
7
build /
7
8
case_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
33
33
git 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
34
34
git commit -m " Update CASE ontology pointer to version 0.6.0" dependencies/CASE case_utils/ontology/version_info.py
35
35
```
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)
21
21
endif
22
22
23
23
all : \
24
- .ontology.done.log
24
+ .ontology.done.log \
25
+ .venv-pre-commit/var/.pre-commit-built.log
25
26
26
27
.PHONY : \
27
28
download
@@ -54,8 +55,32 @@ all: \
54
55
test -r case_utils/ontology/case-$(case_version)-subclasses.ttl
55
56
touch $@
56
57
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
+
57
81
check : \
58
- .ontology.done.log
82
+ .ontology.done.log \
83
+ .venv-pre-commit/var/.pre-commit-built.log
59
84
$(MAKE) \
60
85
PYTHON3=$(PYTHON3) \
61
86
--directory tests \
Original file line number Diff line number Diff line change @@ -67,17 +67,6 @@ check: \
67
67
--ignore case_utils \
68
68
--log-level=DEBUG
69
69
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
-
81
70
check-case_utils : \
82
71
.venv.done.log
83
72
$(MAKE) \
@@ -114,13 +103,3 @@ clean:
114
103
115
104
download : \
116
105
.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 1
1
PyLD
2
- black
3
2
mypy
4
3
pytest
5
4
python-dateutil
You can’t perform that action at this time.
0 commit comments