Browse Source

Install puppeteer in a temp dir

Steven Silvester 5 years ago
parent
commit
3bebe8b786
3 changed files with 18 additions and 7 deletions
  1. 9 2
      examples/example_check.py
  2. 9 2
      jupyterlab/browser_check.py
  3. 0 3
      scripts/ci_script.sh

+ 9 - 2
examples/example_check.py

@@ -16,6 +16,7 @@ import os
 import shutil
 import sys
 import subprocess
+from tempfile import TemporaryDirectory
 
 from tornado.ioloop import IOLoop
 from traitlets import Bool, Unicode
@@ -56,8 +57,14 @@ def run_browser(url):
     target = osp.join(get_app_dir(), 'example_test')
     if not osp.exists(osp.join(target, 'node_modules')):
         os.makedirs(target)
-        subprocess.call(["jlpm"], cwd=target)
-        subprocess.call(["jlpm", "add", "puppeteer"], cwd=target)
+        # Install puppeteer in a temporary directory.
+        # This is to avoid an issue seen in CI where running yarn
+        # In the application directory resulted in the whole Python
+        # install getting removed
+        with TemporaryDirectory() as tdname:
+          subprocess.call(["jlpm"], cwd=tdname)
+          subprocess.call(["jlpm", "add", "puppeteer"], cwd=tdname)
+          shutil.copytree(osp.join(tdname, 'node_modules'), osp.join(target, 'node_modules'))
     shutil.copy(osp.join(here, 'chrome-example-test.js'), osp.join(target, 'chrome-example-test.js'))
     return subprocess.check_call(["node", "chrome-example-test.js", url], cwd=target)
 

+ 9 - 2
jupyterlab/browser_check.py

@@ -11,6 +11,7 @@ import os
 import shutil
 import sys
 import subprocess
+from tempfile import TemporaryDirectory
 
 from tornado.ioloop import IOLoop
 from notebook.notebookapp import flags, aliases
@@ -109,8 +110,14 @@ def run_browser(url):
     target = osp.join(get_app_dir(), 'browser_test')
     if not osp.exists(osp.join(target, 'node_modules')):
         os.makedirs(target)
-        subprocess.call(["jlpm"], cwd=target)
-        subprocess.call(["jlpm", "add", "puppeteer"], cwd=target)
+        # Install puppeteer in a temporary directory.
+        # This is to avoid an issue seen in CI where running yarn
+        # In the application directory resulted in the whole Python
+        # install getting removed
+        with TemporaryDirectory() as tdname:
+          subprocess.call(["jlpm"], cwd=tdname)
+          subprocess.call(["jlpm", "add", "puppeteer"], cwd=tdname)
+          shutil.copytree(osp.join(tdname, 'node_modules'), osp.join(target, 'node_modules'))
     shutil.copy(osp.join(here, 'chrome-test.js'), osp.join(target, 'chrome-test.js'))
     return subprocess.check_call(["node", "chrome-test.js", url], cwd=target)
 

+ 0 - 3
scripts/ci_script.sh

@@ -107,9 +107,6 @@ if [[ $GROUP == usage ]]; then
     jlpm run build:examples
 
     # Test the examples
-    pwd
-    ls
-    cat ./setup.sh
     jlpm run test:examples
 
     # Test the cli apps.