Skip to content

Commit

Permalink
Merge pull request #203 from painebot/tkp/norm
Browse files Browse the repository at this point in the history
Normalize package layout with nbcelltests
  • Loading branch information
timkpaine authored Jun 4, 2024
2 parents 5da519a + 719319a commit 3fec84a
Show file tree
Hide file tree
Showing 22 changed files with 3,805 additions and 3,440 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
# TODO more later
# os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.9]
node-version: [16.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v3
Expand All @@ -42,15 +40,15 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "pyproject.toml"
cache: 'pip'
cache-dependency-path: 'pyproject.toml'

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
cache-dependency-path: yarn.lock
cache-dependency-path: js/yarn.lock

- name: Install yarn
run: npm install -g yarn
Expand Down
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"typescript.tsdk": "./js/node_modules/typescript/lib",
"eslint.workingDirectories": ["./js"]
}
3 changes: 0 additions & 3 deletions .vscode/settings.json.template

This file was deleted.

9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
DOCKER_COMPOSE := podman-compose
YARN := jlpm

###############
# Build Tools #
Expand Down Expand Up @@ -52,7 +51,7 @@ testpy: ## Clean and Make unit tests
python -m pytest -v jupyterfs/tests --junitxml=junit.xml --cov=jupyterfs --cov-report=xml:.coverage.xml --cov-branch --cov-fail-under=20 --cov-report term-missing

testjs: ## Clean and Make js tests
cd js; ${YARN} test
cd js; jlpm test

test: tests
tests: testpy testjs ## run the tests
Expand All @@ -67,15 +66,15 @@ lintpy: ## Lint Python with Ruff
python -m ruff format --check jupyterfs setup.py

lintjs: ## Lint Javascript with ESlint
cd js; ${YARN} lint
cd js; jlpm lint

lint: lintpy lintjs ## run linter

fixpy: ## Autoformat Python with Ruff
python -m ruff format jupyterfs/ setup.py

fixjs: ## Autoformat JavaScript with ESlint
cd js; ${YARN} fix
cd js; jlpm fix

fix: fixpy fixjs ## run black/tslint fix
format: fix
Expand Down Expand Up @@ -122,7 +121,7 @@ clean: ## clean the repository
find . -name ".ipynb_checkpoints" | xargs rm -rf
rm -rf .coverage coverage *.xml build dist *.egg-info lib node_modules .pytest_cache *.egg-info
rm -rf jupyterfs/labextension jupyterfs/nbextension/static/index*
cd js && ${YARN} clean
cd js && jlpm clean
git clean -fd

