Skip to content

Commit

Permalink
Merge branch 'main' of github.com:pawamoy/copier-uv
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Oct 5, 2024
2 parents 0ab8eda + 537a2c5 commit 6796d92
Show file tree
Hide file tree
Showing 14 changed files with 160 additions and 129 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,15 @@ jobs:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Install Copier and uv
run: pip install copier copier-templates-extensions uv
- name: Setup uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: project/pyproject.toml.jinja
cache-suffix: py${{ matrix.python-version }}

- name: Install Copier
run: pip install copier copier-templates-extensions

- name: Test project generation and workflow
run: bash tests/test_project.sh
Expand All @@ -106,8 +113,14 @@ jobs:
with:
python-version: "3.12"

- name: Install Copier and uv
run: pip install copier copier-templates-extensions uv
- name: Setup uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: project/pyproject.toml.jinja

- name: Install Copier
run: pip install copier copier-templates-extensions

- name: Trigger and wait project's own CI
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ jobs:
- name: Prepare release notes
run: git-changelog --release-notes > release-notes.md
- name: Create release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
body_path: release-notes.md
37 changes: 31 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,34 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

<!-- insertion marker -->
## [1.1.4](https://github.com/pawamoy/copier-uv/releases/tag/1.1.4) - 2024-07-25
## [1.1.5](https://github.com/mkdocstrings/handler-template/releases/tag/1.1.5) - 2024-07-25

