Skip to content

Commit f3a35f3

Browse files
Jaspermr-c
andauthored
many enhancements to the contributing guide, some cleanups for the Makefile
including a new target: `make cleanup` Co-authored-by: Michael R. Crusoe <[email protected]>
1 parent ceb38d9 commit f3a35f3

File tree

2 files changed

+78
-39
lines changed

2 files changed

+78
-39
lines changed

CONTRIBUTING.md

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,68 @@
11
Style guide:
2-
- PEP-8
3-
- Python 3.7+ compatible code
2+
- PEP-8 (as implemented by the `black` code formatting tool)
3+
- Python 3.6+ compatible code
44
- PEP-484 type hints
5-
- Vertically align the type hints in function definitions
65

7-
The development is done using ``git``, we encourage you to get familiar with it.
6+
The development is done using `git`, we encourage you to get familiar with it.
87
Here's a rough guide (improvements are welcome!)
98
To get the code and start working on the changes you can start a console and:
10-
- Clone the cwltool: ``git clone https://github.com/common-workflow-language/cwltool.git``
11-
- Switch to cwltool directory: ``cd cwltool``
9+
- Clone the cwltool: `git clone https://github.com/common-workflow-language/cwltool.git`
10+
- Switch to cwltool directory: `cd cwltool`
1211

13-
In order to contribute to the development of ``cwltool``, the source code needs to pass the test before your changes are accepted.
14-
There are a couple ways to test the code with your changes: let `tox` manage installation and test running in virtual environments, or do it manually (preferably in a virtual environment):
15-
- Install ``tox`` preferably using the OS' package manager, otherwise it can be installed with ``pip install --user -U tox``
12+
In order to contribute to the development of `cwltool`, the source code needs to
13+
pass the test before your changes are accepted. There are a couple ways to test
14+
the code with your changes: let `tox` manage installation and test running in
15+
virtual environments, or do it manually (preferably in a virtual environment):
16+
- Install `tox` preferably using the OS' package manager, otherwise it can be
17+
installed with `pip install --user -U tox`
1618
- Make your changes to the code and add tests for new cool things you're adding!
17-
- Run the tests with the command ``tox``, it's recommended to use some parameters as tox will try to run all the checks in all available python interpreters.
18-
- The important tests to run are ``unit tests`` and ``type tests``.
19-
To run these two in Python 3.7, we can tell tox to run only those tests by running: ``tox -e py37-unit,py37-mypy2,py37-mypy3``.
20-
- Run ``tox -l`` to see all available tests and runtimes
19+
- Run the tests with the command `tox`, it's recommended to use some parameters
20+
as tox will try to run all the checks in all available python interpreters.
21+
- The important tests to run are "unit tests" and "type tests".
22+
To run these two in Python 3.7 (for example), we can tell tox to run only those
23+
tests by running: `tox -e py37-mypy`. (the `mypy` tox target also runs the
24+
unit tests; to just run the type checker use `make mypy` as shown below)
25+
- Run `tox -l` to see all available tests and runtimes
2126

2227
For the more traditional workflow:
23-
- Create a virtual environment: ``python3 -m venv cwltool``
24-
- To begin using the virtual environment, it needs to be activated: ``source bin/activate``
25-
- To check if you have the virtual environment set up: ``which python`` and it should point to python executable in your virtualenv
26-
- Install cwltool: ``pip install -e .``
27-
- Check the version which might be different from the version installed in general on any system: ``cwltool --version``
28+
- Create a virtual environment: `python3 -m venv cwltool`
29+
(if you have multiple version of Python installed, then you can replace `python3`
30+
in this command with the version you want to use, `python3.10` for example)
31+
- To begin using the virtual environment, it needs to be activated: `source venv/bin/activate`
32+
- To check if you have the virtual environment set up: `which python`
33+
and it should point to python executable in your virtualenv
34+
- Install cwltool in development mode, along with development tools:
35+
`make install-dep dev`
36+
- Check the `cwltool` version which might be different from the version installed in
37+
general on your system: `cwltool --version`
2838
- Make your changes to the code and add tests for new cool things you're adding!
29-
- Run the unit-tests to see : ``python setup.py test``
30-
- After you're done working on ``cwltool``, you can deactivate the virtual environment: ``deactivate``
39+
- Run the unit-tests to see : `make test`
40+
- After you're done working on `cwltool`, you can deactivate the virtual
41+
environment: `deactivate`
3142

