Skip to content

Commit

Permalink
Scaffolding for adding a npm package and setting up the releaser (#23)
Browse files Browse the repository at this point in the history
* Scaffolding for adding a npm package and setting up the releaser

* Automatic application of license header

* Fix attempt for jupyter-releaser

* Add yarn.lock

* ignore yarn.lock for license

* Set package as private for now to avoid publication and conflict with core package

* Fix pre-commit

* Fix test for pypy

* Skip npm publication for now

* Lint code

* Fix more tests

* Another try to fix pypy warning

* Fourth try

* Drop PyPy test

---------

Co-authored-by: Frédéric Collonval <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 28, 2024
1 parent 4dbb6d9 commit b779035
Show file tree
Hide file tree
Showing 20 changed files with 3,130 additions and 119 deletions.
14 changes: 14 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: v4.3.4
_src_path: https://github.com/jupyterlab/extension-template
author_email: [email protected]
author_name: Jupyter Development Team
has_binder: false
has_settings: false
kind: frontend
labextension_name: '@jupyterlab/builder'
project_short_description: Jupyter build tools.
python_name: jupyter_builder
repository: https://github.com/jupyterlab/jupyterlab-builder
test: false

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

on:
push:
branches:
- main
pull_request:
branches:
- '*'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest

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

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

- name: Install dependencies
run: python -m pip install .[test]

- name: Lint the extension
run: |
set -eux
jlpm
jlpm run lint:check
- name: Package the extension
run: |
set -eux
pip install build
python -m build
- name: Upload extension packages
uses: actions/upload-artifact@v4
with:
name: extension-artifacts
path: dist/jupyter_builder*
if-no-files-found: error

test_isolated:
needs: build
runs-on: ubuntu-latest

steps:
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
architecture: 'x64'
- uses: actions/download-artifact@v4
with:
name: extension-artifacts
- name: Install and Test
run: |
set -eux
pip install jupyter_builder*.whl
check_links:
name: Check Links
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1
30 changes: 30 additions & 0 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Check Release
on:
push:
branches: ["main"]
pull_request:
branches: ["*"]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
check_release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- 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@v4
with:
name: jupyter_builder-releaser-dist-${{ github.run_number }}
path: .jupyter_releaser_checkout/dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
post_version_spec:
description: "Post Version Specifier"
required: false
# silent:
# description: "Set a placeholder in the changelog and don't publish the release."
# required: false
# type: boolean
since:
description: "Use PRs with activity since this date or git reference"
required: false
Expand All @@ -33,9 +37,8 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
version_spec: ${{ github.event.inputs.version_spec }}
silent: ${{ github.event.inputs.silent }}
# silent: ${{ github.event.inputs.silent }}
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 }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
steps_to_skip:
description: "Comma separated list of steps to skip"
required: false
default: 'build-npm'

jobs:
publish_release:
Expand Down Expand Up @@ -38,6 +39,8 @@ jobs:

- name: Finalize Release
id: finalize-release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
uses: jupyter-server/jupyter_releaser/.github/actions/finalize-release@v2
with:
token: ${{ steps.app-token.outputs.token }}
Expand Down
19 changes: 9 additions & 10 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.12"]
include:
- os: ubuntu-latest
python-version: "pypy-3.8"
# include:
# - os: ubuntu-latest
# python-version: "pypy-3.8"
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -62,8 +62,7 @@ jobs:
-
run: pip install -e ".[test,dev]"
- name: Run the unit tests
run: |
pytest
run: pytest

test_prereleases:
name: Test Prereleases
Expand All @@ -74,10 +73,10 @@ jobs:
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
dependency_type: pre
-
run: pip install -e ".[test,dev]"
- name: Run the tests
run: |
pip install pytest
pytest
run: pytest

make_sdist:
name: Make SDist
Expand All @@ -97,8 +96,8 @@ jobs:
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- uses: jupyterlab/maintainer-tools/.github/actions/test-sdist@v1
with:
package_spec: -vv .
test_command: pip install pytest && pytest
package_spec: -vv .[test]
test_command: pytest

check_release:
runs-on: ubuntu-latest
Expand Down
74 changes: 33 additions & 41 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
*.bundle.*
lib/
node_modules/
*.log
.eslintcache
.stylelintcache
*.egg-info/
.ipynb_checkpoints
*.tsbuildinfo
# Version file is handled by hatchling
jupyter_builder/_version.py

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

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand All @@ -20,6 +36,7 @@ parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
Expand All @@ -44,6 +61,7 @@ htmlcov/
.coverage.*
.cache
nosetests.xml
coverage/
coverage.xml
*.cover
*.py,cover
Expand All @@ -55,16 +73,6 @@ cover/
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

Expand All @@ -83,36 +91,9 @@ profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
.python-version

# celery beat schedule file
celerybeat-schedule
celerybeat.pid

Expand All @@ -135,6 +116,11 @@ venv.bak/
# Rope project settings
.ropeproject

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# mkdocs documentation
/site

Expand All @@ -160,4 +146,10 @@ cython_debug/
#.idea/
junit.xml

tests/dummy/
# End of https://www.gitignore.io/api/python

# OSX files
.DS_Store

# Yarn cache
.yarn/
1 change: 1 addition & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ header:
- tsconfig.tsbuildinfo
- node_modules/**
- node_modules/.**
- 'yarn.lock'

comment: on-failure
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ repos:
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
exclude: \.copier-answers\.yml
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
Expand Down
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
**/node_modules
**/lib
**/package.json
!/package.json
jupyter_builder
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
BSD 3-Clause License

Copyright (c) 2024, JupyterLab
Copyright (c) 2024, Jupyter Development Team
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pip install jupyter_builder
```
jupyter-builder build <path to extension folder>
```
- `develop` : Install the Jupyter extension JavaScript assets in dev mode for consumption in the Jupyter app. It similar to [editable install mode of pip](https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs)
- `develop` : Install the Jupyter extension JavaScript assets in dev mode for consumption in the Jupyter app. It similar to [editable install mode of pip](https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs)
```
jupyter-builder develop --overwrite (path to extension folder)
```
Expand Down
Loading

0 comments on commit b779035

Please sign in to comment.