Skip to content

Commit 3d9b0e9

Browse files
authored
Merge pull request #58 from consideRatio/pr/general-maint
maint: require py37, fix tests, use pyupgrade/isort/autoflake, use pyproject.toml, more f-strings
2 parents 36eab38 + 9d3c71f commit 3d9b0e9

File tree

13 files changed

+331
-200
lines changed

13 files changed

+331
-200
lines changed

.flake8

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
[flake8]
2-
ignore = E501,F841
2+
# Ignore style and complexity
3+
# E: style errors
4+
# W: style warnings
5+
# C: complexity
6+
# D: docstring warnings (unused pydocstyle extension)
7+
ignore = E, C, W, D

.github/workflows/publish.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This is a GitHub workflow defining a set of jobs with a set of steps.
2+
# ref: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
3+
#
4+
# Test build release artifacts (PyPI package) and publish them on pushed git
5+
# tags.
6+
#
7+
name: Release
8+
9+
on:
10+
pull_request:
11+
paths-ignore:
12+
- "**.md"
13+
- ".github/workflows/*"
14+
- "!.github/workflows/release.yaml"
15+
push:
16+
paths-ignore:
17+
- "**.md"
18+
- ".github/workflows/*"
19+
- "!.github/workflows/release.yaml"
20+
branches-ignore:
21+
- "dependabot/**"
22+
- "pre-commit-ci-update-config"
23+
tags:
24+
- "**"
25+
workflow_dispatch:
26+
27+
jobs:
28+
build-release:
29+
runs-on: ubuntu-22.04
30+
steps:
31+
- uses: actions/checkout@v3
32+
- uses: actions/setup-python@v4
33+
with:
34+
python-version: "3.11"
35+
36+
- name: install build requirements
37+
run: |
38+
pip install --upgrade pip
39+
pip install build
40+
pip freeze
41+
42+
- name: build release
43+
run: |
44+
python -m build --sdist --wheel .
45+
ls -l dist
46+
47+
- name: Publish to PyPI
48+
if: startsWith(github.ref, 'refs/tags/')
49+
env:
50+
TWINE_USERNAME: __token__
51+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
52+
run: |
53+
pip install twine
54+
twine upload --skip-existing dist/*

.github/workflows/test.yaml

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,67 +5,76 @@ name: Test
55

66
on:
77
pull_request:
8+
paths-ignore:
9+
- "**.md"
10+
- ".github/workflows/*"
11+
- "!.github/workflows/test.yaml"
812
push:
13+
paths-ignore:
14+
- "**.md"
15+
- ".github/workflows/*"
16+
- "!.github/workflows/test.yaml"
17+
branches-ignore:
18+
- "dependabot/**"
19+
- "pre-commit-ci-update-config"
20+
tags:
21+
- "**"
922
workflow_dispatch:
1023

1124
jobs:
12-
pre-commit:
13-
name: Run pre-commit
14-
runs-on: ubuntu-20.04
15-
steps:
16-
- uses: actions/checkout@v2
17-
- uses: actions/setup-python@v2
18-
- uses: pre-commit/[email protected]
19-
2025
pytest:
21-
name: "Run tests"
22-
runs-on: ubuntu-20.04
26+
runs-on: ubuntu-22.04
2327
strategy:
2428
fail-fast: false
2529
matrix:
2630
include:
27-
- python-version: 3.6
28-
jupyterhub-version: 1.3.*
29-
- python-version: 3.7
31+
- python-version: "3.7"
3032
jupyterhub-version: 1.*
31-
- python-version: 3.8
33+
sqlalchemy-version: 1.*
34+
- python-version: "3.8"
3235
jupyterhub-version: 2.0.*
33-
- python-version: 3.9
36+
sqlalchemy-version: 1.*
37+
- python-version: "3.9"
3438
jupyterhub-version: 2.*
39+
sqlalchemy-version: 1.*
40+
- python-version: "3.10"
41+
jupyterhub-version: 3.0.*
42+
sqlalchemy-version: 1.*
43+
- python-version: "3.11"
44+
jupyterhub-version: 3.*
3545

3646
steps:
37-
- uses: actions/checkout@v2
38-
- uses: actions/setup-python@v2
47+
- uses: actions/checkout@v3
48+
- uses: actions/setup-python@v4
3949
with:
40-
python-version: "${{ matrix.python-version}}"
41-
42-
- name: Install Node
43-
uses: actions/setup-node@v1
50+
python-version: "${{ matrix.python-version }}"
51+
- uses: actions/setup-node@v3
4452
with:
45-
node-version: "16"
53+
node-version: "18"
4654

4755
- name: Install configurable-http-proxy
4856
run: |
4957
npm install -g configurable-http-proxy
5058
5159
- name: Install Python dependencies
5260
run: |
53-
pip install -e . -r dev-requirements.txt
61+
pip install -e ".[test]"
5462
5563
- name: Install specified jupyterhub version
5664
if: ${{ matrix.jupyterhub-version }}
5765
run: |
5866
pip install --pre jupyterhub==${{ matrix.jupyterhub-version }}
67+
- name: Install specified sqlalchemy version
68+
if: ${{ matrix.sqlalchemy-version }}
69+
run: |
70+
pip install sqlalchemy==${{ matrix.sqlalchemy-version }}
5971
60-
- name: Show environment
72+
- name: List Python dependencies
6173
run: |
6274
pip freeze
6375
6476
- name: Run tests
65-
continue-on-error: ${{ matrix.accept-failure == true }}
6677
run: |
67-
pytest -v --maxfail=2 --color=yes --cov jupyterhub_idle_culler
78+
pytest --maxfail=2 --cov=jupyterhub_idle_culler
6879
69-
- name: Publish coverage
70-
run: |
71-
codecov
80+
- uses: codecov/codecov-action@v3

.pre-commit-config.yaml

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,57 @@
99
# - Register git hooks: pre-commit install --install-hooks
1010
#
1111
repos:
12+
# Autoformat: Python code, syntax patterns are modernized
13+
- repo: https://github.com/asottile/pyupgrade
14+
rev: v3.3.1
15+
hooks:
16+
- id: pyupgrade
17+
args:
18+
- --py37-plus
19+
20+
# Autoformat: Python code
21+
- repo: https://github.com/PyCQA/autoflake
22+
rev: v2.0.1
23+
hooks:
24+
- id: autoflake
25+
# args ref: https://github.com/PyCQA/autoflake#advanced-usage
26+
args:
27+
- --in-place
28+
29+
# Autoformat: Python code
30+
- repo: https://github.com/pycqa/isort
31+
rev: 5.12.0
32+
hooks:
33+
- id: isort
34+
1235
# Autoformat: Python code
1336
- repo: https://github.com/psf/black
1437
rev: 23.1.0
1538
hooks:
1639
- id: black
17-
args: [--target-version=py36]
1840

19-
# Autoformat: markdown, yaml
41+
# Autoformat: markdown, yaml, javascript (see the file .prettierignore)
2042
- repo: https://github.com/pre-commit/mirrors-prettier
2143
rev: v3.0.0-alpha.4
2244
hooks:
2345
- id: prettier
2446
exclude: COPYING.md
2547

26-
# Lint: Python code
27-
- repo: https://github.com/PyCQA/flake8
28-
rev: "6.0.0"
29-
hooks:
30-
- id: flake8
31-
32-
# Misc...
48+
# Autoformat and linting, misc. details
3349
- repo: https://github.com/pre-commit/pre-commit-hooks
3450
rev: v4.4.0
35-
# ref: https://github.com/pre-commit/pre-commit-hooks#hooks-available
3651
hooks:
37-
# Autoformat: Makes sure files end in a newline and only a newline.
3852
- id: end-of-file-fixer
39-
40-
# Autoformat: Sorts entries in requirements.txt.
4153
- id: requirements-txt-fixer
42-
43-
# Lint: Check for files with names that would conflict on a
44-
# case-insensitive filesystem like MacOS HFS+ or Windows FAT.
4554
- id: check-case-conflict
46-
47-
# Lint: Checks that non-binary executables have a proper shebang.
4855
- id: check-executables-have-shebangs
4956

57+
# Linting: Python code (see the file .flake8)
58+
- repo: https://github.com/PyCQA/flake8
59+
rev: "6.0.0"
60+
hooks:
61+
- id: flake8
62+
5063
# pre-commit.ci config reference: https://pre-commit.ci/#configuration
5164
ci:
5265
autoupdate_schedule: monthly

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# JupyterHub Idle Culler Service
22

3-
[![GitHub Workflow Status - Test](https://img.shields.io/github/workflow/status/jupyterhub/jupyterhub-idle-culler/Test?logo=github&label=tests)](https://github.com/jupyterhub/jupyterhub-idle-culler/actions)
3+
[![GitHub Workflow Status - Test](https://img.shields.io/github/actions/workflow/status/jupyterhub/jupyterhub-idle-culler/test.yaml?logo=github&label=tests)](https://github.com/jupyterhub/jupyterhub-idle-culler/actions)
44
[![Latest PyPI version](https://img.shields.io/pypi/v/jupyterhub-idle-culler?logo=pypi&logoColor=white)](https://pypi.python.org/pypi/jupyterhub-idle-culler)
55
[![GitHub](https://img.shields.io/badge/issue_tracking-github-blue?logo=github)](https://github.com/jupyterhub/jupyterhub-idle-culler/issues)
66
[![Discourse](https://img.shields.io/badge/help_forum-discourse-blue?logo=discourse)](https://discourse.jupyter.org/c/jupyterhub)

RELEASE.md

Lines changed: 34 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,56 @@
11
# How to make a release
22

3-
`jupyterhub-idle-culler` is a package [available on
4-
PyPI](https://pypi.org/project/jupyterhub-idle-culler/). These are instructions
5-
on how to make a release on PyPI. The PyPI release is done automatically by a
6-
GitHub workflow when a tag is pushed.
3+
`jupyterhub-idle-culler` is a package available on [PyPI] and [conda-forge].
4+
These are instructions on how to make a release.
75

8-
For you to follow along according to these instructions, you need:
6+
## Pre-requisites
97

10-
- To have push rights to the [jupyterhub-idle-culler GitHub
11-
repository](https://github.com/jupyterhub/jupyterhub-idle-culler).
8+
- Push rights to [jupyterhub/jupyterhub-idle-culler]
129

1310
## Steps to make a release
1411

15-
1. Checkout main and make sure it is up to date.
12+
1. Create a PR updating `CHANGELOG.md` with [github-activity] and continue only
13+
when its merged.
1614

1715
```shell
18-
ORIGIN=${ORIGIN:-origin} # set to the canonical remote, e.g. 'upstream' if 'origin' is not the official repo
19-
git checkout main
20-
git fetch $ORIGIN main
21-
git reset --hard $ORIGIN/main
22-
# WARNING! This next command deletes any untracked files in the repo
23-
git clean -xfd
24-
```
25-
26-
1. Update [CHANGELOG.md](CHANGELOG.md). Doing this can be made easier with the
27-
help of the
28-
[choldgraf/github-activity](https://github.com/choldgraf/github-activity)
29-
utility.
16+
pip install github-activity
3017

31-
1. Set the `version` variable in [setup.py](setup.py) appropriately and make a
32-
commit.
33-
34-
```
35-
git add setup.py
36-
VERSION=... # e.g. 1.2.3
37-
git commit -m "release $VERSION"
18+
github-activity --heading-level=3 jupyterhub/jupyterhub-idle-culler
3819
```
3920

40-
1. Reset the `version` variable in [setup.py](setup.py) appropriately with an
41-
incremented patch version and a `dev` element, then make a commit.
21+
1. Checkout main and make sure it is up to date.
4222

43-
```
44-
git add setup.py
45-
git commit -m "back to dev"
23+
```shell
24+
git checkout main
25+
git fetch origin main
26+
git reset --hard origin/main
4627
```
4728

48-
1. Push your two commits to main.
29+
1. Update the version, make commits, and push a git tag with `tbump`.
4930

5031
```shell
51-
# first push commits without a tags to ensure the
52-
# commits comes through, because a tag can otherwise
53-
# be pushed all alone without company of rejected
54-
# commits, and we want have our tagged release coupled
55-
# with a specific commit in main
56-
git push $ORIGIN main
32+
pip install tbump
33+
tbump --dry-run ${VERSION}
34+
35+
tbump ${VERSION}
5736
```
5837

59-
1. Create a git tag for the pushed release commit and push it.
38+
Following this, the [CI system] will build and publish a release.
6039

61-
```shell
62-
git tag -a $VERSION -m $VERSION HEAD~1
40+
1. Reset the version back to dev, e.g. `2.1.0.dev` after releasing `2.0.0`
6341

64-
# then verify you tagged the right commit
65-
git log
66-
67-
# then push it
68-
git push $ORIGIN refs/tags/$VERSION
42+
```shell
43+
tbump --no-tag ${NEXT_VERSION}.dev
6944
```
45+
46+
1. Following the release to PyPI, an automated PR should arrive within 24 hours
47+
to [conda-forge/jupyterhub-idle-culler-feedstock] with instructions on
48+
releasing to conda-forge. You are welcome to volunteer doing this, but aren't
49+
required as part of making this release to PyPI.
50+
51+
[pypi]: https://pypi.org/project/jupyterhub-idle-culler/
52+
[conda-forge]: https://anaconda.org/conda-forge/jupyterhub-idle-culler
53+
[jupyterhub/jupyterhub-idle-culler]: https://github.com/jupyterhub/jupyterhub-idle-culler
54+
[conda-forge/jupyterhub-idle-culler-feedstock]: https://github.com/conda-forge/jupyterhub-idle-culler-feedstock
55+
[github-activity]: https://github.com/executablebooks/github-activity
56+
[ci system]: https://github.com/jupyterhub/jupyterhub-idle-culler/actions/workflows/release.yaml

0 commit comments

Comments
 (0)