Skip to content

Upgrade extension to JupyterLab 4 #145

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

Merged
merged 19 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from 13 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
401 changes: 389 additions & 12 deletions .eslintrc.js

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build

on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

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

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

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

- name: Install JupyterLab
run: python -m pip install -U "jupyterlab>=4.0.0,<5"

- name: Lint the extension
run: |
set -eux
jlpm
jlpm run lint:check

- name: Build the extension
run: |
set -eux
python -m pip install .

jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "@jupyterlab/github.*OK"

python -m jupyterlab.browser_check
32 changes: 32 additions & 0 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Check Release
on:
push:
branches: [ master, main ]
pull_request:
branches: ["*"]

jobs:
check_release:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

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

- name: Install Dependencies
run: |
pip install -e .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally we shouldn't need this as it might add side-effects, and this step does not exist during the actual release process.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Maybe we should remove it from the extension-template repo as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah if it's there then yes 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is in the template. I have not changed anything from the template except replacing Jinja2 vars.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


- name: Check Release
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Distributions
uses: actions/upload-artifact@v3
with:
name: jupyterlab_github-releaser-dist-${{ github.run_number }}
path: .jupyter_releaser_checkout/dist
93 changes: 93 additions & 0 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Packaging

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

env:
PIP_DISABLE_PIP_VERSION_CHECK: 1

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

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

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

- name: Install dependencies
run: python -m pip install -U "jupyterlab>=4.0.0,<5"

- name: Package the extension
run: |
set -eux
pip install build
python -m build
pip uninstall -y "jupyterlab_github" jupyterlab

- name: Upload extension packages
uses: actions/upload-artifact@v3
with:
name: extension-artifacts
path: ./dist/jupyterlab_github*
if-no-files-found: error

install:
runs-on: ${{ matrix.os }}-latest
needs: [build]
strategy:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
python: ['3.8', '3.11']
include:
- python: '3.8'
dist: 'jupyterlab_github*.tar.gz'
- python: '3.11'
dist: 'jupyterlab_github*.whl'
- os: windows
py_cmd: python
- os: macos
py_cmd: python3
- os: ubuntu
py_cmd: python

steps:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: 'x64'

- uses: actions/download-artifact@v3
with:
name: extension-artifacts
path: ./dist

- name: Install prerequisites
run: |
${{ matrix.py_cmd }} -m pip install pip wheel

- name: Install package
run: |
cd dist
${{ matrix.py_cmd }} -m pip install -vv ${{ matrix.dist }}

- name: Validate environment
run: |
${{ matrix.py_cmd }} -m pip freeze
${{ matrix.py_cmd }} -m pip check

- name: Validate install
run: |
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "@jupyterlab/github.*OK"
42 changes: 42 additions & 0 deletions .github/workflows/prep-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: "Step 1: Prep Release"
on:
workflow_dispatch:
inputs:
version_spec:
description: "New Version Specifier"
default: "next"
required: false
branch:
description: "The branch to target"
required: false
post_version_spec:
description: "Post Version Specifier"
required: false
since:
description: "Use PRs with activity since this date or git reference"
required: false
since_last_stable:
description: "Use PRs with activity since the last stable git tag"
required: false
type: boolean
jobs:
prep_release:
runs-on: ubuntu-latest
steps:
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Prep Release
id: prep-release
uses: jupyter-server/jupyter_releaser/.github/actions/prep-release@v2
with:
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
version_spec: ${{ github.event.inputs.version_spec }}
post_version_spec: ${{ github.event.inputs.post_version_spec }}
target: ${{ github.event.inputs.target }}
branch: ${{ github.event.inputs.branch }}
since: ${{ github.event.inputs.since }}
since_last_stable: ${{ github.event.inputs.since_last_stable }}

- name: "** Next Step **"
run: |
echo "Optional): Review Draft Release: ${{ steps.prep-release.outputs.release_url }}"
55 changes: 55 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: "Step 2: Publish Release"
on:
workflow_dispatch:
inputs:
branch:
description: "The target branch"
required: false
release_url:
description: "The URL of the draft GitHub release"
required: false
steps_to_skip:
description: "Comma separated list of steps to skip"
required: false
default: "ensure-sha"

