Skip to content

Commit

Permalink
Dev chores (#916)
Browse files Browse the repository at this point in the history
* Migrate to pyproject.toml; use ruff; add SECURITY.md and RELEASING.md

* tox -e lint

* Update build and release pipeline

* cleanup
  • Loading branch information
sloria committed Jan 30, 2024
1 parent 8a95191 commit 0917b88
Show file tree
Hide file tree
Showing 36 changed files with 237 additions and 246 deletions.
64 changes: 42 additions & 22 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,60 @@ jobs:
- { name: "lowest", python: "3.8", tox: py38-lowest }
- { name: "dev", python: "3.12", tox: py312-marshmallowdev }
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/setup-python@v4.3.0
- uses: actions/checkout@v4.0.0
- uses: actions/setup-python@v4.7.0
with:
python-version: ${{ matrix.python }}
- run: python -m pip install --upgrade pip
- run: python -m pip install tox
- run: python -m tox -e${{ matrix.tox }}
build:
name: Build package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install pypa/build
run: python -m pip install build
- name: Build a binary wheel and a source tarball
run: python -m build
- name: Install twine
run: python -m pip install twine
- name: Check build
run: python -m twine check --strict dist/*
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/
# this duplicates pre-commit.ci, so only run it on tags
# it guarantees that linting is passing prior to a release
lint-pre-release:
name: lint
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/setup-python@v4.3.0
- uses: actions/checkout@v4.0.0
- uses: actions/setup-python@v4.7.0
with:
python-version: "3.11"
- run: python -m pip install --upgrade pip
- run: python -m pip install tox
- run: python -m tox -elint
release:
needs: [tests, lint-pre-release]
- run: python -m tox -e lint
publish-to-pypi:
name: PyPI release
if: startsWith(github.ref, 'refs/tags')
if: startsWith(github.ref, 'refs/tags/')
needs: [build, tests, lint-pre-release]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/webargs
permissions:
id-token: write
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/setup-python@v4.3.0
- name: install requirements
run: python -m pip install build twine
- name: build dists
run: python -m build
- name: check package metadata
run: twine check dist/*
- name: publish
run: twine upload -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} dist/*
- 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
18 changes: 4 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.14
hooks:
- id: pyupgrade
args: ["--py38-plus"]
- id: ruff
- id: ruff-format
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.3
hooks:
- id: check-github-workflows
- id: check-readthedocs
- repo: https://github.com/psf/black
rev: 24.1.1
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies: ['flake8-bugbear==23.12.2']
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black==23.12.1]
args: ["--target-version", "py38"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2014-2024 Steven Loria and contributors
Copyright Steven Loria and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

9 changes: 9 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Releasing

1. Bump version in `pyproject.toml` and update the changelog
with today's date.
2. Commit: `git commit -m "Bump version and update changelog"`
3. Tag the commit: `git tag x.y.z`
4. Push: `git push --tags origin dev`. CI will take care of the
PyPI release.
5. Add release notes on Tidelift.
5 changes: 5 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Security Contact Information

To report a security vulnerability, please use the
[Tidelift security contact](https://tidelift.com/security).
Tidelift will coordinate the fix and disclosure.
21 changes: 3 additions & 18 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
import sys
import os
import time
import datetime as dt

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath(os.path.join("..", "src")))
import webargs # noqa
import importlib.metadata

extensions = [
"sphinx.ext.autodoc",
Expand All @@ -30,20 +21,14 @@
}


# Use SOURCE_DATE_EPOCH for reproducible build output
# https://reproducible-builds.org/docs/source-date-epoch/
build_date = dt.datetime.utcfromtimestamp(
int(os.environ.get("SOURCE_DATE_EPOCH", time.time()))
)

# The master toctree document.
master_doc = "index"
language = "en"
html_domain_indices = False
source_suffix = ".rst"
project = "webargs"
copyright = f"2014-{build_date:%Y}, Steven Loria and contributors"
version = release = webargs.__version__
copyright = "Steven Loria and contributors"
version = release = importlib.metadata.version("webargs")
templates_path = ["_templates"]
exclude_patterns = ["_build"]

Expand Down
1 change: 1 addition & 0 deletions examples/aiohttp_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from aiohttp import web
from aiohttp.web import json_response

from webargs import fields, validate
from webargs.aiohttpparser import use_args, use_kwargs

Expand Down
4 changes: 2 additions & 2 deletions examples/annotations_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
$ http GET :5001/users/42
"""

import random
import functools
import random

from flask import Flask, request
from marshmallow import Schema

from webargs import fields
from webargs.flaskparser import parser


app = Flask(__name__)

##### Routing wrapper ####
Expand Down
4 changes: 2 additions & 2 deletions examples/bottle_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

import datetime as dt

from bottle import route, run, error, response
from bottle import error, response, route, run

from webargs import fields, validate
from webargs.bottleparser import use_args, use_kwargs


hello_args = {"name": fields.Str(load_default="Friend")}


Expand Down
6 changes: 3 additions & 3 deletions examples/falcon_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

import datetime as dt

from webargs.core import json

import falcon

from webargs import fields, validate
from webargs.falconparser import use_args, use_kwargs, parser
from webargs.core import json
from webargs.falconparser import parser, use_args, use_kwargs

### Middleware and hooks ###

Expand Down
1 change: 1 addition & 0 deletions examples/flask_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import datetime as dt

from flask import Flask, jsonify

from webargs import fields, validate
from webargs.flaskparser import use_args, use_kwargs

Expand Down
2 changes: 1 addition & 1 deletion examples/flaskrestful_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from flask_restful import Api, Resource

from webargs import fields, validate
from webargs.flaskparser import use_args, use_kwargs, parser, abort
from webargs.flaskparser import abort, parser, use_args, use_kwargs

app = Flask(__name__)
api = Api(app)
Expand Down
6 changes: 3 additions & 3 deletions examples/pyramid_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
"""

import datetime as dt

from wsgiref.simple_server import make_server

from pyramid.config import Configurator
from pyramid.view import view_config
from pyramid.renderers import JSON
from pyramid.view import view_config

from webargs import fields, validate
from webargs.pyramidparser import use_args, use_kwargs


hello_args = {"name": fields.Str(load_default="Friend")}


Expand Down
1 change: 1 addition & 0 deletions examples/schema_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from flask import Flask, request
from marshmallow import Schema, fields, post_dump

from webargs.flaskparser import parser, use_kwargs

app = Flask(__name__)
Expand Down
1 change: 1 addition & 0 deletions examples/tornado_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import tornado.ioloop
from tornado.web import RequestHandler

from webargs import fields, validate
from webargs.tornadoparser import use_args, use_kwargs

Expand Down

0 comments on commit 0917b88

Please sign in to comment.