Skip to content

Commit e0cba8d

Browse files
pauldrucePrabhakar Kumar
authored andcommitted
Adds e2e smoke test which starts jupyter, starts a kernel, and verifies that it can connect and run a MATLAB command. This runs on every commit to main.
1 parent e47533e commit e0cba8d

21 files changed

+9039
-104
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020-2023 The MathWorks, Inc
1+
# Copyright 2020-2023 The MathWorks, Inc.
22

33
# Workflow to release MATLAB Jupyter Integration to PyPi
44
name: Release to PyPI

.github/workflows/run-e2e-tests.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Copyright 2023 The MathWorks, Inc.
2+
3+
name: End-to-End Tests for Jupyter Integration for MATLAB
4+
on:
5+
workflow_call:
6+
7+
jobs:
8+
playwright_e2e_tests:
9+
runs-on: ubuntu-latest
10+
env:
11+
NODE_VERSION: 18
12+
PYTHON_VERSION: 3.8
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version: ${{ env.NODE_VERSION }}
20+
21+
- name: Install xvfb
22+
run: |
23+
sudo apt-get update
24+
sudo apt-get install -y xvfb
25+
26+
- name: Install node dependencies
27+
working-directory: ./tests/e2e
28+
run: npm ci
29+
30+
- name: Run the linter
31+
working-directory: ./tests/e2e
32+
run: npm run lint
33+
34+
- name: Set up MATLAB
35+
# Use MATLAB Actions to get running MATLAB in GitHub Actions
36+
uses: matlab-actions/setup-matlab@v2-beta
37+
with:
38+
products: MATLAB Symbolic_Math_Toolbox
39+
40+
- name: Set up Python
41+
uses: actions/setup-python@v4
42+
with:
43+
python-version: ${{ env.PYTHON_VERSION }}
44+
45+
- name: Install jupyterlab and jupyter-matlab-proxy
46+
run: |
47+
python3 -m pip install --upgrade pip
48+
pip install ".[dev]"
49+
pip install "jupyterlab>3.1.0,<4.0.0"
50+
51+
- name: Install playwright browsers
52+
working-directory: ./tests/e2e
53+
run: npx playwright install --with-deps
54+
55+
- name: Find an available port
56+
run: |
57+
FREE_PORT=$(python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()');
58+
echo "Using port = ${FREE_PORT}"
59+
echo "TEST_JMP_PORT=$FREE_PORT" >> "$GITHUB_ENV"
60+
61+
# Playwright will start and stop the JupyterLab server, so we need
62+
# to activate the Python venv. The command that is executed by Playwright
63+
# is set by the webServer setting in the file playwright.config.ts
64+
- name: Run playwright tests
65+
working-directory: tests/e2e
66+
env:
67+
TEST_USERNAME: ${{ secrets.TEST_USERNAME }}
68+
TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }}
69+
TEST_JMP_PORT: ${{ env.TEST_JMP_PORT }}
70+
run: |
71+
echo "Playwright version: $(npx playwright -V)"
72+
npx playwright test
73+
74+
- name: Zip test results
75+
if: always()
76+
working-directory: tests/e2e
77+
run: |
78+
zip -r zipped-e2e-test-results.zip ./playwright-report ./test-results
79+
80+
- name: Preserve test results after the job has finished
81+
if: always()
82+
uses: actions/upload-artifact@v3
83+
with:
84+
name: e2e_test_results
85+
path: ./tests/e2e/zipped-e2e-test-results.zip
86+
retention-days: 5

.github/workflows/run-integration-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020-2023 The MathWorks, Inc
1+
# Copyright 2020-2023 The MathWorks, Inc.
22

33
# Workflow that contains jobs to test MATLAB Jupyter Integration
44
name: Integration testing MATLAB Jupyter Integration

.github/workflows/run-tests.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020-2023 The MathWorks, Inc
1+
# Copyright 2020-2023 The MathWorks, Inc.
22

33
# Workflow that contains jobs to test MATLAB Jupyter Integration
44
name: Testing MATLAB Jupyter Integration
@@ -13,8 +13,14 @@ jobs:
1313
call-unit-tests:
1414
# Runs unit tests
1515
uses: ./.github/workflows/run-unit-tests.yml
16+
secrets: inherit
1617

1718
call-integration-tests:
1819
# Runs integration tests
1920
uses: ./.github/workflows/run-integration-tests.yml
21+
secrets: inherit
22+
23+
call-e2e-tests:
24+
# Runs the end-to-end tests
25+
uses: ./.github/workflows/run-e2e-tests.yml
2026
secrets: inherit

.github/workflows/run-unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020-2023 The MathWorks, Inc
1+
# Copyright 2020-2023 The MathWorks, Inc.
22

33
# Workflow that contains jobs to test MATLAB Jupyter Integration
44
name: Unit Testing MATLAB Jupyter Integration

