Skip to content

Commit

Permalink
Changed project from flat layout to src layout (#22)
Browse files Browse the repository at this point in the history
* feat: move project to `src` directory

* code review
  • Loading branch information
fschuch authored Nov 9, 2024
1 parent 599311c commit 357c6b8
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- .github/workflows/ci.yaml
- pyproject.toml
- tests/**
- wizard_template/**
- src/wizard_template/**
schedule:
- cron: "0 0 * * 1" # midnight every Monday

Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
release:
needs: build
# upload to PyPI on every tag and ensure it does not run on forks
if: github.event_name == 'push' && github.ref_type == 'tag' && github.repository == 'fschuch/wizard_template'
if: github.event_name == 'push' && github.ref_type == 'tag' && github.repository == 'fschuch/wizard-template'
runs-on: ubuntu-latest
environment:
name: pypi
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
paths:
- .github/workflows/docs.yaml
- docs/**
- wizard_template/**
- src/wizard_template/**
- pyproject.toml

jobs:
Expand Down Expand Up @@ -41,7 +41,7 @@ jobs:

deploy:
needs: build
if: github.event_name == 'push' && github.ref_type == 'tag' && github.repository == 'fschuch/wizard_template'
if: github.event_name == 'push' && github.ref_type == 'tag' && github.repository == 'fschuch/wizard-template'
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
43 changes: 21 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,32 +111,31 @@ $ hatch env show --ascii
codespell................................................................Passed
mdformat.................................................................Passed
nbstripout...............................................................Passed
cmd [2] | pytest --cov
================================ test session starts ================================
platform darwin -- Python 3.12.2, pytest-8.0.2, pluggy-1.4.0
cmd [2] | pytest --cov --cov-report=term
============================================================ test session starts =============================================================
platform darwin -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0
rootdir: /Users/fschuch/Documents/GitHub/wizard-template
configfile: pyproject.toml
plugins: cov-4.1.0
collected 7 items
tests/test_core.py ...... [ 85%]
wizard_template/core.py . [100%]
---------- coverage: platform darwin, python 3.12.2-final-0 -------------
Name Stmts Miss Branch BrPart Cover Missing
-------------------------------------------------------------------------
tests/__init__.py 0 0 0 0 100%
tests/test_core.py 10 0 6 0 100%
wizard_template/__init__.py 2 0 0 0 100%
wizard_template/core.py 8 0 2 0 100%
-------------------------------------------------------------------------
TOTAL 20 0 8 0 100%
plugins: cov-6.0.0
collected 8 items
src/wizard_template/core.py . [ 12%]
tests/test_core.py ...... [ 87%]
tools/rename_project_content.py s [100%]
---------- coverage: platform darwin, python 3.12.7-final-0 ----------
Name Stmts Miss Branch BrPart Cover Missing
-------------------------------------------------------------------------------
src/wizard_template/__init__.py 2 0 0 0 100.00%
src/wizard_template/core.py 8 0 2 0 100.00%
tests/__init__.py 0 0 0 0 100.00%
tests/test_core.py 10 0 0 0 100.00%
-------------------------------------------------------------------------------
TOTAL 20 0 2 0 100.00%
Required test coverage of 90.0% reached. Total coverage: 100.00%
================================= 7 passed in 0.11s =================================
======================================================== 7 passed, 1 skipped in 0.05s ========================================================
cmd [3] | echo '✅ QA passed'
✅ QA passed
```
Expand Down Expand Up @@ -212,7 +211,7 @@ Some may argue about the importance of [Keeping a Changelog](https://keepachange
### Managing the Version Number
The version in the project is set dynamically by [hatch-vcs](https://github.com/ofek/hatch-vcs).
At installation and build time, the version is recovered from the version control system and exported to the file `wizard_template/_version.py`.
At installation and build time, the version is recovered from the version control system and exported to the file `src/wizard_template/_version.py`.
In this way, there is no need to keep the version hard-coded on the codebase. You can use the command `hatch version` to check the current version.
On the deployment workflow, the version is recovered from the tag and used to build the package.
Expand Down
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ addopts = [
"--doctest-continue-on-failure",
"--doctest-report=ndiff",
]

minversion = "8.0"

[tool.coverage.run]
branch = true
relative_files = true
source = ["wizard_template", "tests"]
omit = ["wizard_template/_version.py"]
source = ["src/wizard_template", "tests"]
omit = ["src/wizard_template/_version.py"]

[tool.coverage.report]
fail_under = 90
Expand Down Expand Up @@ -76,7 +76,7 @@ check-filenames = true
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "wizard_template/_version.py"
version-file = "src/wizard_template/_version.py"

[tool.hatch.envs.default]
description = "Base development environment"
Expand All @@ -89,7 +89,7 @@ dependencies = [
]

[tool.hatch.envs.default.scripts]
_wizard = ["python ./scripts/rename_project_content.py"]
_wizard = ["python ./tools/rename_project_content.py"]
pre-commit-install = "pre-commit install {args}"
pre-commit-uninstall = "pre-commit uninstall {args}"
check = "pre-commit run {args} --all-files"
Expand Down Expand Up @@ -128,5 +128,5 @@ config = "jupyter-book config sphinx docs {args}"
build = ["config", "jupyter-book build docs --path-output build {args}"]
serve = [
"config",
"sphinx-autobuild docs build/_build/html --open-browser --watch wizard_template {args}",
"sphinx-autobuild docs build/_build/html --open-browser --watch src/wizard_template {args}",
]
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def main() -> None:

# Rename the directory
print(f"Renaming folder wizard_template to {project_name_underscore}")
Path("wizard_template").rename(project_name_underscore)
Path("src/wizard_template").rename(f"src/{project_name_underscore}")

print("Done!")

Expand Down

0 comments on commit 357c6b8

Please sign in to comment.