<small>[Compare with 1.1.3](https://github.com/pawamoy/copier-uv/compare/1.1.3...1.1.4)</small>
<small>[Compare with 1.1.3](https://github.com/mkdocstrings/handler-template/compare/1.1.3...1.1.4)</small>

### Merge upstream

#### Bug Fixes

- Fix make help message indentation ([addb51e](https://github.com/pawamoy/copier-uv/commit/addb51ed8daaeb19d40cd02665f8fc68bb02f4b8) by Timothée Mazzucotelli).
- Invalidate uv cache based on pyproject.toml ([b78ce88](https://github.com/pawamoy/copier-uv/commit/b78ce880c56b3e346d5b414bda89ac4a8cd22335) by Timothée Mazzucotelli).
- Better flush help message for make script ([fb2d373](https://github.com/pawamoy/copier-uv/commit/fb2d373b217c1d3c216b01f82e3db5c2f1542558) by Timothée Mazzucotelli).
- Better handle `gh` command error (when fetching "Documentation" category ID for discussions) ([896dfb3](https://github.com/pawamoy/copier-uv/commit/896dfb39ea6710b3965fd3162fa9b621f916d166) by Timothée Mazzucotelli).
- Disallow overrides when getting Git remote in docs-deploy duty ([cb0135b](https://github.com/pawamoy/copier-uv/commit/cb0135bf5bc80768fea17366efba35293c60ba93) by Timothée Mazzucotelli).

#### Code Refactoring

- Upgrade setup-uv action version ([cc2c350](https://github.com/pawamoy/copier-uv/commit/cc2c350d6f2c42025ed84afa5740a767ff82510b) by Timothée Mazzucotelli).
- Upgrade gh-release action version ([d26e9fa](https://github.com/pawamoy/copier-uv/commit/d26e9fa99f715e41642d26a32403fc934da4391d) by Timothée Mazzucotelli).
- Update ci and release workflows ([4692788](https://github.com/pawamoy/copier-uv/commit/46927885db4aad4658802707d1f34a129633b83e) by Timothée Mazzucotelli).
- Improve clean command ([d4dfab7](https://github.com/pawamoy/copier-uv/commit/d4dfab790dee59c335ac8907afd468a2cddd0169) by Timothée Mazzucotelli).
- Enable Git revision date docs plugin, remove Git committers plugin (vendor lock-in, requires GitHub token) ([c4907eb](https://github.com/pawamoy/copier-uv/commit/c4907eb96914914314bedf55d300179a790b827a) by Timothée Mazzucotelli).
- Don't show source code in docs when insiders ([5c57d92](https://github.com/pawamoy/copier-uv/commit/5c57d9213b22e3cebec01d3557ea779695bd50da) by Timothée Mazzucotelli).
- Clean up `check` duty (pre tasks) ([2e4dd5b](https://github.com/pawamoy/copier-uv/commit/2e4dd5b65ff49e45a6123a701ae572a6a15041aa) by Timothée Mazzucotelli).
- Use higher-level uv commands ([bf3c328](https://github.com/pawamoy/copier-uv/commit/bf3c328b8aefa1b5e33bb3bf55ff0039c9a436b1) by Timothée Mazzucotelli).

## [1.1.4](https://github.com/mkdocstrings/handler-template/releases/tag/1.1.4) - 2024-07-25

<small>[Compare with 1.1.3](https://github.com/mkdocstrings/handler-template/compare/1.1.3...1.1.4)</small>

### Merge upstream

Expand All @@ -22,18 +47,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Make sure `setup` returns non-0 exit code when uv fails to resolve dependencies ([ba5c4dc](https://github.com/pawamoy/copier-uv/commit/ba5c4dcc8128afa06abd1d2c679c263e4761fd59) by Timothée Mazzucotelli).
- Fix Twine dependency (5.1 has been yanked) ([e022917](https://github.com/pawamoy/copier-uv/commit/e022917f40db2e82c07f5b4a3e2eb31f947c48a6) by Timothée Mazzucotelli).

## [1.1.3](https://github.com/pawamoy/copier-uv/releases/tag/1.1.3) - 2024-06-18
## [1.1.3](https://github.com/mkdocstrings/handler-template/releases/tag/1.1.3) - 2024-06-18

<small>[Compare with 1.1.2](https://github.com/pawamoy/copier-uv/compare/1.1.2...1.1.3)</small>
<small>[Compare with 1.1.2](https://github.com/mkdocstrings/handler-template/compare/1.1.2...1.1.3)</small>

### Merge upstream

- Include almost everything in source distributions, to help system packagers ([064ffb0](https://github.com/pawamoy/copier-uv/commit/064ffb06b5f0e2039987116e443f67cf877965d1) by Timothée Mazzucotelli).
- Re-include tests folder in source distributions ([3d9a7e1](https://github.com/pawamoy/copier-uv/commit/3d9a7e17167294ee43673cafa615931614240235) by Timothée Mazzucotelli).

## [1.1.2](https://github.com/pawamoy/copier-uv/releases/tag/1.1.2) - 2024-05-25
## [1.1.2](https://github.com/mkdocstrings/handler-template/releases/tag/1.1.2) - 2024-05-25

<small>[Compare with 1.1.1](https://github.com/pawamoy/copier-uv/compare/1.1.1...1.1.2)</small>
<small>[Compare with 1.1.1](https://github.com/mkdocstrings/handler-template/compare/1.1.1...1.1.2)</small>

### Merge upstream

Expand Down
14 changes: 12 additions & 2 deletions extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,21 @@ def hook(self, context):

if self.repo_id is None:
command = f"gh api repos/{repository_namespace}/{repository_name} --jq .node_id"
self.repo_id = subprocess.getoutput(command).strip() or self.repo_placeholder
try:
process = subprocess.run(command, shell=True, check=True, text=True, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
except subprocess.CalledProcessError:
self.repo_id = self.repo_placeholder
else:
self.repo_id = process.stdout.strip() or self.repo_placeholder
context["giscus_repo_id"] = self.repo_id

if self.category_id is None:
jq_filter = "--jq '.data.repository.discussionCategories.nodes[] | select(.name == \"Documentation\") | .id'"
command = f"gh api graphql -f query='{self.query}' {jq_filter}" % {"owner": repository_namespace, "name": repository_name}
self.category_id = subprocess.getoutput(command).strip() or self.category_placeholder
try:
process = subprocess.run(command, shell=True, check=True, text=True, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
except subprocess.CalledProcessError:
self.category_id = self.category_placeholder
else:
self.category_id = process.stdout.strip() or self.category_placeholder
context["giscus_discussion_category_id"] = self.category_id
19 changes: 13 additions & 6 deletions project/.github/workflows/ci.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ jobs:
- name: Fetch all tags
run: git fetch --depth=1 --tags

- name: Set up Python
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install uv
run: pip install uv
- name: Setup uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: pyproject.toml

- name: Install dependencies
run: make setup
Expand Down Expand Up @@ -115,14 +118,18 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: {% raw %}${{ matrix.python-version }}{% endraw %}
allow-prereleases: true

- name: Install uv
run: pip install uv
- name: Setup uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: pyproject.toml
cache-suffix: {% raw %}py${{ matrix.python-version }}{% endraw %}

- name: Install dependencies
env:
Expand Down
12 changes: 6 additions & 6 deletions project/.github/workflows/release.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:
- name: Fetch all tags
run: git fetch --depth=1 --tags
- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
{%- if insiders %}
- name: Install build
if: github.repository_owner == '{{ author_username }}-insiders'
run: python -m pip install build
run: pip install build
- name: Build dists
if: github.repository_owner == '{{ author_username }}-insiders'
run: python -m build
run: pyproject-build
- name: Upload dists artifact
uses: actions/upload-artifact@v4
if: github.repository_owner == '{{ author_username }}-insiders'
Expand All @@ -35,12 +35,12 @@ jobs:
if: github.repository_owner != '{{ author_username }}-insiders'
run: git-changelog --release-notes > release-notes.md
- name: Create release with assets
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
if: github.repository_owner == '{{ author_username }}-insiders'
with:
files: ./dist/*
- name: Create release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
if: github.repository_owner != '{{ author_username }}-insiders'
with:
body_path: release-notes.md
Expand All @@ -50,7 +50,7 @@ jobs:
- name: Prepare release notes
run: git-changelog --release-notes > release-notes.md
- name: Create release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
body_path: release-notes.md
{%- endif %}
1 change: 1 addition & 0 deletions project/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/.pdm-build/
/htmlcov/
/site/
uv.lock

# cache
.cache/
Expand Down
33 changes: 0 additions & 33 deletions project/devdeps.txt.jinja

This file was deleted.

7 changes: 4 additions & 3 deletions project/duties.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def changelog(ctx: Context, bump: str = "") -> None:
ctx.run(tools.git_changelog(bump=bump or None), title="Updating changelog")


@duty(pre=["check_quality", "check_types", "check_docs", "check_dependencies", "check-api"])
def check(ctx: Context) -> None: # noqa: ARG001
@duty(pre=["check-quality", "check-types", "check-docs", "check-api"])
def check(ctx: Context) -> None:
"""Check it all!"""


Expand Down Expand Up @@ -123,12 +123,13 @@ def docs_deploy(ctx: Context) -> None:
if not insiders:
ctx.run(lambda: False, title="Not deploying docs without Material for MkDocs Insiders!")
{%- if insiders %}
origin = ctx.run("git config --get remote.origin.url", silent=True)
origin = ctx.run("git config --get remote.origin.url", silent=True, allow_overrides=False)
if "{{ author_username }}-insiders/{{ insiders_repository_name }}" in origin:
ctx.run(
"git remote add upstream [email protected]:{{ repository_namespace }}/{{ repository_name }}",
silent=True,
nofail=True,
allow_overrides=False,
)
ctx.run(
tools.mkdocs.gh_deploy(remote_name="upstream", force=True),
Expand Down
7 changes: 3 additions & 4 deletions project/mkdocs.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,15 @@ plugins:
show_root_heading: true
show_root_full_path: false
show_signature_annotations: true
show_source: {{ "false" if insiders else "true" }}
show_symbol_type_heading: true
show_symbol_type_toc: true
signature_crossrefs: true
summary: true
- git-committers:
- git-revision-date-localized:
enabled: !ENV [DEPLOY, false]
repository: {{ repository_namespace }}/{{ repository_name }}
{#- - git-revision-date-localized:
enable_creation_date: true
type: timeago #}
type: timeago
- minify:
minify_html: !ENV [DEPLOY, false]
- group:
Expand Down
37 changes: 36 additions & 1 deletion project/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ source-includes = [
"scripts",
"share",
"tests",
"devdeps.txt",
"duties.py",
"mkdocs.yml",
"*.md",
Expand All @@ -136,3 +135,39 @@ source-includes = [
data = [
{path = "share/**/*", relative-to = "."},
]

[tool.uv]
dev-dependencies = [
# dev
"editables>=0.5",

# maintenance
"build>=1.2",
"git-changelog>=2.5",
"twine>=5.0; python_version < '3.13'",

# ci
"duty>=1.4",
"ruff>=0.4",
"pytest>=8.2",
"pytest-cov>=5.0",
"pytest-randomly>=3.15",
"pytest-xdist>=3.6",
"mypy>=1.10",
"types-markdown>=3.6",
"types-pyyaml>=6.0",

# docs
"black>=24.4",
"markdown-callouts>=0.4",
"markdown-exec>=1.8",
"mkdocs>=1.6",
"mkdocs-coverage>=1.0",
"mkdocs-gen-files>=0.5",
"mkdocs-git-revision-date-localized-plugin>=1.2",
"mkdocs-literate-nav>=0.6",
"mkdocs-material>=9.5",
"mkdocs-minify-plugin>=0.8",
"mkdocstrings[python]>=0.25",
"tomli>=2.0; python_version < '3.11'",
]
3 changes: 1 addition & 2 deletions project/scripts/gen_credits.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ with project_dir.joinpath("pyproject.toml").open("rb") as pyproject_file:
pyproject = tomllib.load(pyproject_file)
project = pyproject["project"]
project_name = project["name"]
with project_dir.joinpath("devdeps.txt").open() as devdeps_file:
devdeps = [line.strip() for line in devdeps_file if line.strip() and not line.strip().startswith(("-e", "#"))]
devdeps = [dep for dep in pyproject["tool"]["uv"]["dev-dependencies"] if not dep.startswith("-e")]

PackageMetadata = Dict[str, Union[str, Iterable[str]]]
Metadata = Dict[str, PackageMetadata]
Expand Down
Loading

0 comments on commit 6796d92

Please sign in to comment.