Skip to content

Commit b711c4a

Browse files
Upgrade extension to JupyterLab 4 (#145)
* 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
1 parent b9f0693 commit b711c4a

31 files changed

+7245
-6450
lines changed

.eslintrc.js

+388-12
Large diffs are not rendered by default.

.github/workflows/build.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
pull_request:
9+
branches:
10+
- main
11+
- master
12+
13+
defaults:
14+
run:
15+
shell: bash -l {0}
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
25+
- name: Base Setup
26+
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
27+
28+
- name: Install JupyterLab
29+
run: python -m pip install -U "jupyterlab>=4.0.0,<5"
30+
31+
- name: Lint the extension
32+
run: |
33+
set -eux
34+
jlpm
35+
jlpm run lint:check
36+
37+
- name: Build the extension
38+
run: |
39+
set -eux
40+
python -m pip install .
41+
42+
jupyter labextension list
43+
jupyter labextension list 2>&1 | grep -ie "@jupyterlab/github.*OK"
44+
45+
python -m jupyterlab.browser_check

.github/workflows/check-release.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Check Release
2+
on:
3+
push:
4+
branches: [ master, main ]
5+
pull_request:
6+
branches: ["*"]
7+
8+
jobs:
9+
check_release:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
16+
- name: Base Setup
17+
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
18+
19+
- name: Check Release
20+
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
21+
with:
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Upload Distributions
25+
uses: actions/upload-artifact@v3
26+
with:
27+
name: jupyterlab_github-releaser-dist-${{ github.run_number }}
28+
path: .jupyter_releaser_checkout/dist

.github/workflows/packaging.yml

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Packaging
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: '*'
8+
9+
env:
10+
PIP_DISABLE_PIP_VERSION_CHECK: 1
11+
12+
defaults:
13+
run:
14+
shell: bash -l {0}
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v3
23+
24+
- name: Base Setup
25+
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
26+
27+
- name: Install dependencies
28+
run: python -m pip install -U "jupyterlab>=4.0.0,<5"
29+
30+
- name: Package the extension
31+
run: |
32+
set -eux
33+
pip install build
34+
python -m build
35+
pip uninstall -y "jupyterlab_github" jupyterlab
36+
37+
- name: Upload extension packages
38+
uses: actions/upload-artifact@v3
39+
with:
40+
name: extension-artifacts
41+
path: ./dist/jupyterlab_github*
42+
if-no-files-found: error
43+
44+
install:
45+
runs-on: ${{ matrix.os }}-latest
46+
needs: [build]
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
os: [ubuntu, macos, windows]
51+
python: ['3.8', '3.11']
52+
include:
53+
- python: '3.8'
54+
dist: 'jupyterlab_github*.tar.gz'
55+
- python: '3.11'
56+
dist: 'jupyterlab_github*.whl'
57+
- os: windows
58+
py_cmd: python
59+
- os: macos
60+
py_cmd: python3
61+
- os: ubuntu
62+
py_cmd: python
63+
64+
steps:
65+
- name: Install Python
66+
uses: actions/setup-python@v4
67+
with:
68+
python-version: ${{ matrix.python }}
69+
architecture: 'x64'
70+
71+
- uses: actions/download-artifact@v3
72+
with:
73+
name: extension-artifacts
74+
path: ./dist
75+
76+
- name: Install prerequisites
77+
run: |
78+
${{ matrix.py_cmd }} -m pip install pip wheel
79+
80+
- name: Install package
81+
run: |
82+
cd dist
83+
${{ matrix.py_cmd }} -m pip install -vv ${{ matrix.dist }}
84+
85+
- name: Validate environment
86+
run: |
87+
${{ matrix.py_cmd }} -m pip freeze
88+
${{ matrix.py_cmd }} -m pip check
89+
90+
- name: Validate install
91+
run: |
92+
jupyter labextension list
93+
jupyter labextension list 2>&1 | grep -ie "@jupyterlab/github.*OK"

.github/workflows/prep-release.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: "Step 1: Prep Release"
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version_spec:
6+
description: "New Version Specifier"
7+
default: "next"
8+
required: false
9+
branch:
10+
description: "The branch to target"
11+
required: false
12+
post_version_spec:
13+
description: "Post Version Specifier"
14+
required: false
15+
since:
16+
description: "Use PRs with activity since this date or git reference"
17+
required: false
18+
since_last_stable:
19+
description: "Use PRs with activity since the last stable git tag"
20+
required: false
21+
type: boolean
22+
jobs:
23+
prep_release:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
27+
28+
- name: Prep Release
29+
id: prep-release
30+
uses: jupyter-server/jupyter_releaser/.github/actions/prep-release@v2
31+
with:
32+
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
33+
version_spec: ${{ github.event.inputs.version_spec }}
34+
post_version_spec: ${{ github.event.inputs.post_version_spec }}
35+
target: ${{ github.event.inputs.target }}
36+
branch: ${{ github.event.inputs.branch }}
37+
since: ${{ github.event.inputs.since }}
38+
since_last_stable: ${{ github.event.inputs.since_last_stable }}
39+
40+
- name: "** Next Step **"
41+
run: |
42+
echo "Optional): Review Draft Release: ${{ steps.prep-release.outputs.release_url }}"

.github/workflows/publish-release.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: "Step 2: Publish Release"
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
branch:
6+
description: "The target branch"
7+
required: false
8+
release_url:
9+
description: "The URL of the draft GitHub release"
10+
required: false
11+
steps_to_skip:
12+
description: "Comma separated list of steps to skip"
13+
required: false
14+
default: "ensure-sha"
15+
16+
jobs:
17+
publish_release:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
21+
22+
- name: Populate Release
23+
id: populate-release
24+
uses: jupyter-server/jupyter_releaser/.github/actions/populate-release@v2
25+
with:
26+
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
27+
target: ${{ github.event.inputs.target }}
28+
branch: ${{ github.event.inputs.branch }}
29+
release_url: ${{ github.event.inputs.release_url }}
30+
steps_to_skip: ${{ github.event.inputs.steps_to_skip }}
31+
32+
- name: Finalize Release
33+
id: finalize-release
34+
env:
35+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
36+
PYPI_TOKEN_MAP: ${{ secrets.PYPI_TOKEN_MAP }}
37+
TWINE_USERNAME: __token__
38+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
39+
uses: jupyter-server/jupyter-releaser/.github/actions/finalize-release@v2
40+
with:
41+
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
42+
target: ${{ github.event.inputs.target }}
43+
release_url: ${{ steps.populate-release.outputs.release_url }}
44+
45+
- name: "** Next Step **"
46+
if: ${{ success() }}
47+
run: |
48+
echo "Verify the final release"
49+
echo ${{ steps.finalize-release.outputs.release_url }}
50+
51+
- name: "** Failure Message **"
52+
if: ${{ failure() }}
53+
run: |
54+
echo "Failed to Publish the Draft Release Url:"
55+
echo ${{ steps.populate-release.outputs.release_url }}

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ node_modules/
1111
.ipynb_checkpoints/
1212
npm-debug.log
1313
package-lock.json
14-
14+
.yarn
1515
*.tsbuildinfo
16+
*.stylelintcache
1617
jupyterlab_github/labextension
1718

19+
# Version file handled by hatch
20+
jupyterlab_github/_version.py
21+
1822
# Created by https://www.gitignore.io/api/python
1923
# Edit at https://www.gitignore.io/?templates=python
2024

.stylelintrc

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": [
3+
"stylelint-config-recommended",
4+
"stylelint-config-standard",
5+
"stylelint-prettier/recommended"
6+
],
7+
"rules": {
8+
"no-empty-source": null,
9+
"selector-class-pattern": null,
10+
"property-no-vendor-prefix": null,
11+
"selector-no-vendor-prefix": null,
12+
"value-no-vendor-prefix": null
13+
}
14+
}

.yarnrc.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
nodeLinker: node-modules
2+
enableImmutableInstalls: false

0 commit comments

Comments
 (0)