32-
When tests are passing, you can simply commit and create a PR on ``cwltool`` repo
43+
Before you commit your code (or at least before you push to GitHub) it is
44+
recommended to run `make cleanup`
45+
(which is a shortcut for `make sort_imports format flake8 diff_pydocstyle_report`)
46+
to fix common issues and point out any remaining code formatting issues
47+
that cannot be fixed automatically.
48+
49+
When tests are passing, you can create git commits in a new branch and push to
50+
GitHub to make a pull request on `cwltool` repo
51+
52+
Useful `make` commands:
53+
The `make` commands below can help you to install the dependencies, format and test your code
54+
55+
- `make help` to show the list of commands that can be used with the make function
56+
- `make install-dep` will install the dependencies needed by `cwltool`
57+
- `make format` will clean up your code according to the accepted python standard
58+
- `make test` will perform the tests of `cwltool` (can take a while to run all tests)
59+
- `make sort_imports` will clean up and sort your import statements
60+
- `make remove_unused_imports` will remove any unneeded `import` statements
61+
- `make flake8` will catch format issues that `make format` cannot fix automatically
62+
- `make diff_pydocstyle_report` check Python docstring style for changed files only
63+
- `make diff-cover` to run the tests and point out which lines of code that have been
64+
changed as compared to the `main` branch are missing test coverage. This is also calculated
65+
automatically after all the automatic tests run when you open a Pull Request on GitHub;
66+
running it locally can help you confirm that any changes or additions
67+
to the tests are sufficient before pushing to GitHub.
68+
- `make cleanup` is a shortcut for `make sort_imports format flake8 diff_pydocstyle_report`

