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

[test] jlab3 + ci updates #3

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ node_modules
dist
coverage
**/*.d.ts
tests
lib
13 changes: 10 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@ module.exports = {
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
project: 'tsconfig.eslint.json',
sourceType: 'module'
},
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/interface-name-prefix': [
'@typescript-eslint/naming-convention': [
'error',
{ prefixWithI: 'always' }
{
'selector': 'interface',
'format': ['PascalCase'],
'custom': {
'regex': '^I[A-Z]',
'match': true
}
}
],
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
'@typescript-eslint/no-explicit-any': 'off',
Expand Down
54 changes: 14 additions & 40 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI

on:
push:
branches: [master, next]
branches: [master, 2.x]
pull_request:
branches: '*'
branches: [master, 2.x]

env:
CACHE_EPOCH: 1
Expand All @@ -18,7 +18,7 @@ jobs:
os: [ubuntu]
python-version: [3.9]
node-version: [14.x]
lab-version: [2]
lab-version: [3]

steps:
- name: Checkout
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
- name: Collect JS Distribution
run: |
set -eux
cp jupyterlab_pullrequests/labextension/*.tgz dist
cd dist && npm pack ..

- name: Hash Distributions
run: |
Expand All @@ -104,7 +104,7 @@ jobs:
os: [ubuntu]
python-version: [3.9]
node-version: [14.x]
lab-version: [2]
lab-version: [3]

steps:
- name: Checkout
Expand Down Expand Up @@ -167,8 +167,8 @@ jobs:
set -eux
python -m pytest --pyargs jupyterlab_pullrequests --cov jupyterlab_pullrequests --cov-report term-missing:skip-covered --no-cov-on-fail

- name: Unit Test JS (known to be broken)
run: jlpm test || echo "TODO"
- name: Unit Test JS
run: jlpm test

- name: Upload Coverage
run: codecov
Expand All @@ -183,8 +183,7 @@ jobs:
matrix:
os: [ubuntu, macos, windows]
python-version: [3.6, 3.9, pypy3]
node-version: [10.x, 14.x]
lab-version: [2]
lab-version: [3]
include:
# cover artifacts
- python-version: 3.6
Expand All @@ -207,13 +206,6 @@ jobs:
# not supported
- os: windows
python-version: pypy3
# don't need the full node/py matrix
- python-version: 3.6
node-version: 14.x
- python-version: 3.9
node-version: 10.x
- python-version: pypy3
node-version: 10.x

defaults:
run:
Expand Down Expand Up @@ -263,38 +255,24 @@ jobs:
run: ${{ matrix.py-cmd }} -m pip check

- name: List Server Extensions
run: jupyter serverextension list > serverextensions.txt 2>&1
run: |
jupyter serverextension list > serverextensions.txt 2>&1
jupyter server extension list > server_extensions.txt 2>&1

- name: Validate Server Extension
shell: bash -l {0}
run: |
cat serverextensions.txt
cat serverextensions.txt | grep -ie "jupyterlab_pullrequests.*enabled"
cat server_extensions.txt
cat server_extensions.txt | grep -ie "jupyterlab_pullrequests.*enabled"

- name: Install Python Test Dependencies
run: ${{ matrix.py-cmd }} -m pip install "mock>=4.0.0" pytest-asyncio pytest diff-match-patch
run: ${{ matrix.py-cmd }} -m pip install "mock>=4.0.0" pytest-asyncio pytest-tornasync diff-match-patch

- name: Unit Test Server Extension
run: ${{ matrix.py-cmd }} -m pytest --pyargs jupyterlab_pullrequests -vv

- name: Install NodeJS
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: List JupyterLab Extensions
run: ${{ matrix.py-cmd }} -m jupyter labextension list > labextensions.txt 2>&1

- name: Check JupyterLab Preconditions
shell: bash -l {0}
run: |
cat labextensions.txt
cat labextensions.txt | grep -ie "jupyterlab/pullrequests.*enabled.*OK"
cat labextensions.txt | grep "jupyterlab/pullrequests needs to be included in build"

- name: Rebuild JupyterLab
run: ${{ matrix.py-cmd }} -m jupyter lab build --debug

- name: List JupyterLab Extensions
run: ${{ matrix.py-cmd }} -m jupyter labextension list > labextensions.txt 2>&1

Expand All @@ -304,7 +282,3 @@ jobs:
cat labextensions.txt
cat labextensions.txt | grep -ie "jupyterlab/pullrequests.*enabled.*OK"
cat labextensions.txt | grep -v "jupyterlab/pullrequests needs to be included in build"

- name: Run JupyterLab Browser Check
if: ${{ matrix.os != 'windows' && matrix.python-version != '3.6' }}
run: ${{ matrix.py-cmd }} -m jupyterlab.browser_check
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ node_modules/
*.egg-info/
.ipynb_checkpoints
*.tsbuildinfo
jupyterlab_pullrequests/labextension

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

Expand Down Expand Up @@ -116,3 +116,4 @@ dmypy.json
.pytest_cache/

.DS_Store
coverage/
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
**/node_modules
**/lib
**/package.json
jupyterlab_pullrequests
4 changes: 3 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"singleQuote": true
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid"
}
19 changes: 11 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,25 @@ The goal is to be transparent about these, so that anyone can see how to partici

If you have suggestions on how these processes can be improved, please suggest that (see "Enhancement Request" below)!

