Browse Source

Add tests and workflow job for interop between source and prebuilt extensions

Afshin T. Darian 4 years ago
parent
commit
b061ecbcf9

+ 1 - 1
.github/workflows/linuxtests.yml

@@ -7,7 +7,7 @@ jobs:
     name: Linux
     strategy:
       matrix:
-        group: [integrity, integrity2, docs, usage, python, examples, nonode, linkcheck, lint]
+        group: [integrity, integrity2, docs, usage, python, examples, interop, nonode, linkcheck, lint]
         python: [3.6, 3.8]
         exclude:
           - group: integrity

+ 15 - 0
jupyterlab/tests/mock_packages/interop/consumer/index.js

@@ -0,0 +1,15 @@
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+
+const IMockToken = require('@jupyterlab/mock-token').IMockToken;
+
+module.exports = [
+  {
+    id: 'ext_leaf',
+    requires: [IMockToken],
+    autoStart: true,
+    activate: function (application, mock_token) {
+      console.log('hi from consumer', mock_token);
+    }
+  }
+];

+ 13 - 0
jupyterlab/tests/mock_packages/interop/consumer/jlab_mock_consumer.py

@@ -0,0 +1,13 @@
+import json
+import os.path as osp
+
+HERE = osp.abspath(osp.dirname(__file__))
+
+with open(osp.join(HERE, 'package.json')) as fid:
+    data = json.load(fid)
+
+def _jupyter_labextension_paths():
+    return [{
+        'src': data['jupyterlab'].get('outputDir', 'static'),
+        'dest': data['name']
+    }]

+ 14 - 0
jupyterlab/tests/mock_packages/interop/consumer/package.json

@@ -0,0 +1,14 @@
+{
+  "name": "@jupyterlab/mock-consumer",
+  "version": "3.0.0-rc.13",
+  "private": true,
+  "dependencies": {
+    "@jupyterlab/mock-token": "^3.0.0-rc.13"
+  },
+  "devDependencies": {
+    "@jupyterlab/builder": "^3.0.0-rc.13"
+  },
+  "jupyterlab": {
+    "extension": true
+  }
+}

+ 21 - 0
jupyterlab/tests/mock_packages/interop/consumer/setup.py

@@ -0,0 +1,21 @@
+import json
+from glob import glob
+import os.path as osp
+
+name = 'jlab_mock_consumer'
+HERE = osp.abspath(osp.dirname(__file__))
+
+with open(osp.join(HERE, 'package.json')) as fid:
+    data = json.load(fid)
+
+from setuptools import setup
+
+js_name = data['name']
+
+setup(name=name,
+      version=data['version'],
+      py_modules = [name],
+      data_files = [
+        (f'share/jupyter/labextensions/{js_name}', glob('static/package.json')),
+        (f'share/jupyter/labextensions/{js_name}', glob('static/static/*'))
+    ])

+ 15 - 0
jupyterlab/tests/mock_packages/interop/provider/index.js

@@ -0,0 +1,15 @@
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+const IMockToken = require('@jupyterlab/mock-token').IMockToken;
+
+module.exports = [
+  {
+    id: 'mock-provider',
+    provides: IMockToken,
+    autoStart: true,
+    activate: function (application) {
+      console.log('hi from provider');
+      return { value: 'hello' };
+    }
+  }
+];

+ 13 - 0
jupyterlab/tests/mock_packages/interop/provider/jlab_mock_provider.py

@@ -0,0 +1,13 @@
+import json
+import os.path as osp
+
+HERE = osp.abspath(osp.dirname(__file__))
+
+with open(osp.join(HERE, 'static', 'package.json')) as fid:
+    data = json.load(fid)
+
+def _jupyter_labextension_paths():
+    return [{
+        'src': data['jupyterlab'].get('outputDir', 'static'),
+        'dest': data['name']
+    }]

+ 14 - 0
jupyterlab/tests/mock_packages/interop/provider/package.json

@@ -0,0 +1,14 @@
+{
+  "name": "@jupyterlab/mock-provider",
+  "version": "3.0.0-rc.13",
+  "private": true,
+  "dependencies": {
+    "@jupyterlab/mock-token": "^3.0.0-rc.13"
+  },
+  "devDependencies": {
+    "@jupyterlab/builder": "^3.0.0-rc.13"
+  },
+  "jupyterlab": {
+    "extension": true
+  }
+}

