Compare commits

..

No commits in common. "21eb0c065dbc93488d38578614e1a507ae69dfe3" and "d8a950948c7fe0d63dbae37e69129c9a649c91b6" have entirely different histories.

10 changed files with 55 additions and 192 deletions

View File

@ -1,34 +0,0 @@
name: CI
on:
push:
branches: [master]
tags: ['v*.*.*']
jobs:
test:
name: Test
uses: daniil-berg/reusable-workflows/.github/workflows/python-test.yaml@v0.2.1
with:
versions: '["3.9", "3.10", "3.11"]'
unittest-command: 'scripts/test.sh'
coverage-command: 'scripts/cov.sh'
unittest-requirements: "-e '.[dev]'"
typecheck-command: 'scripts/typecheck.sh'
typecheck-requirements: '-Ur requirements/dev.txt'
typecheck-all-versions: true
lint-command: 'scripts/lint.sh'
lint-requirements: '-Ur requirements/dev.txt'
release:
name: Release
if: ${{ github.ref_type == 'tag' }}
needs: test
uses: daniil-berg/reusable-workflows/.github/workflows/python-release.yaml@v0.2.1
with:
git-ref: ${{ github.ref_name }}
secrets:
release-token: ${{ secrets.TOKEN_GITHUB_CREATE_RELEASE }}
publish-token: ${{ secrets.TOKEN_PYPI_PROJECT }}
permissions:
contents: write

View File

@ -26,23 +26,13 @@ extra_css:
plugins: plugins:
- search - search
- mkdocstrings: - mkdocstrings
handlers:
python:
options:
line_length: 80
show_source: false
show_root_toc_entry: false
separate_signature: true
show_signature_annotations: true
markdown_extensions: markdown_extensions:
- admonition - admonition
- codehilite - codehilite
- extra - extra
- pymdownx.superfences - pymdownx.superfences
- toc:
permalink: true
nav: nav:
- Home: index.md - Home: index.md

View File

