Skip to content

Commit

Permalink
Merge pull request #17 from ddelange/ci-cd
Browse files Browse the repository at this point in the history
Prepare for release
  • Loading branch information
cpcloud authored Oct 7, 2020
2 parents 4913b5b + 3580434 commit 7fac5ac
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 2,391 deletions.
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

33 changes: 33 additions & 0 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: CD

on:
release:
types: [created]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
pip install -U pip setuptools wheel
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel --universal
twine upload dist/*
36 changes: 36 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: CI
on:
pull_request:
push:
branches: master

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, 3.4, 3.5, 3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -U pip setuptools wheel
pip install pytest flake8 'mock ; python_version < "3"' -e .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- name: Test with pytest
run: |
pytest -s --strict -vv --cache-clear --maxfail=1
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ docs/_build/

# PyBuilder
target/

# setuptools_scm
autotime/_version.py
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include versioneer.py
include autotime/_version.py
global-exclude *
include autotime/*.py
include LICENSE
include README.md
24 changes: 10 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,31 @@ Time everything in IPython

## Installation:

```
```console
$ pip install ipython-autotime
```

## Examples

```python
In [1]: %load_ext autotime
time: 1433692.87 s
time: 295 µs

In [2]: x = 1
time: 730.99 us

In [3]: x + 2
Out[3]: 3
time: 2.50 ms
time: 519 µs

In [4]: x + ''
In [3]: x / 0
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-bde712cacec5> in <module>()
----> 1 x + ''
ZeroDivisionError Traceback (most recent call last)
<ipython-input-3-034eb0c6102b> in <module>
----> 1 x/0

TypeError: unsupported operand type(s) for +: 'int' and 'str'
time: 156.05 ms
ZeroDivisionError: division by zero
time: 79.7 ms
```

## Want to turn it off?

```python
In [5]: %unload_ext autotime
In [4]: %unload_ext autotime
```
19 changes: 9 additions & 10 deletions autotime/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import print_function

from ._version import version as __version__

try:
from time import monotonic
except ImportError:
Expand All @@ -9,7 +11,6 @@


class LineWatcher(object):

"""Class that implements a basic timer.
Notes
Expand All @@ -27,19 +28,17 @@ def stop(self):


timer = LineWatcher()
start = timer.start
stop = timer.stop


def load_ipython_extension(ip):
timer.start()
ip.events.register('pre_run_cell', timer.start)
ip.events.register('post_run_cell', timer.stop)
start()
ip.events.register('pre_run_cell', start)
ip.events.register('post_run_cell', stop)


def unload_ipython_extension(ip):
ip.events.unregister('pre_run_cell', timer.start)
ip.events.unregister('post_run_cell', timer.stop)

ip.events.unregister('pre_run_cell', start)
ip.events.unregister('post_run_cell', stop)

from ._version import get_versions
__version__ = get_versions()['version']
del get_versions
Loading

0 comments on commit 7fac5ac

Please sign in to comment.