Skip to content
This repository has been archived by the owner on Jan 25, 2025. It is now read-only.

Add pre commit, and applied other project configuration updates #34

Merged
merged 7 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Initial application of pre-commit (including Black)
77f65d1a2ebbb8593e6968ce1af212693b074c93
70 changes: 31 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,21 @@ on:
workflow_call:

jobs:
beefore:
name: Pre-test checks
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
task:
- 'flake8'
- 'towncrier-check'
- 'package'
steps:
# Fetch main branch for comparison, then check out current branch.
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/[email protected]
with:
python-version: 3.X
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
python -m pip install tox
- name: Run pre-test check
run: |
tox -e ${{ matrix.task }}
pre-commit:
name: Pre-commit checks
uses: beeware/.github/.github/workflows/pre-commit-run.yml@main

towncrier:
name: Check towncrier
uses: beeware/.github/.github/workflows/towncrier-run.yml@main

package:
name: Python Package
uses: beeware/.github/.github/workflows/python-package-create.yml@main

python-versions:
unit-tests:
name: Python compatibility test
needs: beefore
needs: [pre-commit, towncrier, package]
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -53,16 +33,28 @@ jobs:
experimental: true

steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies

- name: Get packages
uses: actions/[email protected]
with:
name: ${{ needs.package.outputs.artifact-name }}
path: dist

- name: Install dev dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
python -m pip install tox
# We don't actually want to install travertino;
# we just want the dev extras so we have a known version of tox.
python -m pip install $(ls dist/travertino-*.whl)[dev]

- name: Test
run: |
tox -e py
tox -e py --installpkg dist/travertino-*.whl
12 changes: 12 additions & 0 deletions .github/workflows/pre-commit-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Update pre-commit

on:
schedule:
- cron: "0 20 * * SUN" # Sunday @ 2000 UTC
workflow_dispatch:

jobs:
pre-commit-update:
name: Update pre-commit
uses: beeware/.github/.github/workflows/pre-commit-update.yml@main
secrets: inherit
33 changes: 13 additions & 20 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,18 @@ on:
types: published

jobs:
publish:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
python -m pip install tox
- name: Build release artefacts
run: |
tox -e package
- name: Publish release
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
tox -e publish
- uses: dsaltares/[email protected]
with:
version: tags/${{ github.event.release.tag_name }}
# This next line is *not* a bash filename expansion - it's a regex.
file: travertino.*
regex: true
target: dist/

- name: Publish release to production PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_PASSWORD }}
66 changes: 55 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,66 @@ name: Create Release
on:
push:
tags:
- 'v*'
- "v*"

jobs:
ci:
uses: ./.github/workflows/ci.yml

release:
name: Create Release
runs-on: ubuntu-latest
needs: ci
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Set build variables
run: |
echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV

- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.X"

- name: Get packages
uses: actions/[email protected]
with:
name: packages
path: dist

- name: Install packages
run: pip install dist/travertino-*.whl

