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

Adapt to level config to match other Jupyter repos #237

Merged
merged 14 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
# Python
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
51 changes: 24 additions & 27 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
name: tests

on: [push, pull_request]
on:
push:
branches: ["main"]
pull_request:
schedule:
- cron: "0 8 * * *"

jobs:

pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v3
with:
python-version: 3.8
- uses: pre-commit/action@v2.0.0
- uses: actions/checkout@v4
- uses: actions/setup-python@v3
with:
python-version: "3.10"
- uses: pre-commit/action@v2.0.0

tests:

strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", " 3.12"]
Expand All @@ -28,21 +31,18 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python -m bash_kernel.install # For testing a non-standard kernel
pip install .
- name: Install dependencies
run: |
python -m pip install --upgrade pip hatch

- name: Run tests
run: pytest
- name: Run tests
run: hatch run test:test -x

docs:
runs-on: ubuntu-latest
Expand All @@ -51,16 +51,13 @@ jobs:
- uses: actions/setup-python@v3
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install .
python -m pip install --upgrade pip hatch

- name: Build docs
run: |
cd doc
make html-strict
hatch run doc:build

publish:

name: Publish to PyPi
needs: [tests]
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.tox/
.venv
*.py[cod]

# Packages
Expand Down
86 changes: 69 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,76 @@
ci:
autoupdate_schedule: monthly
autoupdate_commit_msg: "chore: update pre-commit hooks"

repos:
- repo: "https://github.com/pre-commit/pre-commit-hooks"
rev: v4.3.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: check-case-conflict
12rambau marked this conversation as resolved.
Show resolved Hide resolved
- id: check-ast
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-json
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- repo: "https://github.com/pycqa/flake8/"
rev: 3.9.2
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.1
hooks:
- id: check-github-workflows

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: mdformat

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.3"
hooks:
- id: prettier
types_or: [yaml, html, json]

- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
hooks:
- id: blacken-docs
additional_dependencies: [black==23.7.0]
exclude: |
(?x)^(
doc/source/index.rst|
tests/test_execute.py
)$(|)

- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
hooks:
- id: flake8
- repo: "https://github.com/ambv/black"
rev: 22.3.0
- id: codespell
args: ["-L", "sur,nd"]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.10.0"
hooks:
- id: black
language_version: python3
- repo: "https://github.com/PyCQA/isort"
rev: 5.12.0
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.5
hooks:
- id: isort
- repo: https://github.com/asottile/pyupgrade
rev: v2.34.0
- id: ruff
types_or: [python, jupyter]
args: ["--fix", "--show-fixes"]
- id: ruff-format
types_or: [python, jupyter]

- repo: https://github.com/scientific-python/cookie
rev: "2023.10.27"
hooks:
- id: pyupgrade
args: ["--py36-plus"]
- id: sp-repo-review
additional_dependencies: ["repo-review[cli]"]
6 changes: 5 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ sphinx:
configuration: doc/source/conf.py
python:
install:
- requirements: requirements.txt
# install itself with pip install .
- method: pip
path: .
extra_requirements:
- doc
138 changes: 138 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# General Jupyter contributor guidelines

If you're reading this section, you're probably interested in
contributing to Jupyter. Welcome and thanks for your interest in
contributing!

Please take a look at the Contributor documentation, familiarize
yourself with using the Jupyter Server, and introduce yourself on the
mailing list and share what area of the project you are interested in
working on.

For general documentation about contributing to Jupyter projects, see
the [Project Jupyter Contributor
Documentation](https://jupyter.readthedocs.io/en/latest/contributing/content-contributor.html).

# Setting Up a Development Environment

## Installing the Jupyter Server

The development version of the server requires
[node](https://nodejs.org/en/download/) and
[pip](https://pip.pypa.io/en/stable/installing/).

Once you have installed the dependencies mentioned above, use the
following steps:

```
pip install --upgrade pip
git clone https://github.com/jupyter/jupyter-sphinx
cd jupyter-server
pip install -e ".[test]"
```

## Code Styling and Quality Checks

`jupyter-sphinx` has adopted automatic code formatting so you shouldn't
need to worry too much about your code style. As long as your code is
valid, the pre-commit hook should take care of how it should look.
`pre-commit` and its associated hooks will automatically be installed
when you run `pip install -e ".[test]"`

To install `pre-commit` hook manually, run the following:

```
pre-commit install
```

You can invoke the pre-commit hook by hand at any time with:

```
pre-commit run
```

which should run any autoformatting on your code and tell you about any
errors it couldn't fix automatically. You may also install [black
integration](https://github.com/psf/black#editor-integration) into your
text editor to format code automatically.

If you have already committed files before setting up the pre-commit
hook with `pre-commit install`, you can fix everything up using
`pre-commit run --all-files`. You need to make the fixing commit
yourself after that.

Some of the hooks only run on CI by default, but you can invoke them by
running with the `--hook-stage manual` argument.

There are three hatch scripts that can be run locally as well:
`hatch run lint:build` will enforce styling.

# Running Tests

Install dependencies:

```
pip install -e .[test]
```

To run the Python tests, use:

```
pytest
```

You can also run the tests using `hatch` without installing test
dependencies in your local environment:

```
pip install hatch
hatch run test:test
```

The command takes any argument that you can give to `pytest`, e.g.:

```
hatch run test:test -k name_of_method_to_test
```

You can also drop into a shell in the test environment by running:

```
hatch -e test shell
```

# Building the Docs

Install the docs requirements using `pip`:

```
pip install .[doc]
```

Once you have installed the required packages, you can build the docs
with:

```
cd docs
make html
```

You can also run the tests using `hatch` without installing test
dependencies in your local environment.

```bash
pip install hatch
hatch run docs:build
```

You can also drop into a shell in the docs environment by running:

```
hatch -e docs shell
```

After that, the generated HTML files will be available at
`build/html/index.html`. You may view the docs in your browser.

You should also have a look at the [Project Jupyter Documentation
Guide](https://jupyter.readthedocs.io/en/latest/contributing/content-contributor.html).
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Jupyter Sphinx Extensions

``jupyter-sphinx`` enables running code embedded in Sphinx documentation and
`jupyter-sphinx` enables running code embedded in Sphinx documentation and
embedding output of that code into the resulting document. It has support
for rich output such as images and even Jupyter interactive widgets.

Expand All @@ -23,7 +23,6 @@ conda install jupyter_sphinx -c conda-forge
You can check out the documentation on https://jupyter-sphinx.readthedocs.io for up to date
usage information and examples.


## License

We use a shared copyright model that enables all contributors to maintain the
Expand Down