Skip to content

Commit

Permalink
Modernize setuptools packaging and automate releases
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitsanj committed Aug 3, 2024
1 parent 6f220ed commit 508a51e
Show file tree
Hide file tree
Showing 15 changed files with 244 additions and 174 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ commit = True
tag = True
tag_name = {new_version}

[bumpversion:file:testbook/_version.py]
[bumpversion:file:pyproject.toml]
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, "3.10.0-rc.2"]
python-version: [3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12]
env:
OS: ubuntu-latest
PYTHON: "3.8"
Expand Down
117 changes: 117 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Publish testbook

on: push

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/testbook
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: >-
Sign the Python 🐍 distribution 📦 with Sigstore
and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs:
- build
runs-on: ubuntu-latest

environment:
name: testpypi
url: https://test.pypi.org/p/testbook

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
[![Build Status](https://github.com/nteract/testbook/workflows/CI/badge.svg)](https://github.com/nteract/testbook/actions)
[![image](https://codecov.io/github/nteract/testbook/coverage.svg?branch=master)](https://codecov.io/github/nteract/testbook?branch=master)
[![Documentation Status](https://readthedocs.org/projects/testbook/badge/?version=latest)](https://testbook.readthedocs.io/en/latest/?badge=latest)
[![PyPI](https://img.shields.io/pypi/v/testbook.svg)](https://pypi.org/project/testbook/)
[![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/)
[![Python 3.7](https://img.shields.io/badge/python-3.7-blue.svg)](https://www.python.org/downloads/release/python-370/)
[![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/downloads/release/python-380/)
[![Python 3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/downloads/release/python-390/)
[![image](https://img.shields.io/pypi/v/testbook.svg)](https://pypi.python.org/pypi/testbook)
[![image](https://img.shields.io/pypi/l/testbook.svg)](https://github.com/astral-sh/testbook/blob/main/LICENSE)
[![image](https://img.shields.io/pypi/pyversions/testbook.svg)](https://pypi.python.org/pypi/testbook)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)

# testbook
Expand Down
4 changes: 2 additions & 2 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Prerequisites

- First check that the CHANGELOG is up to date for the next release version
- Ensure dev requirements are installed `pip install -r requirements-dev.txt`
- Ensure dev requirements are installed `pip install ".[dev]"`

## Push to GitHub

Expand All @@ -19,6 +19,6 @@ git push upstream && git push upstream --tags
```bash
rm -rf dist/*
rm -rf build/*
python setup.py bdist_wheel
python -m build
twine upload dist/*
```
3 changes: 0 additions & 3 deletions docs/requirements-doc.txt

This file was deleted.

129 changes: 116 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,132 @@
# Example configuration for Black.
[build-system]
build-backend = "setuptools.build_meta"

# NOTE: you have to use single-quoted strings in TOML for regular expressions.
# It's the equivalent of r-strings in Python. Multiline strings are treated as
# verbose regular expressions by Black. Use [ ] to denote a significant space
# character.
requires = [ "setuptools" ]

[project]
name = "testbook_rohitsanjay"
version = "0.4.2"
description = "A unit testing framework for Jupyter Notebooks"
readme = "README.md"
keywords = [ "jupyter", "notebook", "nteract", "unit-testing" ]
license = { file = "LICENSE" }
maintainers = [
{ name = "Nteract Contributors", email = "[email protected]" },
{ name = "Rohit Sanjay", email = "[email protected]" },
{ name = "Matthew Seal", email = "[email protected]" },
]
authors = [
{ name = "Nteract Contributors", email = "[email protected]" },
{ name = "Rohit Sanjay", email = "[email protected]" },
{ name = "Matthew Seal", email = "[email protected]" },
]
requires-python = ">=3.6"

classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Testing",
"Topic :: Software Development :: Testing :: Mocking",
"Topic :: Software Development :: Testing :: Unit",
]
dependencies = [
"nbclient>=0.4",
"nbformat>=5.0.4",
]
optional-dependencies.dev = [
"black; python_version>='3.6'",
"bumpversion",
"check-manifest",
"codecov",
"coverage",
"flake8",
"ipykernel",
"ipython",
"ipywidgets",
"pandas",
"pip>=18.1",
"pytest>=4.1",
"pytest-cov>=2.6.1",
"setuptools>=38.6",
"tox",
"build",
"twine>=1.11",
"xmltodict",
]
optional-dependencies.test = [
"myst-parser==0.9.1",
"sphinx>=1.7,<3",
"sphinx-book-theme==0.0.35",
]
urls.Documentation = "https://testbook.readthedocs.io"
urls.Funding = "https://nteract.io"
urls.Issues = "https://github.com/nteract/testbook/issues"
urls.Repository = "https://github.com/nteract/testbook/"

[tool.black]
line-length = 100
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
# The following are specific to Black, you probably don't want those.
| blib2to3
| tests/data
| profiling
)/
'''
skip-string-normalization = true

[tool.flake8]
exclude = "__init__.py"
ignore = [
"E20", # Extra space in brackets
"E231",
"E241", # Multiple spaces around ","
"E26", # Comments
"E4", # Import formatting
"E721", # Comparing types instead of isinstance
"E731", # Assigning lambda expression
]
max-line-length = 120

# Not sure I need this?
# [tool.bdist_wheel]
# universal = 0

[tool.pytest.ini_options]
filterwarnings = "always"
testpaths = [
"testbook/tests/",
]

[tool.coverage.run]
branch = false
omit = [
"testbook/tests/*",
"testbook/_version.py",
]

[tool.coverage.report]
exclude_lines = [
"if self\\.debug:",
"pragma: no cover",
"raise AssertionError",
"raise NotImplementedError",
"if __name__ == '__main__':",
]
ignore_errors = true
omit = [
"testbook/tests/*",
"testbook/_version.py",
]
3 changes: 0 additions & 3 deletions pytest.ini

This file was deleted.

18 changes: 0 additions & 18 deletions requirements-dev.txt

This file was deleted.

2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

44 changes: 0 additions & 44 deletions setup.cfg

This file was deleted.

Loading

0 comments on commit 508a51e

Please sign in to comment.