## Install
### Install

For a development install, do the following in the repository directory:

```bash
# Install dependencies
pip install -e .[dev] --ignore-installed
# Install NodeJS dependencies
jlpm
# Build the Lab Extension
jlpm build
# Activate the server extension
jupyter serverextension enable --sys-prefix --py jupyterlab_pullrequests
# Install package in development mode
pip install -e .
# Link your development version of the extension with JupyterLab
jupyter labextension install .
jupyter labextension develop . --overwrite
```

To rebuild the extension:

```bash
jlpm run build
```

## Build
Expand All @@ -33,7 +37,6 @@ To rebuild the frontend and your JupyterLab app:

```bash
jlpm run build
jupyter lab build
```

## Live Development
Expand All @@ -47,7 +50,7 @@ jlpm watch
In another terminal start:

```bash
jupyter lab --watch
jupyter lab
```

## Releasing
Expand Down
10 changes: 4 additions & 6 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
include LICENSE
include README.md
include pyproject.toml

include jupyter-config/jupyterlab_pullrequests.json

include package.json
include ts*.json
include jupyterlab_pullrequests/labextension/*.tgz
recursive-include jupyterlab_pullrequests/tests *.json

recursive-include jupyterlab_pullrequests/labextension *
exclude jupyterlab_pullrequests/labextension/build_log.json

# Javascript files
graft src
graft style
prune src
prune style
prune **/node_modules
prune lib

Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ For now, it supports GitHub and GitLab providers.

## Prerequisites

- JupyterLab 2.x
- nbdime 2.x
- JupyterLab 3.x
- for JupyterLab 2.x, see the `2.x` branch
- nbdime 2.x

> For GitLab, you will need also `diff-match-patch`

Expand All @@ -30,14 +31,12 @@ With pip:

```bash
pip install jupyterlab-pullrequests
jupyter lab build
```

Or with conda:

```bash
conda install -c conda-forge jupyterlab-pullrequests
jupyter lab build
```


Expand Down
5 changes: 5 additions & 0 deletions install.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"packageManager": "python",
"packageName": "jupyterlab-pullrequests",
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab-pullrequests"
}
9 changes: 6 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ const {
} = jlabConfig;

module.exports = {
coverageDirectory,
moduleFileExtensions,
moduleNameMapper: {...moduleNameMapper, "monaco-editor": "<rootDir>/node_modules/react-monaco-editor"},
moduleNameMapper,
preset,
setupFilesAfterEnv,
setupFiles,
testPathIgnorePatterns,
transform,
automock: false,
collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/*.d.ts'],
coverageDirectory: 'coverage',
coverageReporters: ['lcov', 'text'],
reporters: ['default'],
testRegex: 'src/tests/.*.spec.ts[x]?$',
transformIgnorePatterns: ['/node_modules/(?!(@?jupyterlab.*)/)'],
transformIgnorePatterns: ['/node_modules/(?!(@?jupyterlab.*|react-spinners)/)'],
setupFiles: ['<rootDir>/setupJest.js'],
globals: {
'ts-jest': {
Expand Down
7 changes: 7 additions & 0 deletions jupyter-config/jupyterlab_pullrequests_server.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ServerApp": {
"jpserver_extensions": {
"jupyterlab_pullrequests": true
}
}
}
17 changes: 10 additions & 7 deletions jupyterlab_pullrequests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
from ._version import __version__
from ._version import __version__, __js__

def _jupyter_labextension_paths():
return [{"src": "labextension", "dest": __js__["name"]}]

def _jupyter_server_extension_paths():

def _jupyter_server_extension_points():
return [{"module": "jupyterlab_pullrequests"}]


def load_jupyter_server_extension(lab_app):
def _load_jupyter_server_extension(server_app):
"""Registers the API handler to receive HTTP requests from the frontend extension.

Parameters
----------
lab_app: jupyterlab.labapp.LabApp
server_app: jupyterlab.labapp.LabApp
JupyterLab application instance
"""
from .base import PRConfig
from .handlers import setup_handlers

config = PRConfig(config=lab_app.config)
setup_handlers(lab_app.web_app, config)
lab_app.log.info("Registered jupyterlab_pullrequests extension")
config = PRConfig(config=server_app.config)
setup_handlers(server_app.web_app, config)
server_app.log.info("Registered jupyterlab_pullrequests extension")
8 changes: 7 additions & 1 deletion jupyterlab_pullrequests/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
__version__ = "2.0.0"
""" read single source of truth from shipped labextension's package.json
"""
import json
from pathlib import Path

__js__ = json.loads((Path(__file__).parent / "labextension/package.json").read_text())
__version__ = __js__["version"]
1 change: 1 addition & 0 deletions jupyterlab_pullrequests/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest_plugins = ["jupyter_server.pytest_plugin"]
19 changes: 19 additions & 0 deletions jupyterlab_pullrequests/tests/test_extensions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from tornado.web import Application

from .. import (
_jupyter_labextension_paths,
_jupyter_server_extension_points,
_load_jupyter_server_extension,
)


def test_labextension():
assert len(_jupyter_labextension_paths()) == 1


def test_server_extension():
assert len(_jupyter_server_extension_points()) == 1


def test_load_extension(jp_serverapp):
_load_jupyter_server_extension(jp_serverapp)
Loading