Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CI #396

Merged
merged 5 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 20 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ jobs:
- name: Install dependencies
run: |
pip install "jupyterlab>=4.0.0,<5"
pip install -e .
pip install -e projects/jupyter-collaboration-ui -e projects/jupyter-docprovider -e projects/jupyter-server-ydoc
jlpm
jlpm install

- name: Run pre-commit
uses: pre-commit/[email protected]
Expand All @@ -55,6 +53,7 @@ jobs:
test-js:
name: Test JavaScript
runs-on: ubuntu-latest
needs: [pre-commit]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -69,13 +68,7 @@ jobs:

- name: Install dependencies
run: |
pip install "jupyterlab>=4.0.0,<5"
pip install -e .
pip install -e projects/jupyter-collaboration-ui -e projects/jupyter-docprovider -e projects/jupyter-server-ydoc
jupyter labextension develop --overwrite projects/jupyter-collaboration-ui
jupyter labextension develop --overwrite projects/jupyter-docprovider
jlpm
jlpm build
yarn dev

- name: Run Tests
run: |
Expand All @@ -84,13 +77,14 @@ jobs:

test-py:
name: Test Python
needs: [pre-commit]
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
# PyPy is not supported because we use the file_id_manager. See:
# https://github.com/jupyter-server/jupyter_server_fileid/issues/44
#include:
Expand All @@ -106,9 +100,8 @@ jobs:

- name: Install the Python dependencies
run: |
python -m pip install "jupyterlab>=4.0.0,<5"
python -m pip install -e ".[test]" codecov
python -m pip install -e projects/jupyter-collaboration-ui -e projects/jupyter-docprovider -e projects/jupyter-server-ydoc
python -m pip install codecov
yarn dev

- name: List installed packages
run: |
Expand Down Expand Up @@ -148,7 +141,7 @@ jobs:

test_minimum_versions:
name: Test Minimum Versions
needs: [pre-commit, test-js, test-py]
needs: [test-js, test-py]
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
Expand All @@ -157,21 +150,20 @@ jobs:
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
python_version: "3.8"
python_version: "3.9"
dependency_type: minimum

- name: Install the Python dependencies
run: |
pip install -e ".[test]"
pip install -e projects/jupyter-collaboration-ui -e projects/jupyter-docprovider -e projects/jupyter-server-ydoc
yarn dev

- name: Run the unit tests
run: |
pytest -vv -W default || pytest -vv -W default --lf

test_prereleases:
name: Test Prereleases
needs: [pre-commit, test-js, test-py]
needs: [test-js, test-py]
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
Expand All @@ -183,8 +175,7 @@ jobs:

- name: Install the Python dependencies
run: |
pip install -e ".[test]"
pip install -e projects/jupyter-collaboration-ui -e projects/jupyter-docprovider -e projects/jupyter-server-ydoc
yarn dev

- name: List installed packages
run: |
Expand All @@ -197,7 +188,7 @@ jobs:

make_sdist:
name: Make SDist
needs: [pre-commit, test-js, test-py]
needs: [pre-commit]
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
Expand Down Expand Up @@ -269,16 +260,21 @@ jobs:

ui_tests:
runs-on: ubuntu-latest
needs: [pre-commit, test-js]
needs: [make_sdist]
timeout-minutes: 30
env:
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/pw-browsers
steps:
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Download sdist
uses: actions/download-artifact@v4
with:
name: "sdist"
- name: Install dependencies
run: |
pip install jupyterlab .
pip install jupyterlab jupyter_collaboration_ui*.tar.gz jupyter_docprovider*.tar.gz jupyter_server_ydoc*.tar.gz

- name: Install playwright
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/update_galata_references.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Update Galata References

on:
issue_comment:
types: [created, edited]

permissions:
contents: write
pull-requests: write

defaults:
run:
shell: bash -l {0}

