Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support JupyterLab 4.0, port to Lumino 2 #673

Merged
merged 21 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 103 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ name: Test
on: [push, pull_request]

jobs:

docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.8
- uses: actions/cache@v1
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}-${{hashFiles('**/requirements.txt')}}
Expand All @@ -28,17 +29,18 @@ jobs:
run: |
cd docs
make html

js:
name: JavaScript
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.8
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}-${{hashFiles('**/requirements.txt')}}
Expand All @@ -47,18 +49,17 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install jupyterlab~=3.0
npm install -g codecov

- name: Use Node.js 18.x
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
- uses: actions/cache@v3
id: npm-cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
Expand All @@ -71,33 +72,35 @@ jobs:
python -m pip install --upgrade --upgrade-strategy=eager -e ".[test]"
npm test
codecov
env:
CI: true

python:
name: Python
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 4
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu-latest]
include:
- python-version: '3.11'
jupyter_server-version: '<2'
- python-version: '3.11'
jupyter_server-version: '>=2'
- python-version: '3.7'
- python-version: '3.8'
os: windows-latest
- python-version: '3.11'
os: windows-latest

outputs:
wheel: ${{ steps.packaging.outputs.wheel }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v1
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}-${{hashFiles('**/requirements.txt')}}
Expand Down Expand Up @@ -132,3 +135,88 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
directory: ${{ env.TEST_TMPDIR }}

- name: Build package
if: startsWith(matrix.os, 'ubuntu') && matrix.python-version == '3.10'
id: packaging
run: |
set -uex

pip install build
python -m build

WHEEL_NAME=$(ls dist/nbdime*.whl | cut -d '/' -f2)
echo "wheel=${WHEEL_NAME}" >> "$GITHUB_OUTPUT"

- name: Upload nbdime package
if: startsWith(matrix.os, 'ubuntu') && matrix.python-version == '3.10'
uses: actions/upload-artifact@v3
with:
name: nbdime-package
path: dist/nbdime*
if-no-files-found: error

ui-test:
needs: python
runs-on: ${{ matrix.os }}
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-22.04]

env:
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/pw-browsers

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install node
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Install Python '3.11'
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Download nbdime package
uses: actions/download-artifact@v3
with:
name: nbdime-package

- name: Install nbdime from wheel
run: |
python -m pip install "${{ needs.python.outputs.wheel }}"

- name: Install Playwright
working-directory: ui-tests
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run:
npm install

- name: Set up browser cache
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/pw-browsers
key: ${{ runner.os }}-${{ hashFiles('ui-tests/package-lock.json') }}

- name: Install browser
working-directory: ui-tests
run: npx playwright install chromium

- name: Run playwright tests
working-directory: ui-tests
run: |
npx playwright test

- name: Upload Playwright Test report
if: always()
uses: actions/upload-artifact@v3
with:
name: ui-tests-${{ matrix.os }}
path: |
ui-tests/playwright-report
70 changes: 70 additions & 0 deletions .github/workflows/update-integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Update Playwright Snapshots

on:
issue_comment:
types: [created, edited]

permissions:
contents: write
pull-requests: write

jobs:
update-snapshots:
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'please update playwright snapshots') }}
runs-on: ${{ matrix.os }}
concurrency: ci-${{ github.ref }}

strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-22.04]

steps:
- name: React to the triggering comment
run: |
hub api repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions --raw-field 'content=+1'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Configure git to use https
run: git config --global hub.protocol https

- name: Checkout the branch from the PR that triggered the job
run: hub pr checkout ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
python_version: '3.11'

- name: Install dependencies
run: python -m pip install -U "jupyterlab>=4.0.0,<5"

- name: Install extension
run: |
python -m pip install .

- name: Build extension
run: |
npm run build

- uses: jupyterlab/maintainer-tools/.github/actions/update-snapshots@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Playwright knows how to start JupyterLab server
start_server_script: 'null'
test_folder: ui-tests
npm_client: npm

- name: Comment back on the PR
run: |
hub api repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments --raw-field 'body=Playwright ${{ matrix.os }} snapshots updated.'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ nbdime/webapp/static/**
*.tsbuildinfo
packages/webapp/webpack-stats.json
nbdime/labextension/
ui-tests/playwright-report/
ui-tests/test-results/
1 change: 1 addition & 0 deletions examples/example1
56 changes: 56 additions & 0 deletions examples/example10/center.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "eabfe4e0-d646-4d09-95a4-09ee3d030db6",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"def gaussian(x, a, b, c):\n",
" #calculate a gaussian\n",
" return a * np.exp(-b * (x-c)**2)\n",
"\n",
"def sinus ():\n",
" # Here you can see a sinus function\n",
" nx = 100\n",
" x = np.linspace(-5.0, 5.0, nx)\n",
" y = np.sin(x)\n",
" return x, y\n",
"\n",
"def noisy_gaussian():\n",
" # gaussian array y in interval -5 <= x <= 5\n",
" nx = 100\n",
" x = np.linspace(-5.0, 5.0, nx)\n",
" y = gaussian(x, a=2.0, b=0.5, c=1.5)\n",
" noise = np.random.normal(0.0, 0.2, nx)\n",
" y += noise\n",
" return x, y"
]
}
],
"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.11.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
53 changes: 53 additions & 0 deletions examples/example10/left.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "2d47bfe2-d91d-4f72-9426-1885c4edb5a9",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline\n",
"%this is a comment\n",
"% more more comments\n",
"\n",
"def gaussian(x, a, b, c):\n",
" return a * np.exp(-b * (x-c)**2)\n",
" % here a comment\n",
" % second line of comment\n",
"\n",
"def noisy_gaussian():\n",
" # gaussian array y in interval -5 <= x <= 5\n",
" nx = 100\n",
" x = np.linspace(-5.0, 5.0, nx)\n",
" y = gaussian(x, a=2.0, b=0.5, c=1.5)\n",
" noise = np.random.normal(0.0, 0.2, nx)\n",
" y += noise\n",
" return x, y"
]
}
],
"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.11.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading
Loading