.gitignore

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
*.egg-info/
2-
.eggs/
3-
__pycache__/
4-
build/
5-
dist/
6-
.venv/
7-
.vscode/
8-
htmlcov/
1+
*.egg-info
2+
.eggs
3+
__pycache__
4+
build
5+
dist
6+
.venv
7+
.vscode
8+
htmlcov
99
.coverage
1010
coverage.xml
1111
cov_html
12+
node_modules
13+
playwright-report
14+
test-results
15+
.env
1216
.python-version
13-
*.env
14-
*node_modules
15-
*playwright-report
16-
*test-results

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
Run MATLAB® code in Jupyter® environments such as Jupyter notebooks, JupyterLab, and JupyterHub.
77

88

9-
## Table of Contents
9+
## Table of Contents
1010
1. [Features of MATLAB Integration _for Jupyter_](#features-of-matlab-integration-for-jupyter)
11-
2. [Requirements](#requirements)
11+
2. [Requirements](#requirements)
1212
3. [Install](#install)
1313
4. [Get Started](#get-started)
1414
1. [Run MATLAB Code in a Jupyter Notebook](#run-matlab-code-in-a-jupyter-notebook)
1515
2. [Open MATLAB in a Browser](#open-matlab-in-a-browser)
16-
3. [Edit MATLAB Files in JupyterLab](#edit-matlab-files-in-jupyterlab)
16+
3. [Edit MATLAB Files in JupyterLab](#edit-matlab-files-in-jupyterlab)
1717
5. [Limitations](#limitations)
1818

1919

@@ -22,9 +22,9 @@ Run MATLAB® code in Jupyter® environments such as Jupyter notebooks, JupyterLa
2222
You can use this package to run MATLAB code in Jupyter notebooks and JupyterLab.
2323

2424
<p><img width="600" src="https://github.com/mathworks/jupyter-matlab-proxy/raw/main/img/JupyterKernel.gif"></p>
25-
25+
2626
From your Jupyter notebook or JupyterLab, you can also open the MATLAB development environment in your browser to access more MATLAB features.
27-
27+
2828
<p><img width="600" src="https://github.com/mathworks/jupyter-matlab-proxy/raw/main/img/JupyterMATLABDesktop.gif"></p>
2929

3030
## Requirements
@@ -41,7 +41,7 @@ From your Jupyter notebook or JupyterLab, you can also open the MATLAB developme
4141
# Confirm MATLAB is on the PATH
4242
which matlab
4343
```
44-
Note: You only need MATLAB installed if you want to execute MATLAB code. You can open Jupyter notebooks containing MATLAB code without having MATLAB installed.
44+
Note: You only need MATLAB installed if you want to execute MATLAB code. You can open Jupyter notebooks containing MATLAB code without having MATLAB installed.
4545

4646
* System dependencies required to run MATLAB:
4747
- The [MATLAB Dependencies](https://github.com/mathworks-ref-arch/container-images/tree/master/matlab-deps) repository contains `base-dependencies.txt` files that list the libraries required to run each release of MATLAB on a given operating system. To see how to use these files, refer to the Dockerfiles in the same folder.
@@ -51,16 +51,16 @@ From your Jupyter notebook or JupyterLab, you can also open the MATLAB developme
5151
```bash
5252
# On a Debian/Ubuntu based system:
5353
$ sudo apt install xvfb
54-
54+
5555
# On a RHEL based system:
5656
$ yum search Xvfb
5757
xorg-x11-server-Xvfb.x86_64 : A X Windows System virtual framebuffer X server.
5858
$ sudo yum install xorg-x11-server-Xvfb
59-
```
59+
```
6060

6161
## Install
6262

63-
Install this Python package from the Python Package Index (PyPI) or build it from the source.
63+
Install this Python package from the Python Package Index (PyPI) or build it from the source.
6464

6565
### Install from PyPI
6666

@@ -69,7 +69,7 @@ python3 -m pip install jupyter-matlab-proxy
6969
```
7070
Installing this package will not install MATLAB. To execute MATLAB code in Jupyter, you must have [MATLAB installed](https://www.mathworks.com/help/install/install-products.html) separately.
7171

72-
The package lets you execute MATLAB code in both JupyterLab 3 and JupyterLab 4, but syntax highlighting and autoindentation are currently only supported on JupyterLab 3. Install JupyterLab 3 using:
72+
The package lets you execute MATLAB code in both JupyterLab 3 and JupyterLab 4, but syntax highlighting and auto indentation are currently only supported on JupyterLab 3. Install JupyterLab 3 using:
7373
```bash
7474
python3 -m pip install 'jupyterlab>=3.0.0,<4.0.0a0'
7575
```
@@ -111,12 +111,12 @@ Open your Jupyter environment by starting Jupyter Notebook or JupyterLab.
111111
jupyter notebook
112112

113113
# For JupyterLab
114-
jupyter lab
114+
jupyter lab
115115
```
116116

117-
If you are prompted for a token, click the link shown in your terminal to access your Jupyter environment.
117+
If you are prompted for a token, click the link shown in your terminal to access your Jupyter environment.
118118

119-
After installing this package, you see new MATLAB options in your Jupyter environments.
119+
After installing this package, you see new MATLAB options in your Jupyter environments.
120120

121121

122122
| Classic Notebook Interface | JupyterLab |
@@ -126,7 +126,7 @@ After installing this package, you see new MATLAB options in your Jupyter enviro
126126

127127
## Run MATLAB Code in a Jupyter Notebook
128128

129-
To open a Jupyter notebook where you can run MATLAB code, click `MATLAB Kernel` in your notebook or JupyterLab.
129+
To open a Jupyter notebook where you can run MATLAB code, click `MATLAB Kernel` in your notebook or JupyterLab.
130130

131131

132132
| Classic Notebook Interface | JupyterLab |
@@ -139,7 +139,7 @@ This opens a Jupyter notebook that supports MATLAB.
139139

140140

141141
- When you execute MATLAB code in a notebook for the first time, enter your MATLAB license information in the dialog box that appears. See [Licensing](https://github.com/mathworks/matlab-proxy/blob/main/MATLAB-Licensing-Info.md) for details. The MATLAB session can take a few minutes to start.
142-
- Multiple notebooks running on a Jupyter server share the underlying MATLAB process, so executing code in one notebook affects the workspace in others. If you work in several notebooks simultaneously, be aware that they share a workspace.
142+
- Multiple notebooks running on a Jupyter server share the underlying MATLAB process, so executing code in one notebook affects the workspace in others. If you work in several notebooks simultaneously, be aware that they share a workspace.
143143
- With MATLAB R2022b and later, you can define a local function at the end of the cell where you want to call it:
144144
<p><img width="350" src="https://github.com/mathworks/jupyter-matlab-proxy/raw/main/img/local_functions.png"></p>
145145
For technical details about how the MATLAB kernel works, see [MATLAB Kernel for Jupyter](https://github.com/mathworks/jupyter-matlab-proxy/blob/main/src/jupyter_matlab_kernel/README.md).
@@ -153,15 +153,15 @@ To access more MATLAB features, you can open the MATLAB development environment
153153
| :---: | :---: |
154154
|<img width="200" src="https://github.com/mathworks/jupyter-matlab-proxy/raw/main/img/open_matlab_notebook.png"> | <img width="300" src="https://github.com/mathworks/jupyter-matlab-proxy/raw/main/img/open_matlab_jupyterlab.png"> |
155155

156-
Notebooks in JupyterLab also have a `Open MATLAB` button on the toolbar:
156+
Notebooks in JupyterLab also have a `Open MATLAB` button on the toolbar:
157157

158158
<img width="300" src="https://github.com/mathworks/jupyter-matlab-proxy/raw/main/img/open-matlab-button.png">
159159

160160
Clicking `Open MATLAB` opens the MATLAB development environment in a new browser tab.
161161

162162
<p align="center"><img width="600" src="https://github.com/mathworks/jupyter-matlab-proxy/raw/main/img/jupyter_matlab_desktop.png"></p>
163163

164-
When you use the package for the first time, enter your MATLAB license information in the dialog box that appears. See [Licensing](https://github.com/mathworks/matlab-proxy/blob/main/MATLAB-Licensing-Info.md) for details.
164+
When you use the package for the first time, enter your MATLAB license information in the dialog box that appears. See [Licensing](https://github.com/mathworks/matlab-proxy/blob/main/MATLAB-Licensing-Info.md) for details.
165165

166166
For technical details about this MATLAB development environment, see [MATLAB in a Browser](https://github.com/mathworks/jupyter-matlab-proxy/blob/main/src/jupyter_matlab_proxy/README.md).
167167

@@ -172,7 +172,7 @@ You can also edit MATLAB `.m` files in JupyterLab. Click the `MATLAB File` butto
172172

173173
<p align="center"><img width="300" src="https://github.com/mathworks/jupyter-matlab-proxy/raw/main/img/matlabfile-icon.png"></p>
174174

175-
This opens an untitled `.m` file where you can write MATLAB code with syntax highlighting and autoindentation.
175+
This opens an untitled `.m` file where you can write MATLAB code with syntax highlighting and auto indentation.
176176

177177
<p align="center"><img width="600" src="https://github.com/mathworks/jupyter-matlab-proxy/raw/main/img/new-matlab-file.png"></p>
178178

src/jupyter_matlab_labextension/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@
7070
"prettier": "^2.1.1",
7171
"rimraf": "^3.0.2",
7272
"semver": ">=5.7.2",
73-
"typescript": "~4.1.3"
73+
"typescript": "~4.1.3",
74+
"yarn-audit-fix": "^10.0.1"
7475
},
7576
"sideEffects": [
7677
"style/*.css",

0 commit comments

Comments
 (0)