Skip to content

Commit 6f31db4

Browse files
Update boilerplate (#11)
* Refactor workflows to use PACKAGE_NAME environment variable for consistency * Remove unused FastAPI badge from Software Maintenance Guide * Update coverage source to include tests * Update packages
1 parent b5726f6 commit 6f31db4

7 files changed

Lines changed: 127 additions & 189 deletions

File tree

.github/workflows/build.yml

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ on:
88
branches:
99
- main
1010

11+
env:
12+
PACKAGE_NAME: example
13+
1114
jobs:
12-
build_wheel:
15+
build-wheel:
1316
runs-on: ubuntu-latest
1417
steps:
1518
- uses: actions/checkout@v4
@@ -20,29 +23,28 @@ jobs:
2023
- name: Inspect wheel contents
2124
run: |
2225
echo "Wheel contents:"
23-
unzip -l dist/example-*-py3-none-any.whl
26+
unzip -l dist/${{ env.PACKAGE_NAME }}-*-py3-none-any.whl
2427
- name: Upload wheel
2528
uses: actions/upload-artifact@v4
2629
with:
27-
name: example_wheel
28-
path: dist/example-*-py3-none-any.whl
30+
name: ${{ env.PACKAGE_NAME }}_wheel
31+
path: dist/${{ env.PACKAGE_NAME }}-*-py3-none-any.whl
2932

30-
verify_structure:
33+
verify-structure:
3134
runs-on: ubuntu-latest
32-
needs: build_wheel
35+
needs: build-wheel
3336
steps:
3437
- uses: actions/checkout@v4
3538
- uses: ./.github/actions/setup-python-core
3639

3740
- name: Download wheel artifact
3841
uses: actions/download-artifact@v4
3942
with:
40-
name: example_wheel
43+
name: ${{ env.PACKAGE_NAME }}_wheel
4144

4245
- name: Install wheel
4346
run: |
44-
PACKAGE_NAME="example"
45-
WHEEL_FILE=$(find . -name "${PACKAGE_NAME}-*-py3-none-any.whl")
47+
WHEEL_FILE=$(find . -name "${{ env.PACKAGE_NAME }}-*-py3-none-any.whl")
4648
4749
if [ ! -f "$WHEEL_FILE" ]; then
4850
echo "Wheel file not found"
@@ -54,16 +56,14 @@ jobs:
5456
5557
- name: Verify installed package structure
5658
run: |
57-
PACKAGE_NAME="example"
58-
5959
# Find site-packages directory
6060
SITE_PACKAGES=$(find . -name "site-packages" -type d | head -1)
6161
echo "Site-packages directory: $SITE_PACKAGES"
6262
6363
# Check for required directories in site-packages
6464
echo "Checking required directories in site-packages..."
6565
REQUIRED_DIRS=(
66-
"${SITE_PACKAGES}/${PACKAGE_NAME}"
66+
"${SITE_PACKAGES}/${{ env.PACKAGE_NAME }}"
6767
)
6868
6969
for dir in "${REQUIRED_DIRS[@]}"; do
@@ -86,7 +86,3 @@ jobs:
8686
exit 1
8787
fi
8888
done
89-
90-
# Show directory structure
91-
echo "Package structure in site-packages:"
92-
tree "${SITE_PACKAGES}/${PACKAGE_NAME}" --dirsfirst -F -L 2

.github/workflows/ci.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
branches:
99
- main
1010

11+
env:
12+
PACKAGE_NAME: example
13+
1114
jobs:
1215
validate-pyproject:
1316
runs-on: ubuntu-latest
@@ -53,7 +56,7 @@ jobs:
5356
- uses: ./.github/actions/setup-python-dev
5457
- name: Security check
5558
run: |
56-
uv run bandit -r example/ -f json -o bandit-report.json || true
59+
uv run bandit -r ${{ env.PACKAGE_NAME }} -f json -o bandit-report.json || true
5760
- uses: actions/upload-artifact@v4
5861
with:
5962
name: bandit-report
@@ -75,9 +78,8 @@ jobs:
7578
run: |
7679
echo "Checking version consistency across all package files..."
7780
78-
PACKAGE_NAME="example"
7981
TOML_VERSION=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
80-
LOCK_VERSION=$(uv run python -c "import tomllib; lock_data = tomllib.load(open('uv.lock', 'rb')); pkg = next((p for p in lock_data['package'] if p['name'] == '${PACKAGE_NAME}'), None); print(pkg['version'] if pkg else 'not found')")
82+
LOCK_VERSION=$(uv run python -c "import tomllib; lock_data = tomllib.load(open('uv.lock', 'rb')); pkg = next((p for p in lock_data['package'] if p['name'] == '$(echo ${{ env.PACKAGE_NAME }} | tr '_' '-')'), None); print(pkg['version'] if pkg else 'not found')")
8183
8284
echo "Version in pyproject.toml: $TOML_VERSION"
8385
echo "Version in uv.lock: $LOCK_VERSION"

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ This repository can be used as a template for a Python application.
1313
- [Documentation](#documentation)
1414
- [License](#license)
1515

16-
1716
## Documentation
1817

1918
- **[Software Maintenance Guide](./docs/SMG.md)**: Development setup, configuration

docs/SMG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ This document outlines how to configure and setup a development environment to w
1515
[![Python](https://img.shields.io/badge/Python-3.13-3776AB?style=flat-square&logo=python&logoColor=ffd343)](https://docs.python.org/3.13/)
1616
[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json&style=flat-square)](https://github.com/astral-sh/uv)
1717
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json&style=flat-square)](https://github.com/astral-sh/ruff)
18-
[![FastAPI](https://img.shields.io/badge/FastAPI-Latest-009688?style=flat-square&logo=fastapi&logoColor=white)](https://fastapi.tiangolo.com/)
1918

2019
### Directory Structure
2120

@@ -49,7 +48,7 @@ uv sync --extra dev
4948
After installing dev dependencies, set up pre-commit hooks:
5049

5150
```sh
52-
uv run pre-commit install
51+
uv run pre-commit install
5352
```
5453

5554
### Testing, Linting, and Type Checking

docs/WORKFLOWS.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ It consists of the following jobs:
3333
### bandit
3434
- Checkout code
3535
- Setup Python environment with dev dependencies (via custom action)
36-
- Run security scanning with bandit
36+
- Run security scanning with bandit on `example/` directory
3737
- Generate JSON report for artifacts
3838
- Fail if security vulnerabilities are found
3939

@@ -52,17 +52,17 @@ It consists of the following jobs:
5252
The Build workflow runs on pushes and pull requests to the `main` branch.
5353
It consists of the following jobs:
5454

55-
### build_wheel
55+
### build-wheel
5656
- Checkout code
5757
- Setup Python environment with dev dependencies (via custom action)
5858
- Build wheel with `uv build`
5959
- Inspect wheel contents for verification
6060
- Upload wheel artifact (`example_wheel`)
6161

62-
### verify_structure
63-
- Depends on `build_wheel` job
62+
### verify-structure
63+
- Depends on `build-wheel` job
6464
- Checkout code
6565
- Setup Python environment (via custom action)
6666
- Download wheel artifact
6767
- Install wheel using `uv pip install`
68-
- Verify installed package structure
68+
- Verify installed package structure in site-packages

pyproject.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ classifiers = [
1717
"Programming Language :: Python :: 3.13",
1818
"License :: OSI Approved :: MIT License",
1919
]
20-
dependencies = [
21-
"numpy",
22-
]
20+
dependencies = []
2321

2422
[project.optional-dependencies]
2523
dev = [
@@ -59,7 +57,7 @@ addopts = [
5957

6058
[tool.coverage.run]
6159
branch = true
62-
source = ["example"]
60+
source = ["example", "tests"]
6361

6462
[tool.coverage.report]
6563
fail_under = 80

0 commit comments

Comments
 (0)