Skip to content

Commit af3be06

Browse files
committed
add pytest opts and pre-commit
1 parent 7f598dd commit af3be06

File tree

4 files changed

+65
-6
lines changed

4 files changed

+65
-6
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,30 @@ defaults:
1414
shell: bash
1515

1616
jobs:
17+
# Run "pre-commit run --all-files"
18+
pre-commit:
19+
runs-on: ubuntu-20.04
20+
timeout-minutes: 2
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
- uses: actions/setup-python@v2
25+
with:
26+
python-version: 3.8
27+
28+
# ref: https://github.com/pre-commit/action
29+
- uses: pre-commit/[email protected]
30+
- name: Help message if pre-commit fail
31+
if: ${{ failure() }}
32+
run: |
33+
echo "You can install pre-commit hooks to automatically run formatting"
34+
echo "on each commit with:"
35+
echo " pre-commit install"
36+
echo "or you can run by hand on staged files with"
37+
echo " pre-commit run"
38+
echo "or after-the-fact on already committed files with"
39+
echo " pre-commit run --all-files"
40+
1741
build:
1842
runs-on: ${{ matrix.os }}
1943
strategy:
@@ -63,14 +87,14 @@ jobs:
6387
timeout-minutes: 15
6488
if: ${{ !startsWith( matrix.python-version, 'pypy' ) && !startsWith(matrix.os, 'windows') }}
6589
run: |
66-
cmd="python -m pytest -vv -raXs --cov ipykernel --cov-branch --cov-report term-missing:skip-covered --durations 10 --color=yes"
90+
cmd="python -m pytest -vv --cov ipykernel --cov-branch --cov-report term-missing:skip-covered"
6791
$cmd || $cmd --lf
6892
6993
- name: Run the tests on pypy and windows
7094
timeout-minutes: 15
7195
if: ${{ startsWith( matrix.python-version, 'pypy' ) || startsWith(matrix.os, 'windows') }}
7296
run: |
73-
cmd="python -m pytest -vv -raXs --durations 10 --color=yes"
97+
cmd="python -m pytest -vv"
7498
$cmd || $cmd --lf
7599
76100
- name: Coverage
@@ -135,7 +159,7 @@ jobs:
135159
- name: Run the tests
136160
timeout-minutes: 10
137161
run: |
138-
cmd="python -m pytest -vv -raXxs --durations 10 --color=yes"
162+
cmd="python -m pytest -vv -raXxs"
139163
$cmd || $cmd --lf
140164
141165
test_miniumum_versions:
@@ -152,7 +176,7 @@ jobs:
152176
uses: jupyterlab/maintainer-tools/.github/actions/install-minimums@v1
153177
- name: Run the unit tests
154178
run: |
155-
cmd="python -m pytest -vv -raXxs --durations 10 --color=yes"
179+
cmd="python -m pytest -vv -raXxs"
156180
$cmd || $cmd --lf
157181
158182
test_prereleases:
@@ -173,7 +197,7 @@ jobs:
173197
pip check
174198
- name: Run the tests
175199
run: |
176-
cmd="python -m pytest -vv -raXs --durations 10 --color=yes"
200+
cmd="python -m pytest -vv"
177201
$cmd || $cmd --lf
178202
179203
make_sdist:
@@ -214,5 +238,5 @@ jobs:
214238
- name: Run Test
215239
run: |
216240
cd sdist/test
217-
cmd="python -m pytest -vv -raXs --durations 10 --color=yes"
241+
cmd="python -m pytest -vv"
218242
$cmd || $cmd --lf

CONTRIBUTING.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,31 @@ cd ipykernel
1717
pip install -e .
1818
```
1919

20+
## Code Styling
21+
`ipykernel` has adopted automatic code formatting so you shouldn't
22+
need to worry too much about your code style.
23+
As long as your code is valid,
24+
the pre-commit hook should take care of how it should look.
25+
To install `pre-commit`, run the following::
26+
27+
pip install pre-commit
28+
pre-commit install
29+
30+
31+
You can invoke the pre-commit hook by hand at any time with::
32+
33+
pre-commit run
34+
35+
which should run any autoformatting on your code
36+
and tell you about any errors it couldn't fix automatically.
37+
You may also install [black integration](https://github.com/psf/black#editor-integration)
38+
into your text editor to format code automatically.
39+
40+
If you have already committed files before setting up the pre-commit
41+
hook with ``pre-commit install``, you can fix everything up using
42+
``pre-commit run --all-files``. You need to make the fixing commit
43+
yourself after that.
44+
2045
## Releasing ipykernel
2146

2247
Releasing ipykernel is *almost* standard for a Python package:

pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,12 @@ tag_template = "v{new_version}"
2828

2929
[[tool.tbump.file]]
3030
src = "ipykernel/_version.py"
31+
32+
[tool.pytest.ini_options]
33+
addopts = "-raXs --durations 10 --color=yes --doctest-modules"
34+
testpaths = [
35+
"tests/"
36+
]
37+
timeout = 300
38+
# Restore this setting to debug failures
39+
# timeout_method = "thread"

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def run(self):
7777
"pytest-cov",
7878
"flaky",
7979
"ipyparallel",
80+
"pre-commit"
8081
],
8182
},
8283
classifiers=[

0 commit comments

Comments
 (0)