Skip to content

Commit

Permalink
Adding clean-notebooks pre-commit (#357)
Browse files Browse the repository at this point in the history
* add pre commit yaml

* fix precommit

* checking precommit

* try to avoid cleaning empty cells

* ignore empty cells

* add pre-commit job to docs CI

* pre-commit changes to clean nbs

* add newline

Co-authored-by: Simon Høxbro Hansen <simon.hansen@me.com>

* stop doc build if pre-commit fails

Co-authored-by: Simon Høxbro Hansen <simon.hansen@me.com>

* remove empty attachments key

Co-authored-by: Simon Høxbro Hansen <simon.hansen@me.com>

* Update .pre-commit-config.yaml

* Add empty line

---------

Co-authored-by: Simon Høxbro Hansen <simon.hansen@me.com>
  • Loading branch information
droumis and hoxbro committed Mar 13, 2023
1 parent 6715faa commit 4b7b9e2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 35 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/docs.yaml
Expand Up @@ -22,8 +22,24 @@ on:
- cron: '0 2 1 */2 SUN' # every two months on Sunday at 2 am

jobs:
pre_commit:
name: Run pre-commit hooks
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: "1"
- name: set PY
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: pre-commit
uses: pre-commit/action@v3.0.0
build_docs:
name: Documentation
needs: [pre_commit]
runs-on: 'ubuntu-latest'
timeout-minutes: 120
defaults:
Expand Down
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,11 @@

# This is the configuration for pre-commit, a local framework for managing pre-commit hooks
# Check out the docs at: https://pre-commit.com/

default_stages: [commit]
repos:
- repo: https://github.com/hoxbro/clean_notebook
rev: v0.1.8
hooks:
- id: clean-notebook
args: [-i, slideshow, --keep-empty] # ignore RISE slideshow metadata and keep empty cells
22 changes: 1 addition & 21 deletions examples/talks/Overview.ipynb
Expand Up @@ -784,29 +784,9 @@
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"state": {},
"version_major": 2,
"version_minor": 0
}
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
Expand Down
15 changes: 1 addition & 14 deletions examples/tutorial/01_Overview.ipynb
Expand Up @@ -160,22 +160,9 @@
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 4b7b9e2

Please sign in to comment.