- name: Check version number
# Check that the setuptools_scm-generated version number is still the same when
# installed from a wheel with setuptools_scm not present.
run: |
set -x
test $(python -c "from travertino import __version__; print(__version__)") = $VERSION

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: ncipollo/[email protected]
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
name: ${{ env.VERSION }}
draft: true
prerelease: false
artifacts: dist/*
artifactErrorsFailBuild: true

test-publish:
name: Publish test package
needs: [release]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Get packages
uses: actions/[email protected]
with:
name: packages
path: dist

- name: Publish release to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository_url: https://test.pypi.org/legacy/
password: ${{ secrets.TEST_PYPI_PASSWORD }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ distribute-*
venv
.idea
pip-wheel-metadata

28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-toml
- id: check-yaml
- id: check-case-conflict
- id: check-docstring-first
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
additional_dependencies: [toml]
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
7 changes: 3 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Contributing

PyBee <3's contributions!
BeeWare <3's contributions!

Please be aware, PyBee operates under a Code of Conduct.

See [CONTRIBUTING to PyBee](http://pybee.org/contributing) for details.
Please be aware, BeeWare operates under a Code of Conduct.

See [CONTRIBUTING to BeeWare](https://beeware.org/contributing) for details.
5 changes: 2 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ include CONTRIBUTING.md
include README.rst
include AUTHORS
include LICENSE
include beekeeper.yml
include tox.ini
include .git-blame-ignore-revs
include .pre-commit-config.yaml
recursive-include changes *.rst
recursive-include travertino *.py
recursive-include tests *.py
recursive-include tests *.json
10 changes: 9 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Travertino
.. image:: https://img.shields.io/discord/836455665257021440?label=Discord%20Chat&logo=discord&style=plastic
:target: https://beeware.org/bee/chat/
:alt: Discord server

Travertino is a set of constants and utilities for describing user
interfaces, including:

Expand Down Expand Up @@ -74,6 +74,14 @@ Contributing
If you experience problems with Travertino, `log them on GitHub`_. If you
want to contribute code, please `fork the code`_ and `submit a pull request`_.

Travertino uses `Pre-commit <https://pre-commit.com/>`__ and `TownCrier
<https://pypi.org/project/towncrier/>`__ to help maintain code quality. For
details on how to use these tools as part of your development environment, see
the `Briefcase code contribution guide
<https://briefcase.readthedocs.io/en/stable/how-to/contribute-code.html>`__.
Although that document is for a different project, the details about setting up
your development environment are the same.

.. _BeeWare suite: http://beeware.org
.. _Read The Docs: https://travertino.readthedocs.io
.. _@pybeeware on Twitter: https://twitter.com/pybeeware
Expand Down
1 change: 1 addition & 0 deletions changes/18.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Details on towncrier and pre-commit ussage were added to the README.
2 changes: 1 addition & 1 deletion changes/22.misc.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Corrected some spelling errors.
Corrected some spelling errors.
2 changes: 1 addition & 1 deletion changes/23.feature.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Node now supports the `clear` method in order to clear all children.
Node now supports the ``clear`` method in order to clear all children.
2 changes: 1 addition & 1 deletion changes/24.misc.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Flake8 should ignore the venv directory when running.
Flake8 should ignore the venv directory when running.
2 changes: 1 addition & 1 deletion changes/25.misc.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Drop python 3.5 support!
Drop python 3.5 support!
2 changes: 1 addition & 1 deletion changes/26.misc.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Upgrade all codebase to use format-strings
Upgrade all codebase to use format-strings
1 change: 1 addition & 0 deletions changes/34.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pre-commit was added to the codebase. This introduces black as a coding style.
14 changes: 9 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
[build-system]
requires = [
"setuptools >= 43.0.0",
"wheel >= 0.32.0",
]
requires = ["setuptools==66.1.1", "setuptools_scm[toml]==7.0.5"]
build-backend = "setuptools.build_meta"

[tool.isort]
profile = "black"
split_on_trailing_comma = true
combine_as_imports = true

[tool.setuptools_scm]
# To enable SCM versioning, we need an empty tool configuration for setuptools_scm

[tool.towncrier]
directory = "changes"
package = "travertino"
filename = "CHANGELOG.rst"
title_format = "{version} ({project_date})"
issue_format = "`#{issue} <https://github.com/beeware/travertino/issues/{issue}>`_"
template = "changes/template.rst"
underlines = ["-", "^", "\""]
20 changes: 10 additions & 10 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[metadata]
name = travertino
version = attr: travertino.__version__
project_urls =
Funding = https://beeware.org/contributing/membership/
Tracker = https://github.com/beeware/travertino/issues
Expand Down Expand Up @@ -35,6 +34,16 @@ packages = find:
package_dir =
= src

[options.extras_require]
dev =
# Pre-commit 3.0 dropped support for Python 3.7
pre-commit == 2.21.0; python_version < "3.8"
pre-commit == 3.0.4; python_version >= "3.8"
pytest == 7.2.1
pytest-tldr == 0.2.5
setuptools_scm[toml] == 7.1.0
tox == 4.4.4

[options.packages.find]
where = src

Expand All @@ -53,12 +62,3 @@ max-line-length = 119
# E226: missing whitespace around arithmetic operator
# W503: line break occurred before a binary operator
ignore = E133,E226,W503

# ignore = E121,E123,E126,E226,E24,E704,W503,W504,C901

[isort]
combine_as_imports = true
include_trailing_comma = true
line_length = 79
multi_line_output = 3
not_skip = __init__.py
4 changes: 0 additions & 4 deletions setup.py

This file was deleted.

Loading