Skip to content

Commit 1ba842f

Browse files
authored
Add pre-commit hook (voila-dashboards#1306)
* Add pre-commit * Format all files * Update dev dependencies * Update prettier * Add CI Action * Copy config from jupyterlab * Format code * Remove .flake8 * Run check on CI
1 parent c60b6c0 commit 1ba842f

File tree

110 files changed

+1799
-1484
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+1799
-1484
lines changed

.binder/postBuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ jlpm && jlpm run build
66
python -m pip install -e .
77
jupyter labextension develop . --overwrite
88
jupyter server extension enable voila.server_extension --sys-prefix
9-
jupyter serverextension enable voila.server_extension --sys-prefix
9+
jupyter serverextension enable voila.server_extension --sys-prefix

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
lint-staged.config.js
21
.eslintrc.js
32

43
node_modules

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ module.exports = {
1111
'eslint:recommended',
1212
'plugin:@typescript-eslint/eslint-recommended',
1313
'plugin:@typescript-eslint/recommended',
14-
'plugin:prettier/recommended',
1514
'plugin:react/recommended',
1615
'plugin:jest/recommended'
1716
],

.flake8

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/benchmark-report.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Commenting on a PR requires write access
22
# This script is taken from jupyterlab project.
33

4-
54
name: Comment on the pull request
65

76
on:
@@ -41,7 +40,6 @@ jobs:
4140
var fs = require('fs');
4241
fs.writeFileSync('${{github.workspace}}/benchmark-assets.zip', Buffer.from(download.data));
4342
- run: unzip benchmark-assets.zip
44-
4543
- name: 'Comment on PR'
4644
uses: actions/github-script@v3
4745
with:

.github/workflows/binder-on-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ jobs:
1212
- uses: jupyterlab/maintainer-tools/.github/actions/binder-link@v1
1313
with:
1414
github_token: ${{ secrets.github_token }}
15-
url_path: voila/tree
15+
url_path: voila/tree

.github/workflows/build.yml

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,43 @@ name: Build Frontend Packages
33
on:
44
push:
55
branches:
6-
- '*'
6+
- '*'
77
pull_request:
88
branches:
9-
- '*'
9+
- '*'
1010
schedule:
11-
- cron: "0 2 * * 1-5" # run on weekdays at 2:00am UTC
11+
- cron: '0 2 * * 1-5' # run on weekdays at 2:00am UTC
1212

1313
jobs:
1414
build:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v2
19-
20-
- name: Base Setup
21-
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
22-
23-
- name: Install Dependencies
24-
run: |
25-
python -m pip install -U jupyterlab~=3.0 jupyter_packaging~=0.10
26-
27-
- name: Install the Voilà Preview JupyterLab extension
28-
run: |
29-
python -m pip install .
30-
31-
- name: Check the extensions are installed
32-
run: |
33-
jupyter nbextension list 2>&1 | grep -ie "voila/extension.*enabled" -
34-
jupyter labextension list 2>&1 | grep -ie "@voila-dashboards/jupyterlab-preview.*enabled.*ok" -
35-
jupyter server extension list 2>&1 | grep -ie "voila\.server_extension.*enabled" -
36-
37-
- name: Browser check
38-
run: |
39-
python -m jupyterlab.browser_check
40-
41-
- name: Lint
42-
run: |
43-
jlpm
44-
jlpm run eslint:check
45-
jlpm run prettier:check
17+
- name: Checkout
18+
uses: actions/checkout@v2
19+
20+
- name: Base Setup
21+
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
22+
23+
- name: Install Dependencies
24+
run: |
25+
python -m pip install -U jupyterlab~=3.0 jupyter_packaging~=0.10
26+
27+
- name: Install the Voilà Preview JupyterLab extension
28+
run: |
29+
python -m pip install .
30+
31+
- name: Check the extensions are installed
32+
run: |
33+
jupyter nbextension list 2>&1 | grep -ie "voila/extension.*enabled" -
34+
jupyter labextension list 2>&1 | grep -ie "@voila-dashboards/jupyterlab-preview.*enabled.*ok" -
35+
jupyter server extension list 2>&1 | grep -ie "voila\.server_extension.*enabled" -
36+
37+
- name: Browser check
38+
run: |
39+
python -m jupyterlab.browser_check
40+
41+
- name: Lint
42+
run: |
43+
jlpm
44+
jlpm run eslint:check
45+
jlpm run prettier:check

.github/workflows/main.yml

Lines changed: 72 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ name: Tests
33
on:
44
push:
55
branches:
6-
- '*'
6+
- '*'
77
pull_request:
88
branches:
9-
- '*'
9+
- '*'
1010
schedule:
11-
- cron: "0 2 * * 1-5" # run on weekdays at 2:00am UTC
11+
- cron: '0 2 * * 1-5' # run on weekdays at 2:00am UTC
1212

1313
jobs:
1414
test-linux:
15-
1615
runs-on: ${{ matrix.os }}
1716

1817
strategy:
@@ -22,47 +21,45 @@ jobs:
2221
python_version: ['3.7', '3.8', '3.9', '3.10']
2322

2423
steps:
25-
- uses: actions/checkout@v2
26-
27-
- name: Setup mamba
28-
uses: conda-incubator/setup-miniconda@v2
29-
with:
30-
miniforge-variant: Mambaforge
31-
channels: conda-forge
32-
33-
- name: Create the conda environment
34-
shell: bash -l {0}
35-
run: mamba install -q python=${{ matrix.python_version }} pip jupyterlab_pygments==0.1.0 pytest-cov pytest-rerunfailures nodejs yarn=1 flake8 ipywidgets matplotlib xeus-cling openssl=1.1.1l "traitlets>=5.0.3,<6"
36-
37-
- name: Install dependencies
38-
shell: bash -l {0}
39-
run: |
40-
whereis python
41-
python --version
42-
yarn install --network-timeout 100000
43-
python -m pip install ".[test]"
44-
(cd tests/test_template; pip install .)
45-
(cd tests/skip_template; pip install .)
46-
47-
- name: Run tests
48-
shell: bash -l {0}
49-
run: |
50-
VOILA_TEST_XEUS_CLING=1 py.test tests/ --async-test-timeout=240 --reruns 2 --reruns-delay 1
51-
voila --help # Making sure we can run `voila --help`
52-
# tests if voila sends a 'heartbeat' to avoid proxies from closing an apparently stale connection
53-
# Note that wget is the only easily available software that has a read-timeout
54-
voila tests/notebooks/sleep10seconds.ipynb --port=8878 --VoilaConfiguration.http_keep_alive_timeout=2 &
55-
sleep 2
56-
wget --read-timeout=5 --tries=1 http://localhost:8878
57-
58-
- name: Flake8
59-
shell: bash -l {0}
60-
run: |
61-
python -m flake8 voila tests setup.py
24+
- uses: actions/checkout@v2
6225

26+
- name: Setup mamba
27+
uses: conda-incubator/setup-miniconda@v2
28+
with:
29+
miniforge-variant: Mambaforge
30+
channels: conda-forge
6331

64-
test-osx:
32+
- name: Create the conda environment
33+
shell: bash -l {0}
34+
run: mamba install -q python=${{ matrix.python_version }} pip jupyterlab_pygments==0.1.0 pytest-cov pytest-rerunfailures nodejs yarn=1 ipywidgets matplotlib xeus-cling openssl=1.1.1l "traitlets>=5.0.3,<6"
6535

36+
- name: Install dependencies
37+
shell: bash -l {0}
38+
run: |
39+
whereis python
40+
python --version
41+
yarn install --network-timeout 100000
42+
python -m pip install ".[test,dev]"
43+
(cd tests/test_template; pip install .)
44+
(cd tests/skip_template; pip install .)
45+
46+
- name: Lint check
47+
shell: bash -l {0}
48+
run: |
49+
pre-commit run --all-files --show-diff-on-failure
50+
51+
- name: Run tests
52+
shell: bash -l {0}
53+
run: |
54+
VOILA_TEST_XEUS_CLING=1 py.test tests/ --async-test-timeout=240 --reruns 2 --reruns-delay 1
55+
voila --help # Making sure we can run `voila --help`
56+
# tests if voila sends a 'heartbeat' to avoid proxies from closing an apparently stale connection
57+
# Note that wget is the only easily available software that has a read-timeout
58+
voila tests/notebooks/sleep10seconds.ipynb --port=8878 --VoilaConfiguration.http_keep_alive_timeout=2 &
59+
sleep 2
60+
wget --read-timeout=5 --tries=1 http://localhost:8878
61+
62+
test-osx:
6663
runs-on: ${{ matrix.os }}
6764

6865
strategy:
@@ -72,41 +69,40 @@ jobs:
7269
python_version: ['3.7', '3.8', '3.9', '3.10']
7370

7471
steps:
75-
- uses: actions/checkout@v2
76-
77-
- name: Setup mamba
78-
uses: conda-incubator/setup-miniconda@v2
79-
with:
80-
miniforge-variant: Mambaforge
81-
channels: conda-forge
82-
83-
- name: Create the conda environment
84-
shell: bash -l {0}
85-
run: mamba install -q python=${{ matrix.python_version }} pip jupyterlab_pygments==0.1.0 pytest-cov pytest-rerunfailures nodejs yarn=1 flake8 ipywidgets matplotlib xeus-cling openssl=1.1.1l "traitlets>=5.0.3,<6"
86-
87-
- name: Install dependencies
88-
shell: bash -l {0}
89-
run: |
90-
whereis python
91-
python --version
92-
yarn install --network-timeout 100000
93-
python -m pip install ".[test]"
94-
(cd tests/test_template; pip install .)
95-
(cd tests/skip_template; pip install .)
96-
97-
- name: Run tests
98-
shell: bash -l {0}
99-
run: |
100-
py.test tests/ --async-test-timeout=240 --reruns 2 --reruns-delay 1
101-
voila --help # Making sure we can run `voila --help`
102-
# tests if voila sends a 'heartbeat' to avoid proxies from closing an apparently stale connection
103-
# Note that wget is the only easily available software that has a read-timeout
104-
voila tests/notebooks/sleep10seconds.ipynb --port=8878 --VoilaConfiguration.http_keep_alive_timeout=2 &
105-
sleep 2
106-
wget --read-timeout=5 --tries=1 http://localhost:8878
72+
- uses: actions/checkout@v2
10773

108-
test-win:
74+
- name: Setup mamba
75+
uses: conda-incubator/setup-miniconda@v2
76+
with:
77+
miniforge-variant: Mambaforge
78+
channels: conda-forge
79+
80+
- name: Create the conda environment
81+
shell: bash -l {0}
82+
run: mamba install -q python=${{ matrix.python_version }} pip jupyterlab_pygments==0.1.0 pytest-cov pytest-rerunfailures nodejs yarn=1 ipywidgets matplotlib xeus-cling openssl=1.1.1l "traitlets>=5.0.3,<6"
10983

84+
- name: Install dependencies
85+
shell: bash -l {0}
86+
run: |
87+
whereis python
88+
python --version
89+
yarn install --network-timeout 100000
90+
python -m pip install ".[test]"
91+
(cd tests/test_template; pip install .)
92+
(cd tests/skip_template; pip install .)
93+
94+
- name: Run tests
95+
shell: bash -l {0}
96+
run: |
97+
py.test tests/ --async-test-timeout=240 --reruns 2 --reruns-delay 1
98+
voila --help # Making sure we can run `voila --help`
99+
# tests if voila sends a 'heartbeat' to avoid proxies from closing an apparently stale connection
100+
# Note that wget is the only easily available software that has a read-timeout
101+
voila tests/notebooks/sleep10seconds.ipynb --port=8878 --VoilaConfiguration.http_keep_alive_timeout=2 &
102+
sleep 2
103+
wget --read-timeout=5 --tries=1 http://localhost:8878
104+
105+
test-win:
110106
runs-on: ${{ matrix.os }}
111107

112108
strategy:
@@ -128,7 +124,7 @@ jobs:
128124

129125
- name: Install dependencies
130126
run: |
131-
python -m pip install jupyterlab_pygments==0.1.0 pytest-cov pytest-rereunfailures flake8 ipywidgets matplotlib traitlets
127+
python -m pip install jupyterlab_pygments==0.1.0 pytest-cov pytest-rereunfailures ipywidgets matplotlib traitlets
132128
yarn install --network-timeout 100000
133129
python -m pip install ".[test]"
134130
cd tests/test_template

.github/workflows/packaging.yml

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name: Packaging
33
on:
44
push:
55
branches:
6-
- '*'
6+
- '*'
77
pull_request:
88
branches:
9-
- '*'
9+
- '*'
1010

1111
env:
1212
PIP_DISABLE_PIP_VERSION_CHECK: 1
@@ -19,37 +19,37 @@ jobs:
1919
build:
2020
runs-on: ubuntu-latest
2121
steps:
22-
- name: Checkout
23-
uses: actions/checkout@v2
24-
25-
- name: Base Setup
26-
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
22+
- name: Checkout
23+
uses: actions/checkout@v2
2724

28-
- name: Install dependencies
29-
run: |
30-
python -m pip install setuptools jupyter_packaging~=0.10 "jupyterlab>=3,<4" build
25+
- name: Base Setup
26+
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
3127

32-
- name: Build pypi distributions
33-
run: |
34-
python -m build
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install setuptools jupyter_packaging~=0.10 "jupyterlab>=3,<4" build
3531
36-
- name: Build npm distributions
37-
run: |
38-
pushd packages/jupyterlab-preview
39-
npm pack
40-
popd
41-
cp packages/*/*.tgz dist
32+
- name: Build pypi distributions
33+
run: |
34+
python -m build
4235
43-
- name: Build checksum file
44-
run: |
45-
cd dist
46-
sha256sum * | tee SHA256SUMS
36+
- name: Build npm distributions
37+
run: |
38+
pushd packages/jupyterlab-preview
39+
npm pack
40+
popd
41+
cp packages/*/*.tgz dist
4742
48-
- name: Upload distributions
49-
uses: actions/upload-artifact@v2
50-
with:
51-
name: dist ${{ github.run_number }}
52-
path: ./dist
43+
- name: Build checksum file
44+
run: |
45+
cd dist
46+
sha256sum * | tee SHA256SUMS
47+
48+
- name: Upload distributions
49+
uses: actions/upload-artifact@v2
50+
with:
51+
name: dist ${{ github.run_number }}
52+
path: ./dist
5353

5454
install:
5555
runs-on: ${{ matrix.os }}-latest

0 commit comments

Comments
 (0)