@ -9,14 +9,14 @@ build-backend = "setuptools.build_meta"
name = "${REPO_NAME}" name = "${REPO_NAME}"
description = "${REPO_DESCRIPTION}" description = "${REPO_DESCRIPTION}"
authors = [ authors = [
{ name = "${REPO_OWNER_TITLE}", email = ... }, { name = "${REPO_OWNER_TITLE}", email = "mail@PLACEHOLDER.to" },
] ]
maintainers = [ maintainers = [
{ name = "${REPO_OWNER_TITLE}", email = ... }, { name = "${REPO_OWNER_TITLE}", email = "mail@PLACEHOLDER.to" },
] ]
requires-python = ">=3.9, <4.0" requires-python = ">=3.9, <4.0"
keywords = [ keywords = [
...
] ]
license = { text = "Apache Software License Version 2.0" } license = { text = "Apache Software License Version 2.0" }
classifiers = [ classifiers = [
@ -30,7 +30,6 @@ classifiers = [
# "Intended Audience :: Developers", # "Intended Audience :: Developers",
# "Framework :: AsyncIO", # "Framework :: AsyncIO",
# "Topic :: Internet", # "Topic :: Internet",
...
] ]
dynamic = [ dynamic = [
"dependencies", "dependencies",
@ -40,34 +39,32 @@ dynamic = [
[project.optional-dependencies] [project.optional-dependencies]
full = [ full = [
...
] ]
dev = [ dev = [
"black==23.3.0", "black",
"build==0.10.0", "build",
"coverage[toml]==7.2.7", "coverage[toml]",
"isort==5.12.0", "flake8",
"mkdocs-material==9.1.17", "mkdocs-material",
"mkdocstrings[python]==0.22.0", "mkdocstrings[python]",
"mypy==1.4.0", "mypy",
"ruff==0.0.275",
] ]
[project.urls] [project.urls]
"Repository" = "https://github.com/${REPO_OWNER_LOWER}/${REPO_NAME_LOWER}" repository = "https://github.com/${REPO_OWNER_LOWER}/${REPO_NAME_LOWER}"
"Issue Tracker" = "https://github.com/${REPO_OWNER_LOWER}/${REPO_NAME_LOWER}/issues" bug_tracker = "https://github.com/${REPO_OWNER_LOWER}/${REPO_NAME_LOWER}/issues"
"Documentation" = "http://${REPO_OWNER_LOWER}.github.io/${REPO_NAME_LOWER}" documentation = "http://${REPO_OWNER_LOWER}.github.io/${REPO_NAME_LOWER}"
[tool.setuptools.dynamic] [tool.setuptools.dynamic]
dependencies = { file = "requirements/common.txt" } dependencies = { file = "requirements/common.txt" }
readme = { file = ["README.md"], content-type = "text/markdown" } readme = { file = ["README.md"] }
version = {attr = ..."${REPO_NAME}.__version__"} version = {attr = "PACKAGE_NAME_PLACEHOLDER.__version__"}
######################### #########
# Static type checking: # # Mypy: #
[tool.mypy] [tool.mypy]
cache_dir = ".cache/mypy"
files = [ files = [
"src/", "src/",
"tests/", "tests/",
@ -76,14 +73,13 @@ warn_unused_configs = true
strict = true strict = true
show_error_codes = true show_error_codes = true
plugins = [ plugins = [
...
] ]
####################### #############
# Unit test coverage: # # Coverage: #
[tool.coverage.run] [tool.coverage.run]
data_file = ".cache/coverage"
source = [ source = [
"src/", "src/",
] ]
@ -104,45 +100,3 @@ exclude_lines = [
omit = [ omit = [
"tests/*", "tests/*",
] ]
###############################
# Linting and style checking: #
[tool.ruff]
cache-dir = ".cache/ruff"
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"D", # pydocstyle
"C", # flake8-comprehensions
"B", # flake8-bugbear
"PL", # pylint
"RUF", # ruff-specific
]
ignore = [
"E501", # Line too long -> handled by black
"D203", # 1 blank line required before class docstring -> D211 is better
"D212", # Multi-line docstring summary should start at the first line -> ugly, D212 is better
"D401", # First line of docstring should be in imperative mood -> no, it shouldn't
"D407", # Missing dashed underline after section -> different docstring style
]
[tool.ruff.per-file-ignores]
"src/**/__init__.py" = [
"D104", # Missing docstring in public package
"F401", # {...} imported but unused
]
"tests/*.py" = [
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
"D102", # Missing docstring in public method
"D104", # Missing docstring in public package
]
###################
# Import sorting: #
[tool.isort]
profile = "black"
extra_standard_library = ["typing_extensions"]

View File

@ -1,9 +1,8 @@
-r common.txt -r common.txt
black==23.3.0 black
build==0.10.0 build
coverage[toml]==7.2.7 coverage[toml]
isort==5.12.0 flake8
mkdocs-material==9.1.17 mkdocs-material
mkdocstrings[python]==0.22.0 mkdocstrings[python]
mypy==1.4.0 mypy
ruff==0.0.275

View File

@ -1,12 +0,0 @@
#!/usr/bin/env bash
# Runs full CI pipeline (test, typecheck, lint).
typeset scripts_dir="$(dirname $(realpath $0))"
source "${scripts_dir}/util.sh"
"${scripts_dir}/test.sh"
"${scripts_dir}/typecheck.sh"
"${scripts_dir}/lint.sh"
echo -e "${background_black}${bold_green}✅ 🎉 All checks passed!${color_reset}"

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# Runs unit tests.
# If successful, prints only the coverage percentage.
# If an error occurs, prints the entire unit tests progress output.
source "$(dirname $(realpath $0))/util.sh"
coverage erase
run_and_capture coverage run
coverage report | awk '$1 == "TOTAL" {print $NF; exit}'

View File

@ -1,17 +1,16 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Runs various linters. # Runs type checker and linters.
source "$(dirname $(realpath $0))/util.sh" # Ensure that we return to the current working directory
# and exit the script immediately in case of an error:
trap "cd $(realpath ${PWD}); exit 1" ERR
# Change into project root directory:
cd "$(dirname $(dirname $(realpath $0)))"
echo 'Performing type checks...'
mypy
echo
echo 'Linting source and test files...' echo 'Linting source and test files...'
flake8 src/ tests/
echo ' isort - consistent imports' echo -e 'No issues found.'
isort src/ tests/ --check-only
echo ' ruff - extensive linting'
ruff src/ tests/
echo ' black - consistent style'
run_and_capture black src/ tests/ --check
echo -e "${bold_green}No issues found${color_reset}\n"

View File

@ -1,12 +1,17 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Runs unit tests and reports coverage percentage. # Runs unit tests and prints only coverage percentage, if successful.
# If an error occurs, prints the entire unit tests progress output.
source "$(dirname $(realpath $0))/util.sh" # Ensure that we return to the current working directory in case of an error:
trap "cd $(realpath ${PWD})" ERR
# Change into project root directory:
cd "$(dirname $(dirname $(realpath $0)))"
echo 'Running unit tests...' coverage erase
coverage run # Capture the test progression in a variable:
typeset percentage typeset progress
typeset color progress=$(coverage run 2>&1)
percentage="$(coverage report | awk '$1 == "TOTAL" {print $NF; exit}')" # If tests failed or produced errors, write progress/messages to stderr and exit:
[[ $percentage == "100%" ]] && color="${bold_green}" || color="${yellow}" [[ $? -eq 0 ]] || { >&2 echo "${progress}"; exit 1; }
echo -e "${color}${percentage} coverage${color_reset}\n" # Otherwise extract the total coverage percentage from the produced report and write it to stdout:
coverage report | awk '$1 == "TOTAL" {print $NF; exit}'

View File

@ -1,8 +0,0 @@
#!/usr/bin/env bash
# Runs type checker.
source "$(dirname $(realpath $0))/util.sh"
echo 'Performing type checks...'
mypy
echo

View File

@ -1,20 +0,0 @@
run_and_capture() {
# Captures stderr of any command passed to it
# and releases it only if the command exits with a non-zero code.
typeset output
output=$($@ 2>&1)
typeset exit_status=$?
[[ $exit_status == 0 ]] || >&2 echo "${output}"
return $exit_status
}
# Ensure that we return to the current working directory
# and exit the script immediately in case of an error:
trap "cd $(realpath ${PWD}); exit 1" ERR
# Change into project root directory:
cd "$(dirname $(dirname $(realpath $0)))"
typeset background_black='\033[40m'
typeset bold_green='\033[1;92m'
typeset yellow='\033[0;33m'
typeset color_reset='\033[0m'