Skip to content

Commit

Permalink
refactor: update template (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
12rambau authored Jan 3, 2025
2 parents 56370ee + dba6778 commit 8c1be6f
Show file tree
Hide file tree
Showing 15 changed files with 107 additions and 95 deletions.
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier
_commit: 0.1.11
_commit: 0.1.16
_src_path: gh:12rambau/pypackage
author_email: [email protected]
author_first_name: Pierrick
Expand Down
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": "python -m pip install commitizen && pre-commit install"
"postCreateCommand": "python -m pip install commitizen uv && pre-commit install"
}
9 changes: 5 additions & 4 deletions .github/workflows/pypackage_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ name: template update check

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

env:
PIP_ROOT_USER_ACTION: ignore

jobs:
check_version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: install dependencies
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
release:
types: [created]

env:
PIP_ROOT_USER_ACTION: ignore

jobs:
tests:
uses: ./.github/workflows/unit.yaml
Expand All @@ -12,12 +15,12 @@ jobs:
needs: [tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.11"
- name: Install dependencies
run: pip install twine build nox
run: pip install twine build nox[uv]
- name: update citation date
run: nox -s release-date
- name: Build and publish
Expand Down
34 changes: 19 additions & 15 deletions .github/workflows/unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,42 @@ on:
- main
pull_request:

env:
FORCE_COLOR: 1
PIP_ROOT_USER_ACTION: ignore

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.11"
- uses: pre-commit/[email protected]

mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.11"
- name: Install nox
run: pip install nox
run: pip install nox[uv]
- name: run mypy checks
run: nox -s mypy

docs:
needs: [lint, mypy]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.11"
- name: Install nox
run: pip install nox
run: pip install nox[uv]
- name: build static docs
run: nox -s docs

Expand All @@ -56,13 +60,13 @@ jobs:
python-version: "3.11"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install nox
run: pip install nox
run: pip install nox[uv]
- name: test with pytest
run: nox -s ci-test
- name: assess dead fixtures
Expand All @@ -84,7 +88,7 @@ jobs:
name: coverage
path: coverage.xml
- name: codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
38 changes: 14 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
default_install_hook_types: [pre-commit, commit-msg]

repos:
- repo: "https://github.com/psf/black"
rev: "22.3.0"
hooks:
- id: black
stages: [commit]

- repo: "https://github.com/commitizen-tools/commitizen"
rev: "v2.18.0"
hooks:
Expand All @@ -17,38 +11,34 @@ repos:
rev: "0.5.0"
hooks:
- id: nbstripout
stages: [commit]
stages: [pre-commit]

- repo: "https://github.com/pre-commit/mirrors-prettier"
rev: "v2.7.1"
- repo: "https://github.com/pycontribs/mirrors-prettier"
rev: "v3.4.2"
hooks:
- id: prettier
stages: [commit]
stages: [pre-commit]
exclude: tests\/test_.+\.

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.215"
rev: "v0.7.0"
hooks:
- id: ruff
stages: [commit]

- repo: https://github.com/PyCQA/doc8
rev: "v1.1.1"
hooks:
- id: doc8
stages: [commit]
stages: [pre-commit]
- id: ruff-format
stages: [pre-commit]

- repo: https://github.com/FHPythonUtils/LicenseCheck
rev: "2023.5.1"
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: "v1.0.0"
hooks:
- id: licensecheck
stages: [commit]
- id: sphinx-lint
stages: [pre-commit]

- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
- id: codespell
stages: [commit]
stages: [pre-commit]
additional_dependencies:
- tomli

Expand All @@ -57,5 +47,5 @@ repos:
rev: v4.3.0
hooks:
- id: check-merge-conflict
stages: [commit]
stages: [pre-commit]
args: [--assume-in-merge]
28 changes: 15 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,46 +1,48 @@
PyGADM
======

.. image:: https://img.shields.io/badge/License-MIT-yellow?logo=opensourceinitiative&logoColor=white
.. |license| image:: https://img.shields.io/badge/License-MIT-yellow.svg?logo=opensourceinitiative&logoColor=white
:target: LICENSE
:alt: License: MIT

.. image:: https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow?logo=git&logoColor=white
.. |commit| image:: https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?logo=git&logoColor=white
:target: https://conventionalcommits.org
:alt: conventional commit

.. image:: https://img.shields.io/badge/code%20style-black-000000?logo=ford&logoColor=white
:target: https://github.com/psf/black
:alt: Black badge
.. |ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
:target: https://github.com/astral-sh/ruff
:alt: ruff badge

.. image:: https://img.shields.io/badge/code_style-prettier-ff69b4?logo=prettier&logoColor=white
.. |prettier| image:: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?logo=prettier&logoColor=white
:target: https://github.com/prettier/prettier
:alt: prettier badge

.. image:: https://img.shields.io/badge/pre--commit-active-yellow?logo=pre-commit&logoColor=white
.. |pre-commmit| image:: https://img.shields.io/badge/pre--commit-active-yellow?logo=pre-commit&logoColor=white
:target: https://pre-commit.com/
:alt: pre-commit

.. image:: https://img.shields.io/pypi/v/pygadm?color=blue&logo=python&logoColor=white
.. |pypi| image:: https://img.shields.io/pypi/v/pygadm?color=blue&logo=pypi&logoColor=white
:target: https://pypi.org/project/pygadm/
:alt: PyPI version

.. image:: https://img.shields.io/conda/vn/conda-forge/pygadm?color=blue&logo=anaconda&logoColor=white
.. |conda| image:: https://img.shields.io/conda/vn/conda-forge/pygadm?color=blue&logo=anaconda&logoColor=white
:target: https://anaconda.org/conda-forge/pygadm
:alt: Conda Version

.. image:: https://img.shields.io/github/actions/workflow/status/12rambau/pygadm/unit.yaml?logo=github&logoColor=white
.. |build| image:: https://img.shields.io/github/actions/workflow/status/12rambau/pygadm/unit.yaml?logo=github&logoColor=white
:target: https://github.com/12rambau/pygadm/actions/workflows/unit.yaml
:alt: build

.. image:: https://img.shields.io/codecov/c/github/12rambau/pygadm?logo=codecov&logoColor=white
.. |coverage| image:: https://img.shields.io/codecov/c/github/12rambau/pygadm?logo=codecov&logoColor=white
:target: https://codecov.io/gh/12rambau/pygadm
:alt: Test Coverage

.. image:: https://img.shields.io/readthedocs/pygadm?logo=readthedocs&logoColor=white
.. |docs| image:: https://img.shields.io/readthedocs/pygadm?logo=readthedocs&logoColor=white
:target: https://pygadm.readthedocs.io/en/latest/
:alt: Documentation Status

|license| |commit| |ruff| |prettier| |pre-commmit| |pypi| |conda| |build| |coverage| |docs|

Overview
--------

Expand Down Expand Up @@ -75,4 +77,4 @@ and then request area of interest from their name or GADM Id:
Credits
-------

This package was created with `Copier <https://copier.readthedocs.io/en/latest/>`__ and the `@12rambau/pypackage <https://github.com/12rambau/pypackage>`__ 0.1.11 project template.
This package was created with `Copier <https://copier.readthedocs.io/en/latest/>`__ and the `@12rambau/pypackage <https://github.com/12rambau/pypackage>`__ 0.1.16 project template.
16 changes: 16 additions & 0 deletions docs/_static/custom-icon.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/_template/pypackage-credit.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p class="pypackage-credit">
From
<a href="https://github.com/12rambau/pypackage">@12rambau/pypackage</a>
0.1.11 Copier project.
0.1.16 Copier project.
</p>
6 changes: 6 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
"url": "https://pypi.org/project/pygadm",
"icon": "fa-brands fa-python",
},
{
"name": "Conda",
"url": "https://anaconda.org/conda-forge/pygadm",
"icon": "fa-custom fa-conda",
"type": "fontawesome",
},
],
}
html_context = {
Expand Down
24 changes: 12 additions & 12 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
The nox run are build in isolated environment that will be stored in .nox. to force the venv update, remove the .nox/xxx folder.
"""

import datetime
import fileinput

Expand All @@ -10,37 +11,36 @@
nox.options.sessions = ["lint", "test", "docs", "mypy"]


@nox.session(reuse_venv=True)
@nox.session(reuse_venv=True, venv_backend="uv")
def lint(session):
"""Apply the pre-commits."""
session.install("pre-commit")
session.run("pre-commit", "run", "--all-files", *session.posargs)


@nox.session(reuse_venv=True)
@nox.session(reuse_venv=True, venv_backend="uv")
def test(session):
"""Run the selected tests and report coverage in html."""
session.install(".[test]")
test_files = session.posargs or ["tests"]
session.run("pytest", "--color=yes", "--cov", "--cov-report=html", *test_files)
session.run("pytest", "--cov", "--cov-report=html", *test_files)


@nox.session(reuse_venv=True, name="ci-test")
@nox.session(reuse_venv=True, name="ci-test", venv_backend="uv")
def ci_test(session):
"""Run all the test and report coverage in xml."""
session.install(".[test]")
session.posargs[0] if session.posargs else "default"
session.run("pytest", "--color=yes", "--cov", "--cov-report=xml")
session.run("pytest", "--cov", "--cov-report=xml")


@nox.session(reuse_venv=True, name="dead-fixtures")
@nox.session(reuse_venv=True, name="dead-fixtures", venv_backend="uv")
def dead_fixtures(session):
"""Check for dead fixtures within the tests."""
session.install(".[test]")
session.run("pytest", "--dead-fixtures")


@nox.session(reuse_venv=True)
@nox.session(reuse_venv=True, venv_backend="uv")
def docs(session):
"""Build the documentation."""
build = session.posargs.pop() if session.posargs else "html"
Expand All @@ -50,23 +50,23 @@ def docs(session):
session.run("python", "tests/check_warnings.py")


@nox.session(name="mypy", reuse_venv=True)
@nox.session(name="mypy", reuse_venv=True, venv_backend="uv")
def mypy(session):
"""Run a mypy check of the lib."""
session.install("mypy")
session.install("mypy", "types-deprecated")
test_files = session.posargs or ["pygadm"]
session.run("mypy", *test_files)


@nox.session(reuse_venv=True)
@nox.session(reuse_venv=True, venv_backend="uv")
def stubgen(session):
"""Generate stub files for the lib but requires human attention before merge."""
session.install("mypy")
package = session.posargs or ["pygadm"]
session.run("stubgen", "-p", package[0], "-o", "stubs", "--include-private")


@nox.session(name="release-date", reuse_venv=True)
@nox.session(name="release-date", reuse_venv=True, venv_backend="uv")
def release_date(session):
"""Update the release date of the citation file."""
current_date = datetime.datetime.now().strftime("%Y-%m-%d")
Expand Down
Loading

0 comments on commit 8c1be6f

Please sign in to comment.