jobs:
update-snapshots:
if: >
(
github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'COLLABORATOR' ||
github.event.comment.author_association == 'MEMBER'
) && github.event.issue.pull_request && contains(github.event.comment.body, 'please update snapshots')
runs-on: ubuntu-latest
steps:
- name: React to the triggering comment
run: |
gh api repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions --raw-field 'content=+1'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Get PR Info
id: pr
env:
PR_NUMBER: ${{ github.event.issue.number }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
COMMENT_AT: ${{ github.event.comment.created_at }}
run: |
pr="$(gh api /repos/${GH_REPO}/pulls/${PR_NUMBER})"
head_sha="$(echo "$pr" | jq -r .head.sha)"
pushed_at="$(echo "$pr" | jq -r .pushed_at)"

if [[ $(date -d "$pushed_at" +%s) -gt $(date -d "$COMMENT_AT" +%s) ]]; then
echo "Updating is not allowed because the PR was pushed to (at $pushed_at) after the triggering comment was issued (at $COMMENT_AT)"
exit 1
fi

echo "head_sha=$head_sha" >> $GITHUB_OUTPUT

- name: Checkout the branch from the PR that triggered the job
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr checkout ${{ github.event.issue.number }}

- name: Validate the fetched branch HEAD revision
env:
EXPECTED_SHA: ${{ steps.pr.outputs.head_sha }}
run: |
actual_sha="$(git rev-parse HEAD)"

if [[ "$actual_sha" != "$EXPECTED_SHA" ]]; then
echo "The HEAD of the checked out branch ($actual_sha) differs from the HEAD commit available at the time when trigger comment was submitted ($EXPECTED_SHA)"
exit 1
fi

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Build the extension
run: yarn dev

- uses: jupyterlab/maintainer-tools/.github/actions/update-snapshots@main
with:
npm_client: jlpm
github_token: ${{ secrets.GITHUB_TOKEN }}
start_server_script: 'null'
test_folder: ui-tests
9 changes: 2 additions & 7 deletions docs/source/developer/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,8 @@ Once you have installed the dependencies above, use the following steps:

git clone https://github.com/jupyterlab/jupyter-collaboration.git
cd jupyter-collaboration
# install monorepo
pip install -e ".[dev,test]"
# install local dependencies as editable
pip install -e projects/jupyter-collaboration-ui -e projects/jupyter-docprovider -e projects/jupyter-server-ydoc
# link lab extensions
jupyter labextension develop --overwrite projects/jupyter-collaboration-ui
jupyter labextension develop --overwrite projects/jupyter-docprovider
# install monorepo in dev mode
python scripts/dev_install.py


If you are using a system-wide Python installation and you only want to install the server for you,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"packages/*"
],
"scripts": {
"dev": "python scripts/dev_install.py",
"build": "lerna run build",
"build:prod": "lerna run build:prod",
"build:test": "lerna run build:test",
Expand Down
40 changes: 40 additions & 0 deletions scripts/dev_install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

import subprocess
from pathlib import Path
from typing import Optional


def execute(cmd: str, cwd: Optional[Path] = None) -> None:
subprocess.run(cmd.split(" "), check=True, cwd=cwd)


def install_dev() -> None:
install_build_deps = "python -m pip install jupyterlab>=4,<5"
install_js_deps = "jlpm install"

python_package_prefix = "projects"
python_packages = ["jupyter-collaboration-ui", "jupyter-docprovider", "jupyter-server-ydoc"]

execute(install_build_deps)
execute(install_js_deps)

for py_package in python_packages:
real_package_name = py_package.replace("-", "_")
execute(f"pip uninstall {real_package_name} -y")
execute(f"pip install -e {python_package_prefix}/{py_package}[test]")

# List of server extensions
if py_package in ["jupyter-server-ydoc"]:
execute(f"jupyter server extension enable {real_package_name}")

# List of jupyterlab extensions
if py_package in ["jupyter-collaboration-ui", "jupyter-docprovider"]:
execute(
f"jupyter labextension develop --overwrite {python_package_prefix}/{py_package} --overwrite"
)


if __name__ == "__main__":
install_dev()
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"strict": true,
"strictNullChecks": true,
"target": "es2018",
"types": []
"types": [],
"lib": ["DOM", "ES2018", "ES2020.Intl"]
}
}
2 changes: 1 addition & 1 deletion ui-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test:update": "npx playwright test --update-snapshots"
},
"devDependencies": {
"@jupyterlab/galata": "^5.1.5",
"@jupyterlab/galata": "^5.3.0",
"@jupyterlab/services": "^7.1.5",
"@playwright/test": "^1.35.0"
},
Expand Down
5 changes: 5 additions & 0 deletions ui-tests/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ module.exports = {
url: 'http://localhost:8888/lab',
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI
},
expect: {
toMatchSnapshot: {
maxDiffPixelRatio: 0.01
}
}
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions ui-tests/tests/notebook.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@
await guestPage.filebrowser.refresh();
await guestPage.notebook.open(pathUntitled);

