Skip to content

Commit d61c9c1

Browse files
authored
Use galata for integration tests (#1030)
* Use future galata for ui-tests * Fix CI * WIP * Wait for the server * Refactor * Use extension merge feature * Lint config file * Force repository status update * Run server in debug mode * Fix linter * Fix CI * Refactor ui tests * Set server log to debug * Set git config globally * [skip ci] use default server log level
1 parent 2f74ac4 commit d61c9c1

17 files changed

+3656
-909
lines changed

.github/workflows/build.yml

Lines changed: 66 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@ name: Build
22

33
on:
44
push:
5-
branches: master
5+
branches: ['master']
66
pull_request:
7-
branches: '*'
7+
branches: ['master']
88

99
jobs:
1010
test-3x:
1111
name: Test Python ${{ matrix.python-version }}
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
python-version: ['3.6', '3.7', '3.8', '3.9']
15+
python-version: ['3.7', '3.8', '3.9', '3.10']
1616
steps:
1717
- name: Checkout
1818
uses: actions/checkout@v2
1919
- name: Install node
2020
uses: actions/setup-node@v1
2121
with:
22-
node-version: '12.x'
22+
node-version: '14.x'
2323
- name: Setup Python ${{ matrix.python-version }}
2424
uses: actions/setup-python@v2
2525
with:
@@ -59,7 +59,7 @@ jobs:
5959
${{ runner.os }}-yarn-
6060
6161
- name: Install dependencies
62-
run: python -m pip install -U jupyter_packaging~=0.7.9 jupyterlab~=3.0 pip wheel
62+
run: python -m pip install -U jupyter_packaging~=0.7.9 jupyterlab~=3.0 pip wheel build
6363
- name: Test the extension
6464
run: |
6565
jlpm
@@ -83,13 +83,14 @@ jobs:
8383
jupyter labextension list 2>&1 | grep -ie "@jupyterlab/git.*OK"
8484
python -m jupyterlab.browser_check
8585
86+
python -m build -w
87+
8688
- uses: actions/upload-artifact@v2
8789
if: matrix.python-version == '3.9'
8890
with:
8991
name: extension
90-
path: |
91-
jupyterlab_git
92-
jupyter-config
92+
path: dist/jupyterlab_git*.whl
93+
if-no-files-found: error
9394

9495
ui-test:
9596
name: Integration tests
@@ -100,30 +101,77 @@ jobs:
100101
steps:
101102
- name: Checkout
102103
uses: actions/checkout@v2
104+
- name: Install node
105+
uses: actions/setup-node@v1
106+
with:
107+
node-version: '14.x'
103108
- uses: actions/download-artifact@v2
104109
with:
105110
name: extension
111+
- name: Setup Python 3.9
112+
uses: actions/setup-python@v2
113+
with:
114+
python-version: 3.9
115+
architecture: 'x64'
106116

107-
- name: UI tests
117+
- name: Get pip cache dir
118+
id: pip-cache
108119
run: |
109-
docker-compose -f ./docker/docker-compose.yml down || true
110-
docker-compose -f ./docker/docker-compose.yml pull -q || true
111-
docker-compose -f ./docker/docker-compose.yml build
112-
docker-compose -f ./docker/docker-compose.yml run --rm e2e
120+
echo "::set-output name=dir::$(pip cache dir)"
121+
122+
- name: pip cache
123+
uses: actions/cache@v2
124+
with:
125+
path: ${{ steps.pip-cache.outputs.dir }}
126+
key: ${{ runner.os }}-pip-3.9-${{ hashFiles('**/setup.py') }}
127+
restore-keys: |
128+
${{ runner.os }}-pip-3.9-
129+
${{ runner.os }}-pip-
130+
131+
- name: Install dependencies
132+
# Install jupyter-archive to deal with test git repository upload
133+
run: |
134+
python -m pip install -U pip
135+
python -m pip install jupyterlab~=3.0 jupyter-archive ./jupyterlab_git*.whl
136+
137+
- name: Set up git
138+
run: |
139+
git config --global user.name 'Test Bot'
140+
git config --global user.email '[email protected]'
141+
142+
- name: Start server for UI tests
143+
working-directory: ui-tests
144+
run: |
145+
jlpm
146+
(jupyter lab --config jupyter_server_test_config.py > /tmp/jupyterlab_server.log 2>&1) &
147+
jlpm run playwright install chromium
148+
149+
- name: Wait for JupyterLab
150+
uses: ifaxity/wait-on-action@v1
151+
with:
152+
resource: http-get://localhost:8888/lab
153+
timeout: 180000
154+
155+
- name: UI tests
113156
working-directory: ui-tests
157+
run: |
158+
jlpm run playwright test
114159
115160
- name: Upload UI Test artifacts
116161
if: always()
117162
uses: actions/upload-artifact@v2
118163
with:
119164
name: ui-test-output
120165
path: |
166+
ui-tests/playwright-report
121167
ui-tests/test-results
122168
123-
- name: Stop containers
169+
- name: Stop JupyterLab
124170
if: always()
125171
run: |
126-
# Print jupyterlab logs before removing the containers using the container name set in docker-compose file
127-
docker logs jupyterlab
128-
docker-compose -f ./docker/docker-compose.yml down
129-
working-directory: ui-tests
172+
kill -s SIGTERM $(pgrep jupyter-lab)
173+
174+
- name: Print JupyterLab logs
175+
if: always()
176+
run: |
177+
cat /tmp/jupyterlab_server.log

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,5 +137,5 @@ dmypy.json
137137
src/version.ts
138138

139139
# Integration tests
140-
ui-tests/node_modules/
141-
ui-tests/test-results/
140+
test-results/
141+
playwright-report/

ui-tests/README.md

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,6 @@
11
# Test
22

3-
The test will produce a video to help debugging and check what happened.
4-
5-
To execute integration tests, you have two options:
6-
7-
- use docker-compose (cons: needs to know and use docker) - this is a more reliable solution.
8-
- run tests locally (cons: will interact with your JupyterLab user settings)
9-
10-
## Test on docker
11-
12-
1. Compile the extension:
13-
14-
```
15-
jlpm install
16-
```
17-
18-
2. Execute the docker stack in the ui-tests folder:
19-
20-
```
21-
docker-compose -f ./docker/docker-compose.yml build --no-cache
22-
docker-compose -f ./docker/docker-compose.yml run --rm e2e
23-
docker-compose -f ./docker/docker-compose.yml down
24-
```
25-
26-
## Test locally
3+
The test will produce a video to help debugging in case of failures and check what happened.
274

285
1. Compile the extension:
296

@@ -35,16 +12,16 @@ jlpm run build:prod
3512
2. Start JupyterLab _with the extension installed_ without any token or password
3613

3714
```
38-
jupyter lab --ServerApp.token= --ServerApp.password=
15+
jupyter lab --config ./ui-tests/jupyter_server_config.py
3916
```
4017

4118
3. Execute in another console the [Playwright](https://playwright.dev/docs/intro) tests:
4219

4320
```
4421
cd ui-tests
4522
jlpm install
46-
npx playwright install
47-
npx playwright test
23+
jlpm playwright install
24+
jlpm playwright test
4825
```
4926

5027
# Create tests
@@ -60,25 +37,17 @@ jlpm run build:prod
6037

6138
2. Start JupyterLab _with the extension installed_ without any token or password:
6239

63-
**Using docker**
64-
65-
```
66-
docker-compose -f ./docker/docker-compose.yml run --rm -p 8888:8888 lab
67-
```
68-
69-
**Using local installation**
70-
7140
```
72-
jupyter lab --ServerApp.token= --ServerApp.password=
41+
jupyter lab --config ./ui-tests/jupyter_server_config.py
7342
```
7443

7544
3. Launch the code generator tool:
7645

7746
```
7847
cd ui-tests
7948
jlpm install
80-
npx playwright install
81-
npx playwright codegen localhost:8888
49+
jlpm playwright install
50+
jlpm playwright codegen localhost:8888
8251
```
8352

8453
# Debug tests
@@ -94,23 +63,15 @@ jlpm run build:prod
9463

9564
2. Start JupyterLab _with the extension installed_ without any token or password:
9665

97-
**Using docker**
98-
99-
```
100-
docker-compose -f ./docker/docker-compose.yml run --rm -p 8888:8888 lab
101-
```
102-
103-
**Using local installation**
104-
10566
```
106-
jupyter lab --ServerApp.token= --ServerApp.password=
67+
jupyter lab --config ./ui-tests/jupyter_server_config.py
10768
```
10869

10970
3. Launch the debug tool:
11071

11172
```
11273
cd ui-tests
11374
jlpm install
114-
npx playwright install
115-
PWDEBUG=1 npx playwright test
75+
jlpm playwright install
76+
PWDEBUG=1 jlpm playwright test
11677
```

ui-tests/docker/Dockerfile

Lines changed: 0 additions & 13 deletions
This file was deleted.
Binary file not shown.

ui-tests/docker/docker-compose.yml

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

ui-tests/docker/prepare.sh

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

0 commit comments

Comments
 (0)