Skip to content

Commit 6d72a01

Browse files
authored
fix: best practice refactor
fix: best practice refactor
2 parents 0df9840 + 4069986 commit 6d72a01

12 files changed

Lines changed: 170 additions & 83 deletions

File tree

.github/workflows/pylint.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ jobs:
1111
permissions:
1212
contents: read
1313
env:
14-
UV_VERSION: '0.9.27'
14+
UV_VERSION: '0.9.28'
1515
PYTHON_VERSION: '3.13'
1616

1717
steps:
1818
- name: Checkout repository
19-
uses: actions/checkout@v4
19+
uses: actions/checkout@v6
2020

2121
- name: Restore global uv cache
2222
id: cache-restore

.github/workflows/pytest.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ jobs:
1111
permissions:
1212
contents: read
1313
env:
14-
UV_VERSION: '0.9.27'
14+
UV_VERSION: '0.9.28'
1515
PYTHON_VERSION: '3.13'
1616
steps:
1717
- name: Checkout repository
18-
uses: actions/checkout@v4
18+
uses: actions/checkout@v6
1919

2020
- name: Restore uv caches
2121
id: cache-restore

.github/workflows/release.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: UV - Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
Semantic-Release:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
tag: ${{ steps.release.outputs.tag }}
13+
concurrency:
14+
group: ${{ github.workflow }}-release-${{ github.ref_name }}
15+
cancel-in-progress: false
16+
permissions:
17+
contents: write
18+
env:
19+
dist_artifacts_name: dist
20+
dist_artifacts_dir: dist
21+
lock_file_artifact: uv.lock
22+
UV_VERSION: '0.9.28'
23+
PYTHON_VERSION: '3.13'
24+
GITHUB_ACTIONS_AUTHOR_NAME: github-actions
25+
GITHUB_ACTIONS_AUTHOR_EMAIL: actions@users.noreply.github.com
26+
steps:
27+
- name: Setup | Checkout Repository on Release Branch
28+
uses: actions/checkout@v6
29+
with:
30+
ref: ${{ github.ref_name }}
31+
32+
- name: Setup | Force release branch to be at workflow sha
33+
run: |
34+
git reset --hard ${{ github.sha }}
35+
36+
- name: Restore global uv cache
37+
id: cache-restore
38+
uses: actions/cache/restore@v4
39+
with:
40+
path: |
41+
~/.cache/uv
42+
~/.local/share/uv
43+
.venv
44+
key: uv-main-${{ env.UV_VERSION }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('pyproject.toml', 'uv.lock') }}
45+
restore-keys: |
46+
uv-main-
47+
48+
- name: Install uv
49+
uses: astral-sh/setup-uv@v7
50+
with:
51+
version: ${{ env.UV_VERSION }}
52+
python-version: ${{ env.PYTHON_VERSION }}
53+
enable-cache: false
54+
55+
- name: Action | Semantic Version Release
56+
id: release
57+
uses: python-semantic-release/python-semantic-release@v10.5.3
58+
with:
59+
github_token: ${{ secrets.GITHUB_TOKEN }}
60+
git_committer_name: 'github-actions'
61+
git_committer_email: 'actions@users.noreply.github.com'
62+
63+
- name: Publish | Upload to GitHub Release Assets
64+
uses: python-semantic-release/publish-action@v10.5.3
65+
if: steps.release.outputs.released == 'true'
66+
with:
67+
github_token: ${{ secrets.GITHUB_TOKEN }}
68+
tag: ${{ steps.release.outputs.tag }}
69+
70+
- name: Save uv caches
71+
if: steps.cache-restore.outputs.cache-hit != 'true'
72+
uses: actions/cache/save@v4
73+
with:
74+
path: |
75+
~/.cache/uv
76+
~/.local/share/uv
77+
.venv
78+
key: uv-main-${{ env.UV_VERSION }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('pyproject.toml', 'uv.lock') }}

pyproject.toml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
[tool.coverage.run]
2-
source = ["src"]
3-
4-
[tool.coverage.report]
5-
omit = ["tests/*"]
61
[project]
7-
name = "python-app-template"
2+
name = "sample_python_app"
83
version = "0.1.0"
94
description = "Add your description here"
105
readme = "README.md"
@@ -23,7 +18,14 @@ dependencies = [
2318
]
2419

2520
[project.optional-dependencies]
26-
build = ["uv ~= 0.9.27"]
21+
build = ["uv >= 0.9.28"]
22+
23+
[build-system]
24+
requires = ["uv_build >= 0.9.28, < 0.10.0"]
25+
build-backend = "uv_build"
26+
27+
[project.scripts]
28+
sample-python-app = "sample_python_app.main:run_app"
2729

2830
[tool.semantic_release]
2931
build_command = """
@@ -32,3 +34,10 @@ build_command = """
3234
git add uv.lock
3335
uv build
3436
"""
37+
version_toml = ["pyproject.toml:project.version"]
38+
39+
[tool.coverage.run]
40+
source = ["src"]
41+
42+
[tool.coverage.report]
43+
omit = ["tests/*"]

src/core/__init__.py

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""
2+
Export core modules for use in other modules.
3+
"""
4+
5+
from sample_python_app.core.config import settings
6+
from sample_python_app.core.logging import setup_logger
7+
8+
__all__ = ["settings", "setup_logger"]

src/main.py renamed to src/sample_python_app/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
Main entry point for the python-app-template project.
33
"""
44

5-
from src.core import settings, setup_logger
5+
from sample_python_app.core import settings, setup_logger
66

77

8-
def main():
8+
def run_app():
99
logger = setup_logger()
1010
logger.info(f"Starting {settings.APP_NAME}...")
1111
logger.info("Hello from python-app-template!")
1212

1313

1414
if __name__ == "__main__": # pragma: no cover
15-
main()
15+
run_app()

0 commit comments

Comments
 (0)