jobs:
publish_release:
runs-on: ubuntu-latest
steps:
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Populate Release
id: populate-release
uses: jupyter-server/jupyter_releaser/.github/actions/populate-release@v2
with:
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
target: ${{ github.event.inputs.target }}
branch: ${{ github.event.inputs.branch }}
release_url: ${{ github.event.inputs.release_url }}
steps_to_skip: ${{ github.event.inputs.steps_to_skip }}

- name: Finalize Release
id: finalize-release
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
PYPI_TOKEN_MAP: ${{ secrets.PYPI_TOKEN_MAP }}
TWINE_USERNAME: __token__
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
uses: jupyter-server/jupyter-releaser/.github/actions/finalize-release@v2
with:
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
target: ${{ github.event.inputs.target }}
release_url: ${{ steps.populate-release.outputs.release_url }}

- name: "** Next Step **"
if: ${{ success() }}
run: |
echo "Verify the final release"
echo ${{ steps.finalize-release.outputs.release_url }}

- name: "** Failure Message **"
if: ${{ failure() }}
run: |
echo "Failed to Publish the Draft Release Url:"
echo ${{ steps.populate-release.outputs.release_url }}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ node_modules/
.ipynb_checkpoints/
npm-debug.log
package-lock.json

.yarn
*.tsbuildinfo
*.stylelintcache
jupyterlab_github/labextension

# Version file handled by hatch
jupyterlab_github/_version.py

# Created by https://www.gitignore.io/api/python
# Edit at https://www.gitignore.io/?templates=python

Expand Down
14 changes: 14 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": [
"stylelint-config-recommended",
"stylelint-config-standard",
"stylelint-prettier/recommended"
],
"rules": {
"no-empty-source": null,
"selector-class-pattern": null,
"property-no-vendor-prefix": null,
"selector-no-vendor-prefix": null,
"value-no-vendor-prefix": null
}
}
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nodeLinker: node-modules
enableImmutableInstalls: false
25 changes: 0 additions & 25 deletions MANIFEST.in

This file was deleted.

18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ This process is described in the [installation](#Installation) section.

## Prerequisites

- JupyterLab 3.0
- JupyterLab > 3.0
- A GitHub account for the server extension

## Installation

As discussed above, this extension has both a server extension and a lab extension.
Both extensions will be installed by default when installing from PyPI, but you may
have only lab extension installed if you used the Extension Manager in JupyterLab 3.x.
have only lab extension installed if you used the Extension Manager in JupyterLab.

We recommend completing the steps described below as to not be rate-limited.
The purpose of the server extension is to add GitHub credentials that you will need to acquire
Expand All @@ -57,12 +57,22 @@ For JupyterLab version older than 3 please see the instructions on the

### 1. Installing both server and prebuilt lab extension

#### JupyterLab 4.x

To install the both the server extension and (prebuilt) lab extension, enter the following in your terminal:

```bash
pip install jupyterlab-github
```

#### JupyterLab 3.x

We need to pin the extension version to `3.0.1` for making it work on the JupyterLab 3.x.

```bash
pip install 'jupyterlab-github==3.0.1'
```

After restarting JupyterLab, the extension should work, and you can experience
the joys of being rate-limited first-hand!

Expand Down Expand Up @@ -111,7 +121,7 @@ _Do not_ share this value online, as people may be able to use it to impersonate
### 3. Enabling and configuring the server extension

The server extension will be enabled by default on new JupyterLab installations
if you installed it with pip. If you used Extension Manager in JupyterLab 3.x,
if you installed it with pip. If you used Extension Manager in JupyterLab,
please uninstall the extension and install it again with the instructions from point (1).

Confirm that the server extension is installed and enabled with:
Expand All @@ -124,7 +134,7 @@ you should see the following:

```
- Validating jupyterlab_github...
jupyterlab_github 3.0.0 OK
jupyterlab_github 4.0.0 OK
```

On some older installations (e.g. old JupyterHub versions) which use jupyter
Expand Down
Loading