Makefile

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ VERSION=3.1.$(shell TZ=UTC git log --first-parent --max-count=1 \
3636
mkfile_dir := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
3737
UNAME_S=$(shell uname -s)
3838

39-
## all : default task
39+
## all : default task (install cwltool in dev mode)
4040
all: dev
4141

42-
## help : print this help message and exit
42+
## help : print this help message and exit
4343
help: Makefile
4444
@sed -n 's/^##//p' $<
4545

46-
## install-dep : install most of the development dependencies via pip
46+
## cleanup : shortcut for "make sort_imports format flake8 diff_pydocstyle_report"
47+
cleanup: sort_imports format flake8 diff_pydocstyle_report
48+
49+
## install-dep : install most of the development dependencies via pip
4750
install-dep: install-dependencies
4851

4952
install-dependencies: FORCE
@@ -53,20 +56,20 @@ install-dependencies: FORCE
5356
install-doc-dep:
5457
pip install -r docs/requirements.txt
5558

56-
## install-deb-dep: install most of the dev dependencies via apt-get
59+
## install-deb-dep : install many of the dev dependencies via apt-get
5760
install-deb-dep:
5861
sudo apt-get install $(DEBDEVPKGS)
5962

60-
## install : install the ${MODULE} module and schema-salad-tool
63+
## install : install the cwltool module with the "deps" dependency (galaxy-tool-util)
6164
install: FORCE
6265
pip install .[deps]
6366

64-
## dev : install the ${MODULE} module in dev mode
67+
## dev : install the cwltool module in dev mode
6568
dev: install-dep
6669
pip install -e .[deps]
6770

6871

69-
## dist : create a module package for distribution
72+
## dist : create a module package for distribution
7073
dist: dist/${MODULE}-$(VERSION).tar.gz
7174

7275
check-python3:
@@ -76,11 +79,11 @@ check-python3:
7679
dist/${MODULE}-$(VERSION).tar.gz: check-python3 $(SOURCES)
7780
python setup.py sdist bdist_wheel
7881

79-
## docs : make the docs
82+
## docs : make the docs
8083
docs: FORCE
8184
cd docs && $(MAKE) html
8285

83-
## clean : clean up all temporary / machine-generated files
86+
## clean : clean up all temporary / machine-generated files
8487
clean: check-python3 FORCE
8588
rm -f ${MODULE}/*.pyc tests/*.pyc *.so ${MODULE}/*.so
8689
rm -Rf ${MODULE}/__pycache__/
@@ -89,37 +92,37 @@ clean: check-python3 FORCE
8992
rm -f diff-cover.html
9093

9194
# Linting and code style related targets
92-
## sorting imports using isort: https://github.com/timothycrosley/isort
95+
## sort_import : sorting imports using isort: https://github.com/timothycrosley/isort
9396
sort_imports: $(PYSOURCES) mypy-stubs
9497
isort $^
9598

9699
remove_unused_imports: $(PYSOURCES)
97100
autoflake --in-place --remove-all-unused-imports $^
98101

99102
pep257: pydocstyle
100-
## pydocstyle : check Python docstring style
103+
## pydocstyle : check Python docstring style
101104
pydocstyle: $(PYSOURCES)
102105
pydocstyle --add-ignore=D100,D101,D102,D103 $^ || true
103106

104107
pydocstyle_report.txt: $(PYSOURCES)
105108
pydocstyle setup.py $^ > $@ 2>&1 || true
106109

107-
## diff_pydocstyle_report : check Python docstring style for changed files only
110+
## diff_pydocstyle_report : check Python docstring style for changed files only
108111
diff_pydocstyle_report: pydocstyle_report.txt
109112
diff-quality --compare-branch=main --violations=pydocstyle --fail-under=100 $^
110113

111-
## codespell : check for common mispellings
114+
## codespell : check for common mispellings
112115
codespell:
113116
codespell -w $(shell git ls-files | grep -v cwltool/schemas | grep -v cwltool/jshint/ | grep -v mypy-stubs)
114117

115-
## format : check/fix all code indentation and formatting (runs black)
118+
## format : check/fix all code indentation and formatting (runs black)
116119
format:
117120
black --exclude cwltool/schemas setup.py cwltool.py cwltool tests mypy-stubs
118121

119122
format-check:
120123
black --diff --check --exclude cwltool/schemas setup.py cwltool.py cwltool tests mypy-stubs
121124

122-
## pylint : run static code analysis on Python code
125+
## pylint : run static code analysis on Python code
123126
pylint: $(PYSOURCES)
124127
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
125128
$^ -j0|| true
@@ -154,18 +157,18 @@ diff-cover: coverage.xml
154157
diff-cover.html: coverage.xml
155158
diff-cover --compare-branch=main $^ --html-report $@
156159

157-
## test : run the ${MODULE} test suite
160+
## test : run the ${MODULE} test suite
158161
test: check-python3 $(PYSOURCES)
159162
python -m pytest -rs ${PYTEST_EXTRA}
160163

161-
## testcov : run the ${MODULE} test suite and collect coverage
164+
## testcov : run the ${MODULE} test suite and collect coverage
162165
testcov: check-python3 $(PYSOURCES)
163166
python -m pytest -rs --cov --cov-config=.coveragerc --cov-report= ${PYTEST_EXTRA}
164167

165168
sloccount.sc: $(PYSOURCES) Makefile
166169
sloccount --duplicates --wide --details $^ > $@
167170

168-
## sloccount : count lines of code
171+
## sloccount : count lines of code
169172
sloccount: $(PYSOURCES) Makefile
170173
sloccount $^
171174

0 commit comments

Comments
 (0)