Skip to content

Commit

Permalink
Rework CI
Browse files Browse the repository at this point in the history
  • Loading branch information
lafrech committed Feb 28, 2024
1 parent 15afc94 commit 09b88c7
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 120 deletions.
83 changes: 56 additions & 27 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,76 @@ on:
push:
pull_request:
jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: '3.11'
- run: python -m pip install --upgrade pip wheel
- run: pip install tox
- run: tox -elint
tests:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- {name: '3.8', python: '3.8', tox: py38}
- {name: '3.12', python: '3.12', tox: py312}
- { name: '3.8', python: '3.8', tox: py38 }
- { name: '3.12', python: '3.12', tox: py312 }
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/setup-python@v4.3.0
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
allow-prereleases: true
- name: Run test
run: |
python -m pip install --upgrade pip wheel
pip install tox
tox -e${{ matrix.tox }}
python -m pip install tox
python -m tox -e ${{ matrix.tox }}
- name: Upload coverage
uses: codecov/codecov-action@v3
release:
needs: [lint, tests]
name: PyPI release
build:
name: Build package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
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@v4
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:
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
- run: python -m pip install --upgrade pip wheel
- run: pip install twine
- run: python setup.py sdist bdist_wheel
- run: twine upload -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} dist/*
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: python -m pip install tox
- run: python -m tox -e lint
publish-to-pypi:
name: PyPI release
if: startsWith(github.ref, 'refs/tags/')
needs: [build, tests, lint-pre-release]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/flask-smorest
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
# TODO: Configure GH permissions, remove TOKEN
uses: pypa/gh-action-pypi-publish@release/v1
23 changes: 9 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.1
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/psf/black
rev: 24.2.0
- id: ruff
- id: ruff-format
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear==24.2.6]
- id: check-github-workflows
- id: check-readthedocs
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black==22.3.0]
additional_dependencies: [black==23.12.1]
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ flask-smorest
:target: https://codecov.io/gh/marshmallow-code/flask-smorest
:alt: Code coverage

.. image:: https://results.pre-commit.ci/badge/github/marshmallow-code/flask-smorest/dev.svg
:target: https://results.pre-commit.ci/latest/github/marshmallow-code/flask-smorest/dev
:alt: pre-commit.ci status

.. image:: https://readthedocs.org/projects/flask-smorest/badge/
:target: http://flask-smorest.readthedocs.io/
:alt: Documentation
Expand Down
1 change: 1 addition & 0 deletions docs/openapi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ The :meth:`Api.register_converter` allows to register a converter in the
# Register MongoDB's ObjectId converter in Flask application
app.url_map.converters["objectid"] = ObjectIdConverter
# Define custom converter to schema function
def objectidconverter2paramschema(converter):
return {"type": "string", "format": "ObjectID"}
Expand Down
2 changes: 1 addition & 1 deletion flask_smorest/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def arguments(
description=None,
example=None,
examples=None,
**kwargs
**kwargs,
):
"""Decorator specifying the schema used to deserialize parameters
Expand Down
2 changes: 1 addition & 1 deletion flask_smorest/etag.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def _prepare_etag_doc(self, doc, doc_info, *, api, spec, method, **kwargs):
for success_status_code in success_status_codes:
doc["responses"][success_status_code].setdefault("headers", {})[
"ETag"
] = (ETAG_HEADER if spec.openapi_version.major < 3 else "ETAG")
] = ETAG_HEADER if spec.openapi_version.major < 3 else "ETAG"

if responses:
doc = deepupdate(doc, {"responses": responses})
Expand Down
75 changes: 0 additions & 75 deletions setup.py

This file was deleted.

5 changes: 3 additions & 2 deletions tests/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ def func():
else:
assert "produces" not in get
assert get["responses"]["200"]["content"] == {
content_type
or "application/json": {"schema": build_ref(api.spec, "schema", "Doc")}
content_type or "application/json": {
"schema": build_ref(api.spec, "schema", "Doc")
}
}

@pytest.mark.parametrize("openapi_version", ["2.0", "3.0.2"])
Expand Down

0 comments on commit 09b88c7

Please sign in to comment.