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

maint: req py36+ and jh 1.5.1+, fix tests, add RELEASE.md, add pre-commit hooks, add dependabot #273

Merged
merged 18 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
16 changes: 7 additions & 9 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# flake8 is used for linting Python code setup to automatically run with
# pre-commit.
#
# ref: https://flake8.pycqa.org/en/latest/user/configuration.html
#
[flake8]
# Ignore style and complexity
# E: style errors
# W: style warnings
# C: complexity
# F401: module imported but unused
# F403: import *
# F811: redefinition of unused `name` from line `N`
# F841: local variable assigned but never used
# E402: module level import not at top of file
# I100: Import statements are in the wrong order
# I101: Imported names are in the wrong order. Should be
ignore = E, W, C, F401, F403, F811, F841, E402, I100, I101, D400
# D: docstring warnings (unused pydocstyle extension)
ignore = E, C, W, D
16 changes: 16 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# dependabot.yaml reference: https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
#
# Notes:
# - Status and logs from dependabot are provided at
# https://github.com/jupyterhub/tmpauthenticator/network/updates.
#
version: 2
updates:
# Maintain dependencies in our GitHub Workflows
- package-ecosystem: github-actions
directory: /
labels: [ci]
schedule:
interval: monthly
time: "05:00"
timezone: Etc/UTC
79 changes: 79 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# This is a GitHub workflow defining a set of jobs with a set of steps.
# ref: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
#
name: Test

on:
pull_request:
paths-ignore:
- "**.md"
- ".github/workflows/*.yaml"
- "!.github/workflows/test.yaml"
push:
paths-ignore:
- "**.md"
- ".github/workflows/*.yaml"
- "!.github/workflows/test.yaml"
branches-ignore:
- "dependabot/**"
- "pre-commit-ci-update-config"
tags: ["**"]
workflow_dispatch:

jobs:
pytest:
name: Run pytest
runs-on: ${{ matrix.runs-on || 'ubuntu-22.04' }}

strategy:
fail-fast: false
matrix:
include:
# test oldest supported version
- python-version: "3.6"
pip-install-spec: "jupyterhub==1.5.1 sqlalchemy==1.*"
runs-on: ubuntu-20.04 # python 3.6 is only available in 20.04

- python-version: "3.7"
pip-install-spec: "jupyterhub==2.* sqlalchemy==1.*"
- python-version: "3.8"
pip-install-spec: "jupyterhub==3.*"
- python-version: "3.10"
pip-install-spec: "jupyterhub==4.*"
- python-version: "3.11"
pip-install-spec: "jupyterhub==4.*"

# test unreleased jupyterhub, failures tolerated
- python-version: "3.X"
pip-install-spec: "git+https://github.com/jupyterhub/jupyterhub"
allow-failure: true

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18"
- uses: actions/setup-python@v4
with:
python-version: "${{ matrix.python-version }}"

- name: Install Node dependencies
run: |
npm install -g configurable-http-proxy

- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install ${{ matrix.pip-install-spec }}
pip install -e ".[test]"

- name: List dependencies
run: |
pip freeze

- name: pytest
run: |
pytest

# GitHub action reference: https://github.com/codecov/codecov-action
- uses: codecov/codecov-action@v3
88 changes: 0 additions & 88 deletions .github/workflows/test.yml

This file was deleted.

30 changes: 23 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,34 @@
# - Register git hooks: pre-commit install --install-hooks
#
repos:
# Autoformat: Python code, syntax patterns are modernized
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.2
hooks:
- id: pyupgrade
args:
- --py38-plus

# Autoformat: Python code
- repo: https://github.com/PyCQA/autoflake
rev: v2.1.1
hooks:
- id: autoflake
# args ref: https://github.com/PyCQA/autoflake#advanced-usage
args:
- --in-place

# Autoformat: Python code
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort

# Autoformat: Python code
- repo: https://github.com/psf/black
rev: "23.3.0"
hooks:
- id: black
args:
- --target-version=py36
- --target-version=py37
- --target-version=py38
- --target-version=py39
- --target-version=py310
- --target-version=py311

# Autoformat: markdown, yaml
- repo: https://github.com/pre-commit/mirrors-prettier
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
include *.md
include LICENSE
include version.py
include requirements.txt
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# batchspawner for Jupyterhub