const nbPanel = await page.notebook.getNotebookInPanel();
const nbPanel = await page.notebook.getNotebookInPanelLocator();
expect.soft(await nbPanel?.screenshot()).toMatchSnapshot(
'initialization-create-notebook-host.png'
);

const nbPanelGuest = await guestPage.notebook.getNotebookInPanel();
const nbPanelGuest = await guestPage.notebook.getNotebookInPanelLocator();
expect(await nbPanelGuest?.screenshot()).toMatchSnapshot(
'initialization-create-notebook-guest.png'
);
Expand All @@ -133,13 +133,13 @@
await guestPage.notebook.open(exampleNotebook);
await guestPage.notebook.activate(exampleNotebook);

const nbPanel = await page.notebook.getNotebookInPanel();
const nbPanel = await page.notebook.getNotebookInPanelLocator();
expect.soft(await nbPanel?.screenshot()).toMatchSnapshot(

Check failure on line 137 in ui-tests/tests/notebook.spec.ts

View workflow job for this annotation

GitHub Actions / ui_tests

tests/notebook.spec.ts:127:7 › Initialization › Open a notebook

1) tests/notebook.spec.ts:127:7 › Initialization › Open a notebook ─────────────────────────────── Error: Screenshot comparison failed: 5742 pixels (ratio 0.02 of all image pixels) are different. Expected: /home/runner/work/jupyter-collaboration/jupyter-collaboration/ui-tests/test-results/tests-notebook-Initialization-Open-a-notebook/initialization-open-notebook-host-expected.png Received: /home/runner/work/jupyter-collaboration/jupyter-collaboration/ui-tests/test-results/tests-notebook-Initialization-Open-a-notebook/initialization-open-notebook-host-actual.png Diff: /home/runner/work/jupyter-collaboration/jupyter-collaboration/ui-tests/test-results/tests-notebook-Initialization-Open-a-notebook/initialization-open-notebook-host-diff.png 135 | 136 | const nbPanel = await page.notebook.getNotebookInPanelLocator(); > 137 | expect.soft(await nbPanel?.screenshot()).toMatchSnapshot( | ^ 138 | 'initialization-open-notebook-host.png' 139 | ); 140 | at /home/runner/work/jupyter-collaboration/jupyter-collaboration/ui-tests/tests/notebook.spec.ts:137:46
'initialization-open-notebook-host.png'
);

const nbPanelGuest = await guestPage.notebook.getNotebookInPanel();
const nbPanelGuest = await guestPage.notebook.getNotebookInPanelLocator();
expect(await nbPanelGuest?.screenshot()).toMatchSnapshot(

Check failure on line 142 in ui-tests/tests/notebook.spec.ts

View workflow job for this annotation

GitHub Actions / ui_tests

tests/notebook.spec.ts:127:7 › Initialization › Open a notebook

1) tests/notebook.spec.ts:127:7 › Initialization › Open a notebook ─────────────────────────────── Error: Screenshot comparison failed: 5742 pixels (ratio 0.02 of all image pixels) are different. Expected: /home/runner/work/jupyter-collaboration/jupyter-collaboration/ui-tests/test-results/tests-notebook-Initialization-Open-a-notebook/initialization-open-notebook-guest-expected.png Received: /home/runner/work/jupyter-collaboration/jupyter-collaboration/ui-tests/test-results/tests-notebook-Initialization-Open-a-notebook/initialization-open-notebook-guest-actual.png Diff: /home/runner/work/jupyter-collaboration/jupyter-collaboration/ui-tests/test-results/tests-notebook-Initialization-Open-a-notebook/initialization-open-notebook-guest-diff.png 140 | 141 | const nbPanelGuest = await guestPage.notebook.getNotebookInPanelLocator(); > 142 | expect(await nbPanelGuest?.screenshot()).toMatchSnapshot( | ^ 143 | 'initialization-open-notebook-guest.png' 144 | ); 145 | at /home/runner/work/jupyter-collaboration/jupyter-collaboration/ui-tests/tests/notebook.spec.ts:142:46
'initialization-open-notebook-guest.png'
);

Expand Down Expand Up @@ -245,7 +245,7 @@
async () => (await page.notebook.getCellCount()) === numCells + numClients
);

const nbPanel = await page.notebook.getNotebookInPanel();
const nbPanel = await page.notebook.getNotebookInPanelLocator();
expect(await nbPanel?.screenshot()).toMatchSnapshot(
'ten-clients-add-a-new-cell.png'
);
Expand Down
Loading
Loading