Skip to content

Commit

Permalink
build: put on copier clothes
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Nov 16, 2024
1 parent fbb5371 commit 45db1c0
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 60 deletions.
21 changes: 21 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Changes here will be overwritten by Copier
_commit: v1.6.4
_src_path: .\copier-phil65\
author_email: [email protected]
author_fullname: Philipp Temminghoff
author_username: phil65
copyright_date: '2024'
copyright_holder: Philipp Temminghoff
copyright_holder_email: [email protected]
libraries_use_pydantic: false
libraries_use_qt: false
project_description: Enhanced YAML loading and dumping.
project_name: yamling
python_minimum_version: '3.12'
python_package_command_line_name: yamling
python_package_distribution_name: yamling
python_package_import_name: yamling
repository_name: yamling
repository_namespace: phil65
repository_provider: github.com

3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
github: phil65
custom:
- https://www.paypal.me/phil65
9 changes: 4 additions & 5 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@

You can assume Python 3.12.
Use newest language features if possible
Consider using pattern matching, walrus operators and other new syntax features.
Adhere to pep8.
Consider using pattern matching and walrus operators.

## Tests

Tests are written using PyTest.

Tests are written using PyTest. Dont put tests into a class.

## DocStrings

DocStrings are written in google-style.
Dont add the types to the Args section.
Dont add the types to the "Args" section.
Only add a Return section if a value is returned and the meaning of the returned value
is not obvious.
You can use markdown admonitions with python-markdown syntax (!!! info, !!! note, !!! warning)
You can use markdown admonitions with python-markdown syntax if neccessary (!!! info, !!! note, !!! warning).
You can use markdown tables and markdown lists if neccessary.
33 changes: 21 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.python_version == '3.14' }}
strategy:
matrix:
python_version: ["3.12", "3.13"]

python_version: ["3.12", "3.13", "3.14"]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
steps:
- name: Check out repository
uses: actions/checkout@v4
Expand All @@ -17,12 +18,17 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
allow-prereleases: true

- name: Install uv
uses: yezz123/setup-uv@v4
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: pyproject.toml
cache-suffix: py${{ matrix.python_version }}

- name: Install dependencies (uv sync)
run: uv sync --all-extras
run: uv sync --all-extras --no-group docs

- name: Check for code issues (ruff check)
uses: astral-sh/ruff-action@v1
Expand All @@ -33,15 +39,14 @@ jobs:
args: "format --check"

- name: Static type checking (MyPy)
run: uv run mypy src/yamling/
run: uv run --no-group docs mypy src/yamling/

- name: Run tests
run: uv run pytest --cov-report=xml
run: uv run --no-group docs pytest --cov-report=xml --cov=src/yamling/ --cov-report=term-missing

- name: Upload test results to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verbose: true

Expand All @@ -63,13 +68,17 @@ jobs:
python-version: "3.12"

- name: Install uv
uses: yezz123/setup-uv@v4
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: pyproject.toml
cache-suffix: py${{ matrix.python_version }}

- name: Build package
run: uv build

- name: Release package on PyPI
run: uv publish
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

- name: Release package on GitHub
uses: ncipollo/release-action@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
with:
python-version: "3.12"
- name: Install uv
uses: yezz123/setup-uv@v4
uses: astral-sh/setup-uv@v3
- name: Install dependencies
run: |
uv sync --all-extras
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ __pycache__/
*.sublime-workspace
# Unit test / coverage reports
.coverage
coverage.xml
.cache
.hatch
.pytest_cache/
Expand Down
15 changes: 7 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,26 @@ repos:
types: [python]
pass_filenames: false
always_run: true

- repo: https://github.com/pre-commit/pre-commit-hooks
# https://pre-commit.com/hooks.html
rev: v5.0.0
hooks:
# - id: trailing-whitespace
# - id: check-ast
- id: check-added-large-files
- id: check-case-conflict
- id: check-docstring-first
- id: check-merge-conflict
# - id: check-yaml
- id: check-toml
- id: check-json
- id: check-xml
- id: check-yaml
args: [--allow-multiple-documents, --unsafe]
- id: debug-statements
- id: detect-private-key
- id: forbid-new-submodules
# - id: check-added-large-files
# https://pre-commit.com/hooks.html

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
# args: [--ignore-missing-imports]
additional_dependencies: [orjson]

- repo: https://github.com/charliermarsh/ruff-pre-commit
Expand Down
3 changes: 1 addition & 2 deletions duties.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ def update(ctx):
"""Update all environment packages using pip directly."""
ctx.run("uv lock --upgrade")
ctx.run("uv sync --all-extras")
ctx.run("uv pip install google-generativeai")


@duty(capture=False)
def lint(ctx):
"""Lint the code and fix issues if possible."""
ctx.run("uv run ruff check --fix .")
ctx.run("uv run ruff check --fix --unsafe-fixes .")
ctx.run("uv run ruff format .")
ctx.run("uv run mypy src/yamling/")

