Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .claude/scripts/test_setup_script_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
# to check that the rename reaches the Astro config and the API pages.
set -euo pipefail
REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
PYTHON="${PYTHON:-$REPO/.venv-docs/bin/python}"
PYTHON="${PYTHON:-$REPO/.venv/bin/python}"
WORK="$(mktemp -d)"
trap 'rm -rf "$WORK"' EXIT
rsync -a --exclude .git --exclude node_modules --exclude dist --exclude .astro --exclude .venv-docs "$REPO/" "$WORK/"
rsync -a --exclude .git --exclude node_modules --exclude dist --exclude .astro --exclude .venv "$REPO/" "$WORK/"
cd "$WORK"
bash setup_project.sh my-test-app
grep -q "const pythonPackage = 'my_test_app'" docs/astro.config.mjs
grep -q "/api/my_test_app/" docs/src/components/Header.astro
grep -q "/api/my_test_app/index.html" .github/workflows/docs.yml
grep -q "src/my_test_app/__init__.py" release-please-config.json
grep -q "source = \[ \"my_test_app\" \]" pyproject.toml
grep -q "from my_test_app.main import main" docs/src/content/docs/getting-started/quickstart.md
cp -cR "$REPO/docs/node_modules" docs/node_modules 2>/dev/null || cp -R "$REPO/docs/node_modules" docs/node_modules
cd docs && DOCS_PYTHON="$PYTHON" npm run build 2>&1 | tail -25
Expand Down
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: Bug report
about: Something does not work as documented
title: ""
labels: bug
assignees: ""
---

**Describe the bug**

...

**To reproduce**

```python
# the smallest script or command that shows the problem
```

**Expected behavior**

...

**Environment**

- template-python version:
- Python version:
- OS:

**Additional context**

...
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Feature request
about: Suggest an addition or a change
title: ""
labels: enhancement
assignees: ""
---

**What problem does this solve?**

...

**Proposed solution**

...

**Alternatives considered**

...

**Additional context**

...
10 changes: 10 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Summary

<!-- What changes and why. Link the issue it closes, if any. -->

## Checklist

- [ ] `pre-commit run --all-files` and `pytest .` pass
- [ ] New code has docstrings and tests
- [ ] The docs (`docs/`, tutorials or `README.qmd`) are updated where the behaviour changed
- [ ] The commit messages follow [Conventional Commits](https://www.conventionalcommits.org/) (`feat:`, `fix:`, `docs:`, ...)
32 changes: 32 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Weekly update PRs for the GitHub Actions, the npm packages of the docs site and the Python
# dependencies. Pre-commit hook revisions are bumped by .github/workflows/pre_commit_autoupdate.yml.
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
groups:
actions:
patterns: ["*"]
- package-ecosystem: npm
directory: /docs
schedule:
interval: weekly
groups:
docs:
patterns: ["*"]
- package-ecosystem: pip
directory: /
schedule:
interval: weekly
groups:
python:
patterns: ["*"]
- package-ecosystem: uv
directory: /
schedule:
interval: weekly
groups:
python:
patterns: ["*"]
28 changes: 18 additions & 10 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Docs

# The Astro + Starlight site in docs/: hand-written pages, the executed tutorials and the API
# reference. Built on every push and pull request; deployed to GitHub Pages from main.
# reference. Built on every push and pull request; deployed to GitHub Pages from devel.

on:
push:
Expand All @@ -28,10 +28,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
- uses: astral-sh/setup-uv@v6
with:
python-version: "3.12"
cache: pip
enable-cache: true

- uses: actions/setup-node@v4
with:
Expand All @@ -41,29 +41,37 @@ jobs:

- name: Install the package with the docs extra
run: |
python -m pip install --upgrade pip
pip install -e ".[docs]"
python -m ipykernel install --user --name python3
uv sync --extra docs
uv run python -m ipykernel install --user --name python3

- name: Execute and convert the tutorials
run: |
python docs/tools/notebooks.py execute
python docs/tools/notebooks.py convert --strict
uv run python docs/tools/notebooks.py execute
uv run python docs/tools/notebooks.py convert --strict

- name: Build the site
working-directory: docs
run: |
npm ci
npm run check:mdx
DOCS_PYTHON="$(command -v python)" npm run build
DOCS_PYTHON="$(pwd)/../.venv/bin/python" npm run build

- name: Smoke test the built site
working-directory: docs
run: |
for page in /index.html /getting-started/installation/index.html /tutorials/example-tutorial/index.html /api/app/index.html /api/app/main/index.html; do
test -f "dist$page" || { echo "missing dist$page"; exit 1; }
done
grep -q 'href="/template-python/' dist/index.html || { echo "links do not use the base path"; exit 1; }
echo "all pages built with the /template-python base path"

- uses: actions/upload-pages-artifact@v3
with:
path: docs/dist

deploy:
needs: build
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/devel'
runs-on: ubuntu-latest
environment:
name: github-pages
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/pre_commit_autoupdate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Pre-commit autoupdate

# Weekly PR that bumps the hook revisions in .pre-commit-config.yaml.

on:
schedule:
- cron: "0 6 * * 1"
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
autoupdate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Update the hook revisions
run: |
pip install pre-commit
pre-commit autoupdate

- name: Open a pull request
uses: peter-evans/create-pull-request@v7
with:
branch: pre-commit-autoupdate
title: "chore: update pre-commit hooks"
commit-message: "chore: update pre-commit hooks"
body: Weekly `pre-commit autoupdate`.
labels: dependencies
36 changes: 0 additions & 36 deletions .github/workflows/publish_pypi.yml

This file was deleted.

54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Release

# release-please keeps a release PR open on main from the conventional commit messages. Merging
# it tags vX.Y.Z, updates CHANGELOG.md and the version, and the publish job uploads the package
# to PyPI with trusted publishing (OIDC). A tag pushed by hand (git tag v1.2.3 && git push --tags)
# publishes too.

on:
push:
branches: ["main"]
tags: ["v*"]
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
release-please:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
steps:
- id: release
uses: googleapis/release-please-action@v4
with:
config-file: release-please-config.json
manifest-file: .release-please-manifest.json

publish:
needs: release-please
if: >-
always() &&
(needs.release-please.outputs.release_created == 'true' || startsWith(github.ref, 'refs/tags/v'))
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/template-python/
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v6
with:
python-version: "3.12"

- name: Build the package
run: uv build

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
34 changes: 22 additions & 12 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,38 @@ jobs:
ruff:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
- uses: astral-sh/setup-uv@v6
with:
python-version: "3.10"

- name: Install ruff
run: pip install ruff
python-version: "3.12"

- name: Lint
run: ruff check .
run: uvx ruff check .

- name: Check formatting
run: ruff format --check .
run: uvx ruff format --check .

pyright:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v6
with:
python-version: "3.12"
enable-cache: true

- name: Install project
run: uv sync --extra dev

- name: Type check
run: uv run pyright src/

readme:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2
Expand Down
23 changes: 14 additions & 9 deletions .github/workflows/test_pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,22 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Set up uv and Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}
cache: pip
enable-cache: true

- name: Install project
run: |
pip install --upgrade pip
pip install ".[test]"
run: uv sync --extra test

- name: Run tests
run: |
pytest .
- name: Run tests with coverage
run: uv run pytest --cov --cov-report=xml --cov-report=term .

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
flags: python-${{ matrix.python-version }}
fail_ci_if_error: false
Loading
Loading