Skip to content

Commit

Permalink
fix: rely on pypackage copier template for structure (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
12rambau authored Nov 14, 2023
1 parent d381d66 commit 8d44bd2
Show file tree
Hide file tree
Showing 14 changed files with 163 additions and 45 deletions.
12 changes: 12 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changes here will be overwritten by Copier
_commit: 0.1.5
_src_path: gh:12rambau/pypackage
author_email: [email protected]
author_first_name: Pierrick
author_last_name: Rambaud
author_orcid: 0000-0001-8764-5749
github_repo_name: pytest-copie
github_user: 12rambau
project_name: pytest-copie
project_slug: pytest_copie
short_description: The pytest plugin for your copier templates 📒
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"ghcr.io/devcontainers-contrib/features/nox:2": {},
"ghcr.io/devcontainers-contrib/features/pre-commit:2": {}
},
"postCreateCommand": "pip install commitizen && pre-commit install"
"postCreateCommand": "pre-commit install"
}
52 changes: 52 additions & 0 deletions .github/workflows/pypackage_check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: template update check

on:
workflow_dispatch:
schedule:
- cron: "0 0 1 * *" # Run at 00:00 on the first day of each month

jobs:
check_version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: install dependencies
run: pip install requests
- name: get latest pypackage release
id: get_latest_release
run: |
RELEASE=$(curl -s https://api.github.com/repos/12rambau/pypackage/releases | jq -r '.[0].tag_name')
echo "latest=$RELEASE" >> $GITHUB_OUTPUT
echo "latest release: $RELEASE"
- name: get current pypackage version
id: get_current_version
run: |
RELEASE=$(yq -r "._commit" .copier-answers.yml)
echo "current=$RELEASE" >> $GITHUB_OUTPUT
echo "current release: $RELEASE"
- name: open issue
if: steps.get_current_version.outputs.current != steps.get_latest_release.outputs.latest
uses: rishabhgupta/git-action-issue@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "Update template to ${{ steps.get_latest_release.outputs.latest }}"
body: |
The package is based on the ${{ steps.get_current_version.outputs.current }} version of [@12rambau/pypackage](https://github.com/12rambau/pypackage).
The latest version of the template is ${{ steps.get_latest_release.outputs.latest }}.
Please consider updating the template to the latest version to include all the latest developments.
Run the following code in your project directory to update the template:
```
copier update --trust --defaults --vcs-ref ${{ steps.get_latest_release.outputs.latest }}
```
> **Note**
> You may need to reinstall ``copier`` and ``jinja2-time`` if they are not available in your environment.
After solving the merging issues you can push back the changes to your main branch.
7 changes: 3 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ jobs:
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine build
run: pip install twine build nox
- name: update citation date
run: nox -s release-date
- name: Build and publish
env:
TWINE_USERNAME: __token__
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/unit.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Unit tests

on:
push:
Expand Down Expand Up @@ -74,13 +74,11 @@ jobs:
with:
python-version: "3.10"
- name: Install deps
run: pip install nox coverage[toml]
run: pip install nox
- name: test with pytest
run: nox -s test
- name: assess dead fixtures
run: nox -s dead-fixtures
- name: coverage
run: coverage xml
- name: codecov
uses: codecov/codecov-action@v3
with:
Expand Down
19 changes: 14 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ repos:
- id: doc8
stages: [commit]

- repo: https://github.com/FHPythonUtils/LicenseCheck
rev: "2023.1.1"
hooks:
- id: licensecheck
stages: [commit]
# too many deps are on GPL at the moment I'll work on it if needed later
#- repo: https://github.com/FHPythonUtils/LicenseCheck
# rev: "2023.5.1"
# hooks:
# - id: licensecheck
# stages: [commit]

- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
Expand All @@ -51,3 +52,11 @@ repos:
stages: [commit]
additional_dependencies:
- tomli

# Prevent committing inline conflict markers
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-merge-conflict
stages: [commit]
args: [--assume-in-merge]
3 changes: 0 additions & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ build:
os: ubuntu-22.04
tools:
python: "3.10"
jobs:
pre_build:
- sphinx-apidoc -o docs/api pytest_copie

sphinx:
configuration: docs/conf.py
Expand Down
15 changes: 13 additions & 2 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@ Thanks goes to these wonderful people (`emoji key <https://allcontributors.org/d

.. raw:: html

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
<table class="table table-bordered">
<tr>
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<td align="center">
<a href="#">
<img src="https://github.com/12rambau.png" width="70px;" alt="12rambau"/><br />
<sub><b>Pierrick Rambaud</b></sub>
</a>
<a href="#code" title="Code">💻</a>
</td>
<!-- ALL-CONTRIBUTORS-LIST:END -->
</tr>
</table>

This project follows the `all-contributors <https://allcontributors.org>`_ specification.

Expand Down
12 changes: 10 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
def lint(session):
"""Apply the pre-commits."""
session.install("pre-commit")
session.run("pre-commit", "run", "--a", *session.posargs)
session.run("pre-commit", "run", "--all-files", *session.posargs)


@nox.session(reuse_venv=True)
def test(session):
"""Run all the test using the environment variable of the running machine."""
session.install(".[test]")
test_files = session.posargs or ["tests"]
session.run("coverage", "run", "-m", "pytest", "--color=yes", *test_files)
session.run("pytest", "--color=yes", "--cov", "--cov-report=xml", *test_files)


@nox.session(reuse_venv=True, name="dead-fixtures")
Expand All @@ -46,3 +46,11 @@ def mypy(session):
session.install("mypy")
test_files = session.posargs or ["pytest_copie"]
session.run("mypy", *test_files)


@nox.session(reuse_venv=True)
def stubgen(session):
"""Generate stub files for the lib but requires human attention before merge."""
session.install("mypy")
package = session.posargs or ["pytest_copie"]
session.run("stubgen", "-p", package[0], "-o", "stubs", "--include-private")
41 changes: 22 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
[build-system]
requires = ["setuptools>=61.2", "wheel"]
build-backend = "setuptools.build_meta"
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "pytest-copie"
version = "0.1.3"
description = "The pytest plugin for your Copier templates."
keywords = ["Python", "pytest", "pytest-plugin", "copier"]
description = "The pytest plugin for your copier templates 📒"
keywords = [
"Python",
"pytest",
"pytest-plugin",
"copier"
]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
Expand All @@ -21,7 +26,7 @@ dependencies = [
"deprecated>=1.2.14",
"copier",
"pytest",
]
]

[[project.authors]]
name = "Pierrick Rambaud"
Expand All @@ -41,15 +46,10 @@ Homepage = "https://github.com/12rambau/pytest-copie"
copie = "pytest_copie.plugin"

[project.optional-dependencies]
dev = [
"pre-commit",
"commitizen",
"nox"
]
test = [
"pytest",
"coverage",
"pytest-sugar",
"pytest-cov",
"pytest-deadfixtures"
]
doc = [
Expand All @@ -60,13 +60,16 @@ doc = [
"sphinxemoji",
]

[tool.setuptools]
include-package-data = false
license-files = ["LICENSE.txt"]
[tool.hatch.build.targets.wheel]
only-include = ["pytest_copie"]

[tool.setuptools.packages.find]
include = ["pytest_copie*"]
exclude = ["docs*", "tests*"]
[tool.hatch.envs.default]
dependencies = [
"pre-commit",
"commitizen",
"nox"
]
post-install-commands = ["pre-commit install"]

[tool.commitizen]
tag_format = "v$major.$minor.$patch$prerelease"
Expand All @@ -75,7 +78,7 @@ version = "0.1.3"
version_files = [
"pyproject.toml:version",
"pytest_copie/__init__.py:__version__",
"docs/conf.py:release"
"docs/conf.py:release",
]

[tool.pytest.ini_options]
Expand Down Expand Up @@ -110,7 +113,7 @@ non_interactive = true
warn_redundant_casts = true

[tool.licensecheck]
using = "PEP631:test;dev;doc"
using = "PEP631"

[tool.codespell]
ignore-words-list = "copie"
1 change: 1 addition & 0 deletions pytest_copie/py.typed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Marker file for PEP 561. The mypy package uses inline types.
5 changes: 0 additions & 5 deletions setup.py

This file was deleted.

3 changes: 3 additions & 0 deletions stubs/pytest_copie/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__version__: str
__author__: str
__email__: str
30 changes: 30 additions & 0 deletions stubs/pytest_copie/plugin.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from dataclasses import dataclass
from pathlib import Path
from typing import Generator, Optional, Union

@dataclass
class Result:
exception: Union[Exception, SystemExit, None] = ...
exit_code: Union[str, int, None] = ...
project_dir: Optional[Path] = ...
answers: dict = ...
def __repr__(self) -> str: ...
def __init__(self, exception, exit_code, project_dir, answers) -> None: ...

@dataclass
class Copie:
default_template_dir: Path
test_dir: Path
config_file: Path
counter: int = ...
def copy(
self, extra_answers: dict = ..., template_dir: Optional[Path] = ...
) -> Result: ...
def __init__(
self, default_template_dir, test_dir, config_file, counter
) -> None: ...

def _copier_config_file(tmp_path_factory) -> Path: ...
def copie(request, tmp_path: Path, _copier_config_file: Path) -> Generator: ...
def pytest_addoption(parser) -> None: ...
def pytest_configure(config) -> None: ...

0 comments on commit 8d44bd2

Please sign in to comment.