Skip to content

Commit

Permalink
Test nightly link (#1)
Browse files Browse the repository at this point in the history
* Create artifacts-comment.yaml

* Use future galata for ui-tests

* Fix CI
  • Loading branch information
fcollonval authored Sep 12, 2021
1 parent 4623fae commit f824391
Show file tree
Hide file tree
Showing 17 changed files with 1,772 additions and 378 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/artifacts-comment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Comment on pull request
on:
workflow_run:
workflows: ['Test workflow with upload']
types: [completed]
jobs:
pr_comment:
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
with:
# This snippet is public-domain, taken from
# https://github.com/oprypin/nightly.link/blob/master/.github/workflows/pr-comment.yml
script: |
const {owner, repo} = context.repo;
const run_id = ${{github.event.workflow_run.id}};
const pull_head_sha = '${{github.event.workflow_run.head_sha}}';
const pull_user_id = ${{github.event.sender.id}};
const issue_number = await (async () => {
const pulls = await github.pulls.list({owner, repo});
for await (const {data} of github.paginate.iterator(pulls)) {
for (const pull of data) {
if (pull.head.sha === pull_head_sha && pull.user.id === pull_user_id) {
return pull.number;
}
}
}
})();
if (issue_number) {
core.info(`Using pull request ${issue_number}`);
} else {
return core.error(`No matching pull request found`);
}
const {data: {artifacts}} = await github.actions.listWorkflowRunArtifacts({owner, repo, run_id});
if (!artifacts.length) {
return core.error(`No artifacts found`);
}
let body = `Download the artifacts for this pull request:\n`;
for (const art of artifacts) {
body += `\n* [${art.name}.zip](https://nightly.link/${owner}/${repo}/actions/artifacts/${art.id}.zip)`;
}
const {data: comments} = await github.issues.listComments({repo, owner, issue_number});
const existing_comment = comments.find((c) => c.user.login === 'github-actions[bot]');
if (existing_comment) {
core.info(`Updating comment ${existing_comment.id}`);
await github.issues.updateComment({repo, owner, comment_id: existing_comment.id, body});
} else {
core.info(`Creating a comment`);
await github.issues.createComment({repo, owner, issue_number, body});
}
61 changes: 44 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build

on:
push:
branches: master
branches: ['master']
pull_request:
branches: '*'
branches: ['master']

jobs:
test-3x:
Expand All @@ -19,7 +19,7 @@ jobs:
- name: Install node
uses: actions/setup-node@v1
with:
node-version: '12.x'
node-version: '14.x'
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
${{ runner.os }}-yarn-
- name: Install dependencies
run: python -m pip install -U jupyter_packaging~=0.7.9 jupyterlab~=3.0 pip wheel
run: python -m pip install -U jupyter_packaging~=0.7.9 jupyterlab~=3.0 pip wheel build
- name: Test the extension
run: |
jlpm
Expand All @@ -82,16 +82,15 @@ jobs:
jupyter labextension list 2>&1 | grep -ie "@jupyterlab/git.*OK"
python -m jupyterlab.browser_check
# Run our extension-specific browser integration test
# python tests/test-browser/run_browser_test.py
python -m build -w
- uses: actions/upload-artifact@v2
if: matrix.python-version == '3.9'
with:
name: extension
path: |
jupyterlab_git
jupyter-config
path: dist/jupyterlab_git*.whl
if-no-files-found: error

ui-test:
name: Integration tests
Expand All @@ -102,16 +101,45 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install node
uses: actions/setup-node@v1
with:
node-version: '14.x'
- uses: actions/download-artifact@v2
with:
name: extension
- name: Setup Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
architecture: 'x64'

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: pip cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-3.9-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-3.9-
${{ runner.os }}-pip-
- name: Install dependencies
# Install jupyter-archive to deal with test git repository upload
run: |
python -m pip install -U pip
python -m pip install jupyterlab~=3.0 jupyter-archive ./jupyterlab_git*.whl
- name: UI tests
run: |
docker-compose -f ./docker/docker-compose.yml down || true
docker-compose -f ./docker/docker-compose.yml pull -q || true
docker-compose -f ./docker/docker-compose.yml build
docker-compose -f ./docker/docker-compose.yml run --rm e2e
jlpm
jlpm install:browser
jlpm start-jlab:detached
jlpm run test
working-directory: ui-tests

- name: Upload UI Test artifacts
Expand All @@ -120,12 +148,11 @@ jobs:
with:
name: ui-test-output
path: |
ui-tests/playwright-report
ui-tests/test-results
- name: Stop containers
- name: Stop JupyterLab
if: always()
run: |
# Print jupyterlab logs before removing the containers using the container name set in docker-compose file
docker logs jupyterlab
docker-compose -f ./docker/docker-compose.yml down
kill -s SIGTERM $(pgrep jupyter-lab)
working-directory: ui-tests
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,5 @@ src/version.ts

# Integration tests
ui-tests/node_modules/
ui-tests/test-results/
ui-tests/test-results/
ui-tests/playwright-report/
59 changes: 10 additions & 49 deletions ui-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,6 @@
# Test

The test will produce a video to help debugging and check what happened.

To execute integration tests, you have two options:

- use docker-compose (cons: needs to know and use docker) - this is a more reliable solution.
- run tests locally (cons: will interact with your JupyterLab user settings)

## Test on docker

1. Compile the extension:

```
jlpm install
```

2. Execute the docker stack in the ui-tests folder:

```
docker-compose -f ./docker/docker-compose.yml build --no-cache
docker-compose -f ./docker/docker-compose.yml run --rm e2e
docker-compose -f ./docker/docker-compose.yml down
```

## Test locally
The test will produce a video to help debugging in case of failures and check what happened.

1. Compile the extension:

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

```
jupyter lab --ServerApp.token= --ServerApp.password=
jupyter lab --config ./ui-tests/jupyter_server_config.py
```

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

```
cd ui-tests
jlpm install
npx playwright install
npx playwright test
jlpm playwright install
jlpm playwright test
```

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

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

**Using docker**

```
docker-compose -f ./docker/docker-compose.yml run --rm -p 8888:8888 lab
```

**Using local installation**

```
jupyter lab --ServerApp.token= --ServerApp.password=
jupyter lab --config ./ui-tests/jupyter_server_config.py
```

3. Launch the code generator tool:

```
cd ui-tests
jlpm install
npx playwright install
npx playwright codegen localhost:8888
jlpm playwright install
jlpm playwright codegen localhost:8888
```

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

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

**Using docker**

```
docker-compose -f ./docker/docker-compose.yml run --rm -p 8888:8888 lab
```

**Using local installation**

```
jupyter lab --ServerApp.token= --ServerApp.password=
jupyter lab --config ./ui-tests/jupyter_server_config.py
```

3. Launch the debug tool:

```
cd ui-tests
jlpm install
npx playwright install
PWDEBUG=1 npx playwright test
jlpm playwright install
PWDEBUG=1 jlpm playwright test
```
13 changes: 0 additions & 13 deletions ui-tests/docker/Dockerfile

This file was deleted.

Binary file removed ui-tests/docker/data/merge-conflict-example.tar.gz
Binary file not shown.
58 changes: 0 additions & 58 deletions ui-tests/docker/docker-compose.yml

This file was deleted.

7 changes: 0 additions & 7 deletions ui-tests/docker/prepare.sh

This file was deleted.

Loading

0 comments on commit f824391

Please sign in to comment.