diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3ea9a1d..e81e65a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,8 +10,8 @@ permissions: contents: read jobs: - tests: - name: tests + pytest: + name: Run tests runs-on: ubuntu-latest steps: diff --git a/README.md b/README.md index 8cb584d..a83422f 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,28 @@   [](https://github.com/haztecaso/python-template/actions) -[](https://opensource.org/licenses/MIT) A modern cookiecutter template for Python projects using `uv` as the package manager, Nix flakes for reproducibility, and a clean development setup. +## 🚀 Usage + +### Creating a new project + +If you want to keep your project in sync with this template, you can use +*cruft*. + +```bash +cruft create gh:haztecaso/python-template +``` + +Otherwise you can stick with *cookiecutter*. + +```bash +cookiecutter gh:haztecaso/python-template +``` + ## Features ### Current Features @@ -42,26 +58,3 @@ A modern cookiecutter template for Python projects using `uv` as the package man - 🔄 **Enhanced CI**: GitHub Action test matrix for multi-environment testing - 🐍 **PyPy**: Registry setup and GitHub Action for multi-interpreter testing -## 🚀 Usage - -This template requires the [Nix package manager](https://nixos.org/). You can install `cookiecutter` in your preferred way or create a temporal shell with it: - -```bash -nix-shell -p cookiecutter -``` - -### Creating a new project - -```bash -cookiecutter gh:haztecaso/python-template -``` - -### Initial setup - -```bash -# If you use direnv -direnv allow - -# manually activate the development environment -nix develop -``` diff --git a/hooks/post_gen_project.sh b/hooks/post_gen_project.sh index 2990c23..cbdebb6 100755 --- a/hooks/post_gen_project.sh +++ b/hooks/post_gen_project.sh @@ -13,5 +13,5 @@ uv sync --dev uv run black src tests uv run isort src tests nix build -git init && git branch -m "main" && git add . +git init --initial-branch=main && git add . uv run pre-commit install --hook-type commit-msg --hook-type pre-commit diff --git a/tests/test_template.py b/tests/test_template.py index 65a7e1f..cfa6d9b 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -121,6 +121,12 @@ def test_pytest_runs(project: Result): test_dir = project_path / "tests" assert test_dir.is_dir(), f"Expected tests directory not found: {test_dir}" + # Sync test dependencies + process = run_command("uv sync --group test", project_path) + assert ( + process.returncode == 0 + ), f"uv sync failed with error: {process.stderr}\nOutput: {process.stdout}" + process = run_command("uv run pytest -xvs", project_path) assert ( @@ -151,7 +157,7 @@ def test_mkdocs_runs(project: Result): assert ( process.returncode == 0 - ), f"pytest failed with error: {process.stderr}\nOutput: {process.stdout}" + ), f"mkdocs failed with error: {process.stderr}\nOutput: {process.stdout}" assert ( "Documentation built in" in process.stderr ), f"Expected 'Documentation built in' in mkdocs build stderr, but got: {process.stderr}" diff --git a/{{cookiecutter.project_slug}}/.github/workflows/docs.yml b/{{cookiecutter.project_slug}}/.github/workflows/docs.yml index baf0ed6..31a065b 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/docs.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/docs.yml @@ -1,11 +1,8 @@ -name: docs +name: Docs on: push: branches: [ "main" ] - pull_request: - branches: [ "main" ] - # Allow manual trigger workflow_dispatch: permissions: @@ -13,13 +10,13 @@ permissions: pages: write id-token: write -# Allow only one concurrent deployment concurrency: group: "pages" cancel-in-progress: false jobs: build: + name: Mkdocs build runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -47,6 +44,7 @@ jobs: path: ./site deploy: + name: Deploy to github pages environment: name: github-pages url: {% raw -%}${{ github.event.repository.html_url }}/{%- endraw %} diff --git a/{{cookiecutter.project_slug}}/.github/workflows/test.yml b/{{cookiecutter.project_slug}}/.github/workflows/test.yml index a741956..90baf1d 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/test.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: test +name: Test on: push: @@ -10,8 +10,8 @@ permissions: contents: read jobs: - uv-example: - name: python + pytest: + name: Run tests runs-on: ubuntu-latest steps: diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index 4544e28..5440f4b 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -1,7 +1,15 @@ # {{ cookiecutter.project_name }} -{{ cookiecutter.project_short_description }} +