[![GitHub Workflow Status - Test](https://img.shields.io/github/workflow/status/jupyterhub/batchspawner/Test?logo=github&label=tests)](https://github.com/jupyterhub/batchspawner/actions)
[![Latest PyPI version](https://img.shields.io/pypi/v/batchspawner?logo=pypi&logoColor=white)](https://pypi.python.org/pypi/batchspawner)
[![GitHub](https://img.shields.io/badge/issue_tracking-github-blue?logo=github)](https://github.com/jupyterhub/batchspawner/issues)
[![Discourse](https://img.shields.io/badge/help_forum-discourse-blue?logo=discourse)](https://discourse.jupyter.org/c/jupyterhub)
[![Gitter](https://img.shields.io/badge/social_chat-gitter-blue?logo=gitter)](https://gitter.im/jupyterhub/jupyterhub)
[![Latest PyPI version](https://img.shields.io/pypi/v/batchspawner?logo=pypi)](https://pypi.python.org/pypi/batchspawner)
[![Latest conda-forge version](https://img.shields.io/conda/vn/conda-forge/batchspawner?logo=conda-forge)](https://anaconda.org/conda-forge/batchspawner)
[![GitHub Workflow Status - Test](https://img.shields.io/github/actions/workflow/status/jupyterhub/batchspawner/test.yaml?logo=github&label=tests)](https://github.com/jupyterhub/batchspawner/actions)
[![Test coverage of code](https://codecov.io/gh/jupyterhub/batchspawner/branch/main/graph/badge.svg)](https://codecov.io/gh/jupyterhub/batchspawner)
[![Issue tracking - GitHub](https://img.shields.io/badge/issue_tracking-github-blue?logo=github)](https://github.com/jupyterhub/batchspawner/issues)
[![Help forum - Discourse](https://img.shields.io/badge/help_forum-discourse-blue?logo=discourse)](https://discourse.jupyter.org/c/jupyterhub)
[![Contribute](https://img.shields.io/badge/I_want_to_contribute!-grey?logo=jupyter)](https://github.com/jupyterhub/batchspawner/blob/master/CONTRIBUTING.md)

This is a custom spawner for [Jupyterhub](https://jupyterhub.readthedocs.io/) that is designed for installations on clusters using batch scheduling software.
Expand Down
60 changes: 60 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# How to make a release

`batchspawner` is a package available on [PyPI] and on [conda-forge].

These are the instructions on how to make a release.

## Pre-requisites

- Push rights to this GitHub repository

## Steps to make a release

1. Create a PR updating `CHANGELOG.md` with [github-activity] and continue when
its merged.

Advice on this procedure can be found in [this team compass
issue](https://github.com/jupyterhub/team-compass/issues/563).

2. Checkout main and make sure it is up to date.

```shell
git checkout main
git fetch origin main
git reset --hard origin/main
```

3. Update the version, make commits, and push a git tag with `tbump`.

```shell
pip install tbump
```

`tbump` will ask for confirmation before doing anything.

```shell
# Example versions to set: 1.0.0, 1.0.0b1
VERSION=
tbump ${VERSION}
```

Following this, the [CI system] will build and publish a release.

4. Reset the version back to dev, e.g. `1.0.1.dev` after releasing `1.0.0`.

```shell
# Example version to set: 1.0.1.dev
NEXT_VERSION=
tbump --no-tag ${NEXT_VERSION}.dev
```

5. Following the release to PyPI, an automated PR should arrive within 24 hours
to [conda-forge/batchspawner-feedstock] with instructions on releasing to
conda-forge. You are welcome to volunteer doing this, but aren't required as
part of making this release to PyPI.

[github-activity]: https://github.com/executablebooks/github-activity
[pypi]: https://pypi.org/project/batchspawner/
[ci system]: https://github.com/jupyterhub/batchspawner/actions/workflows/release.yaml
[conda-forge]: https://anaconda.org/conda-forge/batchspawner
[conda-forge/batchspawner-feedstock]: https://github.com/conda-forge/batchspawner-feedstock
5 changes: 3 additions & 2 deletions batchspawner/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .batchspawner import *
from . import api
from . import api # noqa
from ._version import __version__, version_info # noqa
from .batchspawner import * # noqa
7 changes: 7 additions & 0 deletions batchspawner/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# __version__ should be updated using tbump, based on configuration in
# pyproject.toml, according to instructions in RELEASE.md.
#
__version__ = "1.3.0.dev"

# version_info looks like (1, 2, 3, "dev") if __version__ is 1.2.3.dev
version_info = tuple(int(p) if p.isdigit() else p for p in __version__.split("."))
3 changes: 2 additions & 1 deletion batchspawner/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
from tornado import web

from jupyterhub.apihandlers import APIHandler, default_handlers
from tornado import web
consideRatio marked this conversation as resolved.
Show resolved Hide resolved


class BatchSpawnerAPIHandler(APIHandler):
Expand Down
Loading