+ 22 - 0
jupyterlab/tests/mock_packages/interop/provider/setup.py

@@ -0,0 +1,22 @@
+import json
+from glob import glob
+import os.path as osp
+
+name = 'jlab_mock_provider'
+HERE = osp.abspath(osp.dirname(__file__))
+
+with open(osp.join(HERE, 'package.json')) as fid:
+    data = json.load(fid)
+
+from setuptools import setup
+
+js_name = data['name']
+
+setup(name=name,
+      version=data['version'],
+      py_modules = [name],
+      data_files = [
+        (f'share/jupyter/labextensions/{js_name}', glob('static/package.json')),
+        (f'share/jupyter/labextensions/{js_name}', glob('static/static/*'))
+    ],
+     )

+ 7 - 0
jupyterlab/tests/mock_packages/interop/token/index.js

@@ -0,0 +1,7 @@
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+const Token = require('@lumino/coreutils').Token;
+
+module.exports = {
+  IMockToken: new Token('mock-token')
+};

+ 8 - 0
jupyterlab/tests/mock_packages/interop/token/package.json

@@ -0,0 +1,8 @@
+{
+  "name": "@jupyterlab/mock-token",
+  "version": "3.0.0-rc.13",
+  "private": true,
+  "dependencies": {
+    "@lumino/coreutils": "^1.5.3"
+  }
+}

+ 2 - 1
package.json

@@ -16,7 +16,8 @@
       "tests",
       "tests/test-*",
       "testutils",
-      "jupyterlab/tests/mock_packages/extension"
+      "jupyterlab/tests/mock_packages/extension",
+      "jupyterlab/tests/mock_packages/interop/*"
     ]
   },
   "scripts": {

+ 65 - 0
scripts/ci_script.sh

@@ -326,6 +326,71 @@ if [[ $GROUP == usage ]]; then
     jupyter lab clean --all
 fi
 
+if [[ $GROUP == interop ]]; then
+    cd jupyterlab/tests/mock_packages/interop
+
+    # Install a source extension that depends on a prebuilt extension
+    pushd token
+    jupyter labextension link . --no-build
+    popd
+    pushd provider
+    jupyter labextension build .
+    pip install .
+    popd
+    pushd consumer
+    jupyter labextension install .
+    popd
+    jupyter labextension list 1>labextensions 2>&1
+    cat labextensions | grep -q "@jupyterlab/mock-consumer.*OK"
+    cat labextensions | grep -q "@jupyterlab/mock-provider.*OK"
+
+    python -m jupyterlab.browser_check
+
+    # Clear install
+    pip uninstall -y jlab_mock_provider
+    jupyter lab clean --all
+
+    # Install a prebuilt extension that depends on a source extension
+    pushd token
+    jupyter labextension link . --no-build
+    popd
+    pushd provider
+    jupyter labextension install .
+    popd
+    pushd consumer
+    jupyter labextension build .
+    pip install .
+    popd
+    jupyter labextension list 1>labextensions 2>&1
+    cat labextensions | grep -q "@jupyterlab/mock-consumer.*OK"
+    cat labextensions | grep -q "@jupyterlab/mock-provider.*OK"
+    python -m jupyterlab.browser_check
+
+    # Clear install
+    pip uninstall -y jlab_mock_consumer
+    jupyter lab clean --all
+
+    # Install the mock consumer as a source extension and as a
+    # prebuilt extension to test shadowing
+    pushd token
+    jupyter labextension link . --no-build
+    popd
+    pushd provider
+    jupyter labextension install . --no-build
+    popd
+    pushd consumer
+    # Need to install source first because it would get ignored
+    # if installed after
+    jupyter labextension install .
+    jupyter labextension build .
+    pip install .
+    popd
+    jupyter labextension list 1>labextensions 2>&1
+    cat labextensions | grep -q "@jupyterlab/mock-consumer.*OK"
+    cat labextensions | grep -q "@jupyterlab/mock-provider.*OK"
+    python -m jupyterlab.browser_check
+fi
+
 if [[ $GROUP == nonode ]]; then
     # Make sure we can install the wheel
     virtualenv -p $(which python3) test_install