###########
Expand Down
9 changes: 9 additions & 0 deletions js/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
/******************************************************************************
*
* Copyright (c) 2019, the jupyter-fs authors.
*
* This file is part of the jupyter-fs library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
module.exports = {
ignorePatterns: ["lib/**", "node_modules/**", "filetree.ts", "utils.ts"],
env: {
browser: true,
es6: true,
commonjs: true,
jest: true,
},
extends: [
"eslint:recommended",
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions js/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/******************************************************************************
*
* Copyright (c) 2019, the jupyter-fs authors.
*
* This file is part of the jupyter-fs library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
module.exports = {
presets: [
[
Expand Down
25 changes: 24 additions & 1 deletion js/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
const esModules = ["@jupyter", "@jupyterlab", "@jupyter-widgets", "@lumino", "lib0", "nanoid", "y-protocols", "internmap", "delaunator", "robust-predicates", "lodash-es", "tree-finder"].join("|");
/******************************************************************************
*
* Copyright (c) 2019, the nbcelltests authors.
*
* This file is part of the nbcelltests library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
const esModules = [
"@jupyter",
"@jupyterlab",
"@jupyter-widgets",
"@lumino",
"@microsoft",
"delaunator",
"exenv-es6",
"internmap",
"lib0",
"lodash-es",
"nanoid",
"robust-predicates",
"vscode-ws-jsonrpc",
"y-protocols",
].join("|");

module.exports = {
preset: "ts-jest/presets/js-with-babel",
Expand Down
5 changes: 2 additions & 3 deletions js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@
"build:prod": "jlpm build:lib && jlpm build:labextension:prod",
"build:labextension:prod": "jupyter labextension build --source-map=True .",
"build:lib": "tsc -b",
"clean": "rimraf *junit.xml .jupyter coverage* dist lib tsconfig.tsbuildinfo",
"clean": "rimraf dist lib tsconfig.tsbuildinfo",
"clean:labextension": "rimraf ../jupyterfs/labextension",
"clean:slate": "jlpm clean && jlpm clean:labextension && rimraf node_modules",
"deduplicate": "jlpm yarn-deduplicate -s fewer ../yarn.lock || jlpm yarn-deduplicate -s fewer",
"deduplicate": "jlpm yarn-deduplicate -s fewer yarn.lock || jlpm yarn-deduplicate -s fewer",
"fix": "jlpm lint --fix",
"integrity": "jlpm install && jlpm deduplicate && jlpm install",
"lint": "eslint -c .eslintrc.js --ext .js,.ts,.tsx src/ tests/",
"postpack": "shx rm README.md",
"prepack": "shx cp ../README.md .",
"prepublishOnly": "jlpm clean && jlpm clean:labextension && jlpm integrity && jlpm build:prod",
"test": "jest --coverage",
"test:browser": "../ci/browser_check.sh",
"watch": "run-p watch:lib watch:labextension",
"watch:lib": "tsc -b -w",
"watch:labextension": "jupyter labextension watch ."
Expand Down
8 changes: 8 additions & 0 deletions js/style/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
/******************************************************************************
*
* Copyright (c) 2019, the jupyter-fs authors.
*
* This file is part of the jupyter-fs library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
import './index.css';
8 changes: 8 additions & 0 deletions js/tests/activate.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/******************************************************************************
*
* Copyright (c) 2019, the jupyter-fs authors.
*
* This file is part of the jupyter-fs library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
import "isomorphic-fetch";

import { browser, progressStatus } from "../src/index";
Expand Down
8 changes: 8 additions & 0 deletions js/tests/assetsTransformer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/******************************************************************************
*
* Copyright (c) 2019, the jupyter-fs authors.
*
* This file is part of the jupyter-fs library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
const path = require("path");

module.exports = {
Expand Down
8 changes: 8 additions & 0 deletions js/tests/export.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/******************************************************************************
*
* Copyright (c) 2019, the jupyter-fs authors.
*
* This file is part of the jupyter-fs library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
import "isomorphic-fetch";

import * as extension from "../src/index";
Expand Down
8 changes: 8 additions & 0 deletions js/tests/fileMock.js
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
/******************************************************************************
*
* Copyright (c) 2019, the jupyter-fs authors.
*
* This file is part of the jupyter-fs library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
module.exports = "test-file-stub";
8 changes: 8 additions & 0 deletions js/tests/jest-setup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/******************************************************************************
*
* Copyright (c) 2019, the jupyter-fs authors.
*
* This file is part of the jupyter-fs library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
/* eslint-disable no-undef */
//global.fetch = require("jest-fetch-mock");
const version = process.version.match(/^v((\d+)\.(\d+))/).slice(2, 4).map(v => parseInt(v));
Expand Down
8 changes: 8 additions & 0 deletions js/tests/settings.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/******************************************************************************
*
* Copyright (c) 2019, the jupyter-fs authors.
*
* This file is part of the jupyter-fs library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
import "isomorphic-fetch";

import { unpartialResource } from "../src/settings";
Expand Down
22 changes: 22 additions & 0 deletions js/tests/setup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/******************************************************************************
*
* Copyright (c) 2019, the jupyter-fs authors.
*
* This file is part of the jupyter-fs library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
Object.defineProperty(window, "DragEvent", {
value: class DragEvent {},
});

Object.defineProperty(window, "matchMedia", {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // Deprecated
removeListener: jest.fn(), // Deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});
8 changes: 8 additions & 0 deletions js/tests/snippets.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/******************************************************************************
*
* Copyright (c) 2019, the jupyter-fs authors.
*
* This file is part of the jupyter-fs library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
import "isomorphic-fetch";

import {
Expand Down
8 changes: 8 additions & 0 deletions js/tests/styleMock.js
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
/******************************************************************************
*
* Copyright (c) 2019, the jupyter-fs authors.
*
* This file is part of the jupyter-fs library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
module.exports = {};
Loading

0 comments on commit 3fec84a

Please sign in to comment.