Expand Down
24 changes: 11 additions & 13 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
site_name: YAMLing
site_name: "yamling"
site_description: "Enhanced YAML loading and dumping."
repo_url: "https://github.com/phil65/yamling/"
site_url: https://phil65.github.io/yamling/
site_author: Philipp Temminghoff
site_author: "Philipp Temminghoff"
copyright: Copyright © 2024 Philipp Temminghoff

theme:
Expand Down Expand Up @@ -57,15 +57,7 @@ theme:
plugins:
- search
- autorefs
- mknodes:
build_fn: yamling.manual:Build.build
# global_resources: false
render_by_default: false
# jinja_loaders:
# - type: filesystem
# searchpath: docs
# - type: template_file
# path: templates.toml
- mknodes
- mkdocstrings:
default_handler: python
handlers:
Expand All @@ -75,6 +67,7 @@ plugins:
domains: [std, py]
options:
# https://mkdocstrings.github.io/python/usage/
enable_inventory: !ENV [CI, false]
show_signature_annotations: true
show_symbol_type_toc: true
show_symbol_type_heading: true
Expand All @@ -85,10 +78,15 @@ plugins:
signature_crossrefs: true
separate_signature: true
line_length: 90
preload_modules:
- mknodes
markdown_extensions:
- attr_list
- pymdownx.emoji
- toc:
permalink: true

extra:
social:
- icon: fontawesome/brands/github
link: https://github.com/phil65
- icon: fontawesome/brands/python
link: https://pypi.org/project/yamling/
54 changes: 35 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ build-backend = "hatchling.build"

[project]
name = "yamling"
description = "Enhanced YAML loading and dumping."
authors = [
{ name = "Philipp Temminghoff", email = "philipptemminghoff@gmail.com" },
{ name = "Philipp Temminghoff", email = "philipptemminghoff@googlemail.com" },
]
description = "Enhanced YAML loading and dumping."
readme = "README.md"
dynamic = ["version"]
classifiers = [
Expand All @@ -29,29 +29,46 @@ classifiers = [
]
keywords = ["yaml", "PyYAML", "include", "yml", "serialization"]
requires-python = ">=3.12"
dependencies = ["PyYAML >=5.1", "pyyaml-include", "fsspec", "universal_pathlib"]
license = "MIT"
dependencies = [

# Only add below (Copier)
"PyYAML >=5.1",
"pyyaml-include",
"fsspec",
"universal_pathlib",
]
license = { file = "LICENSE" }

[tool.uv]
dev-dependencies = [
# lint
"ruff",
"mypy[faster-cache]",
# test
default-groups = ["dev", "lint", "docs"]

[dependency-groups]
dev = [
"pytest",
"pytest-cov",
# docs
"mkdocs-material",
"mkdocs-mknodes",
# dev
"pyreadline3",
"pyinstrument",
"jinja2>=3.1.4",
"devtools",
# Only add below (Copier)
]
benchmark = ["pyinstrument"]
lint = [
"ruff",
"mypy[faster-cache]; python_version < '3.14'",
"mypy; python_version >= '3.14'",
# Only add below (Copier)
]
docs = [
"mkdocs-mknodes",
"mkdocs-material",
# Only add below (Copier)
]

[project.urls]
Documentation = "https://phil65.github.io/yamling/"
Source = "https://github.com/phil65/yamling"
Issues = "https://github.com/phil65/yamling/issues"
Discussions = "https://github.com/phil65/yamling/discussions"
"Code coverage" = "https://app.codecov.io/gh/phil65/yamling"

[project.entry-points.toolreg_functions]
dump_file = "yamling:dump_file"
Expand All @@ -65,11 +82,9 @@ dump = "yamling:dump"

[tool.pytest.ini_options]
testpaths = "tests/"
log_cli = false
log_level = "ERROR"
log_cli = true
log_format = "%(asctime)s %(levelname)s %(message)s"
log_date_format = "%Y-%m-%d %H:%M:%S"
addopts = "--cov=yamling/ --cov-report=term-missing --cov-report=xml"

[tool.coverage.report]
exclude_lines = [
Expand All @@ -82,11 +97,11 @@ exclude_lines = [

[tool.mypy]
python_version = "3.12"
# python_executable = ".venv/env/virtual/yamling/Scripts/python.exe"
disable_error_code = ["misc", "import"]
pretty = true
check_untyped_defs = true
exclude = ['venv/', '.venv/', 'tests/']
plugins = []

[tool.ruff]
line-length = 90
Expand Down Expand Up @@ -217,6 +232,7 @@ reportUnknownVariableType = false
reportAny = false
reportImplicitOverride = false
reportUnusedFunction = false
reportImplicitStringConcatenation = false

[tool.mknodes]
allowed-commit-types = [
Expand Down

0 comments on commit 45db1c0

Please sign in to comment.