Skip to content

Commit

Permalink
Upgrade extension to JupyterLab 4 (#145)
Browse files Browse the repository at this point in the history
* Migrate to hatch build system

Use npm_builder hook to build labextension.

Use nodejs version hook to manage extension's version

* Bump @jupyterlab deps to 4.0.0

Migrate deprecated tslint.json to eslintrc.js.

Update target in tsconfig to es2018

Lint ts src code and make changes for the src to be compatible for
Jlab 4

* Update labextension points

* Update binder env in CI workflows

* Ensure we can make editable builds

* Fix build cmd for editbale installs in pyproject

* Remove "extension" suffix from extensions name

* Remove utililies from jupyter_server rather than nb

* Enhance lint config

Add stylelint config and npm script.

Add lint:check script that checks eslint, prettier and stylelint

Lint css files according to stylelint config

* Add basic CI workflows

* Modernise async stuff and ensure token is defined

* Update README file

* Add release related workflows

The ones that are taken from jupyter_releaser repo

* Add an empty changelog file

It is needed for check release workflow to generate a draft changelog.
The workflow expects the file to exist.

* Generate a changelog from github-activity

Add missing markers in the changelog file

* Remove unnecessary step in check release workflow

* Remove unnecessary prepare script from package.json

Remove deprecated tslint related packages

* Remove reference to tslint in eslint config

* Revert version back to 3.x in package.json

jupyter-releaser will take care of version bumping
  • Loading branch information
mahendrapaipuri authored Aug 2, 2023
1 parent b9f0693 commit b711c4a
Show file tree
Hide file tree
Showing 31 changed files with 7,245 additions and 6,450 deletions.
400 changes: 388 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
28 changes: 28 additions & 0 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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: 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
Loading

0 comments on commit b711c4a

Please sign in to comment.