Skip to content

Commit f79cf60

Browse files
chore(deps): update from template
1 parent a53f3c0 commit f79cf60

30 files changed

Lines changed: 837 additions & 551 deletions

.copier-answers.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
_commit: v0.6.26
1+
_commit: v0.7.3
22
_src_path: gh:helmut-hoffer-von-ankershoffen/oe-python-template
3+
attestations_enabled: true
34
author_email: helmuthva@gmail.com
45
author_github_username: helmut-hoffer-von-ankershoffen
56
author_name: Helmut Hoffer von Ankershoffen
7+
codeql_enabled: true
68
docker_io_enabled: true
79
docker_io_image_name: oe-python-template-example
810
docker_io_owner: helmuthva
911
github_repository_name: oe-python-template-example
1012
github_repository_owner: helmut-hoffer-von-ankershoffen
1113
github_repository_url_https: https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example
1214
github_repository_url_ssh: git@github.com:helmut-hoffer-von-ankershoffen/oe-python-template-example.git
15+
import_package_name: oe_python_template_example
1316
org_email: helmuthva@gmail.com
1417
org_name: Helmut Hoffer von Ankershoffen
1518
project_description: Example project scaffolded and kept up to date with OE Python
1619
Template (oe-python-template).
1720
project_icon: 🧠
1821
project_name: OE Python Template Example
1922
pypi_distribution_name: oe-python-template-example
23+
pypi_enabled: true
2024
readthedocs_domain: readthedocs.org
2125
readthedocs_project_key: oe-python-template-example
2226
sonarqube_key: helmut-hoffer-von-ankershoffen_oe-python-template-example

.github/workflows/docker-image-build-publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ jobs:
8585

8686

8787

88+
8889
- name: Generate artifact attestation
8990
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
9091
with:

.github/workflows/package-build-publish-release.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,22 @@ jobs:
3232
- name: Print the release notes
3333
run: cat "${{ steps.git-cliff.outputs.changelog }}"
3434

35-
3635
- name: Install uv
3736
uses: astral-sh/setup-uv@f94ec6bedd8674c4426838e6b50417d36b6ab231 # v5.3.1
3837
with:
3938
version: "0.6.3"
4039
cache-dependency-glob: uv.lock
4140
enable-cache: true
4241

43-
- name: Build package into dist/
42+
- name: Build distribution into dist/
4443
run: uv build
4544

46-
- name: Publish package to PyPI
45+
46+
- name: Publish distribution to Python Package Index at pypi.org
4747
run: uv publish -t ${{ secrets.UV_PUBLISH_TOKEN }}
4848

49-
- name: Build package into dist/
49+
50+
- name: Have audit checks publish to reports/ for auditing
5051
run: uv run nox -s audit
5152

5253
- name: Create GitHub release

.vscode/extensions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"ms-python.python",
1818
"ms-python.vscode-pylance",
1919
"ms-toolsai.jupyter",
20+
"ms-vscode.makefile-tools",
2021
"oderwat.indent-rainbow",
2122
"samuelcolvin.jinjahtml",
2223
"sonarsource.sonarlint-vscode",

CODE_STYLE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,9 @@ OpenAPI pecification.
265265

266266
## Conventional Commits
267267

268-
Our commit messages follow conventional commits format.
268+
Our commit messages follow [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) definition.
269269

270-
1. We use 'feat','fix','chore','docs','style','refactor','test' prefixes and
270+
1. We use `feat`, `fix`, `chore`, `docs`, `style`, `perf`, `refactor`, `test` prefixes and
271271
components in parentheses. E.g.
272272
`feat(api): add new endpoint for user registration`.
273273

CONTRIBUTING.md

Lines changed: 126 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,118 +2,137 @@
22

33
Thank you for considering contributing to OE Python Template Example!
44

5-
## Setup
6-
7-
Clone this GitHub repository via ```git clone git@github.com:helmut-hoffer-von-ankershoffen/oe-python-template-example.git``` and change into the directory of your local OE Python Template Example repository: ```cd oe-python-template-example```
85

9-
Install the dependencies:
6+
## Setup
107

11-
### macOS
8+
Install or update tools required for development:
129

1310
```shell
14-
if ! command -v brew &> /dev/null; then # if Homebrew package manager not present ...
15-
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" # ... install it
16-
else
17-
which brew # ... otherwise inform where brew command was found
18-
fi
19-
# Install required tools if not present
20-
which jq &> /dev/null || brew install jq
21-
which xmllint &> /dev/null || brew install xmllint
22-
which act &> /dev/null || brew install act
23-
which pinact &> /dev/null || brew install pinact
24-
uv run pre-commit install # install pre-commit hooks, see https://pre-commit.com/
11+
# Install Homebrew, uv package manager, copier and further dev tools
12+
curl -LsSf https://raw.githubusercontent.com/helmut-hoffer-von-ankershoffen/oe-python-template/HEAD/install.sh | sh
2513
```
2614

27-
### Linux
15+
[Create a fork](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/fork) and clone your fork using ```git clone URL_OF_YOUR_CLONE```. Then change into the directory of your local OE Python Template Example repository with ```cd oe-python-template-example```.
16+
17+
If you are one of the committers of https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example you can directly clone via ```git clone git@github.com:helmut-hoffer-von-ankershoffen/oe-python-template-example.git``` and ```cd oe-python-template-example```.
2818

29-
```shell
30-
sudo sudo apt install -y curl jq libxml2-utils gnupg2 # tooling
31-
curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash # act
32-
uv run pre-commit install # see https://pre-commit.com/
33-
```
3419

35-
## Code
20+
## Directory Layout
3621

3722
```
38-
src/oe_python_template_example/
23+
├── Makefile # Central entrypoint for build, test, release and deploy
24+
├── noxfile.py # Noxfile for running tests in multiple python environments and other tasks
25+
├── .pre-commit-config.yaml # Definition of hooks run on commits
26+
├── .github/ # GitHub specific files
27+
│ ├── workflows/ # GitHub Actions workflows
28+
│ ├── prompts/ # Custom prompots for GitHub Copilot
29+
│ └── copilot-instructions.md # Insructions for GitHub Copilot
30+
├── .vscode/ # Recommended VSCode settings and extensions
31+
├── .env # Environment variables, on .gitignore
32+
├── .env.example # Example environment variables
33+
src/oe_python_template_example/ # Source code
3934
├── __init__.py # Package initialization
40-
└── cli.py # Command Line Interface
35+
├── constants.py # Constants used throughout the app
36+
├── service.py # Service exposed for use as shared library
37+
├── models.py # Models and data structures
38+
├── cli.py # CLI enabling to interact with service from terminal
39+
└── api.py # API exposing service as web service
4140
tests/ # Unit and E2E tests
4241
├── cli_tests.py # Verifies the CLI functionality
42+
├── api_tests.py # Verifies the API functionality
4343
└── fixtures/ # Fixtures and mock data
44+
docs/ # Documentation
45+
├── partials/*.md # Partials to compile README.md, _main partial included in HTML and PDF documentation
46+
├── ../README.md # Compiled README.md shown on GitHub
47+
├── source/*.rst # reStructuredText files used to generate HTML and PDF documentation
48+
├── ../*.md # Markdown files shown on GitHub and imported by .rst files
49+
├── source/conf.py # Sphinx configuration used to generate HTML and PDF documentation
50+
├── build/html/* # Generated HTML documentation as multiple pages
51+
├── build/singlehtml/index.html # HTML documentation as a single page
52+
└── build/latex/oe-python-template-example.pdf # PDF manual - generate with make docs pdf
4453
examples/ # Example code demonstrating use of the project
4554
├── streamlit.py # Streamlit App, deployed in Streamlit Community Cloud
4655
├── notebook.py # Marimo notebook
4756
├── notebook.ipynb # Jupyter notebook
4857
└── script.py # Minimal script
58+
reports/ # Compliance reports for auditing
59+
├── junit.xml # Report of executions
60+
├── mypy_junit.xml # Report of executions
61+
├── coverage.xml # Test coverage in XML format
62+
├── coverage_html # Report of test coverage in HTML format
63+
├── licenses.csv # List of dependencies and their license types
64+
├── licenses.json # .json file with dependencies their license types
65+
├── licenses_grouped.json # .json file with dependencies grouped by license type
66+
├── notebook.ipynb # Jupyter notebook
67+
└── script.py # Minimal script
4968
```
5069

51-
## Run
5270

53-
### .env file
71+
## Build, Run and Release
72+
73+
### Setup project specific development environment
74+
75+
```shell
76+
make setup
77+
```
5478

5579
Don't forget to configure your `.env` file with the required environment variables.
5680

5781
Notes:
58-
1. .env.example is provided as a template.
82+
1. .env.example is provided as a template, use ```cp .env.example .env``` and edit ```.env``` to create your environment.
5983
2. .env is excluded from version control, so feel free to add secret values.
6084

61-
### update dependencies and create virtual environment
62-
63-
```shell
64-
uv sync # install dependencies
65-
uv sync --all-extras # install all extras, required for examples
66-
uv venv # create a virtual environment
67-
source .venv/bin/activate # activate it
68-
uv run pre-commit install # Install pre-commit hook etc.
69-
```
70-
71-
### run the CLI
85+
### Build
7286

7387
```shell
74-
uv run oe-python-template-example # shows help
88+
make # Runs primary build steps, i.e. formatting, linting, testing, building HTML docs and distribution, auditing
89+
make help # Shows help with additional build targets, e.g. to build PDF documentation, bump the version to release etc.
7590
```
7691

77-
## Build
92+
Notes:
93+
1. Primary build steps defined in `noxfile.py`.
94+
2. Distribution dumped into ```dist/```
95+
3. Documentation dumped into ```docs/build/html/``` and ```docs/build/latex/```
96+
4. Audit reports dumped into ```reports/```
7897

79-
All build steps are defined in `noxfile.py`.
98+
### Run the CLI
8099

81100
```shell
82-
uv run nox # Runs all build steps except setup_dev
101+
uv run oe-python-template-example # shows help
83102
```
84103

85-
You can run individual build steps - called sessions in nox as follows:
104+
### Commit and Push your changes
86105

87106
```shell
88-
uv run nox -s test # run tests
89-
uv run nox -s lint # run formatting and linting
90-
uv run nox -s audit # run security and license audit, inc. sbom generation
91-
uv run nox -s docs # build documentation, output in docs/build/html
92-
uv run nox -s docs_pdf # locally build pdf manual to docs/build/latex/oe-python-template-example.pdf
107+
git add .
108+
git commit -m "feat(user): added new api endpoint to offboard user"
109+
git push
93110
```
94111

95-
As a shortcut, you can run build steps using `./n`, e.g.
112+
Notes:
113+
1. [pre-commit hooks](https://pre-commit.com/) will run automatically on commit to ensure code quality.
114+
2. We use the conventional commits format - see the [code style guide](CODE_STYLE.md) for the mandatory commit message format.
96115

97-
```shell
98-
./n test
99-
./n lint
100-
# ...
101-
```
116+
### Publish Release
102117

103-
Generate a wheel using uv
104118
```shell
105-
uv build
119+
make bump # Patch release
120+
make minor # Patch release
121+
make major # Patch release
122+
make x.y.z # Targeted release
106123
```
107124

108125
Notes:
109-
1. Reports dumped into ```reports/```
110-
3. Documentation dumped into ```docs/build/html/```
111-
2. Distribution dumped into ```dist/```
126+
1. Changelog generated automatically
127+
2. Publishes to PyPi, Docker Registries, Read The Docs, Streamlit and Auditing services
112128

113-
### Running GitHub CI workflow locally
129+
130+
## Advanced usage
131+
132+
### Running GitHub CI Workflow locally
114133

115134
```shell
116-
uv run nox -s act
135+
make act
117136
```
118137

119138
Notes:
@@ -122,34 +141,68 @@ Notes:
122141

123142
### Docker
124143

144+
Build and run the Docker image with plain Docker
145+
125146
```shell
126-
docker build -t oe-python-template-example .
147+
# Build from Dockerimage
148+
make docker build
149+
# Run the CLI
150+
docker run --env THE_VAR=THE_VALUE oe-python-template-example --help
127151
```
128152

153+
Build and run the Docker image with docker compose:
154+
129155
```shell
130-
docker run --env THE_VAR=THE_VALUE oe-python-template-example --help
156+
echo "Building the Docker image with docker compose and running CLI..."
157+
docker compose run --build oe-python-template --help
158+
echo "Building the Docker image with docker compose and running API container as a daemon ..."
159+
docker compose up --build -d
160+
echo "Waiting for the API server to start..."
161+
sleep 5
162+
echo "Checking health of v1 API ..."
163+
curl http://127.0.0.1:8000/api/v1/healthz
164+
echo ""
165+
echo "Saying hello world with v1 API ..."
166+
curl http://127.0.0.1:8000/api/v1/hello-world
167+
echo ""
168+
echo "Swagger docs of v1 API ..."
169+
curl http://127.0.0.1:8000/api/v1/docs
170+
echo ""
171+
echo "Checking health of v2 API ..."
172+
curl http://127.0.0.1:8000/api/v2/healthz
173+
echo ""
174+
echo "Saying hello world with v1 API ..."
175+
curl http://127.0.0.1:8000/api/v2/hello-world
176+
echo ""
177+
echo "Swagger docs of v2 API ..."
178+
curl http://127.0.0.1:8000/api/v2/docs
179+
echo ""
180+
echo "Shutting down the API container ..."
181+
docker compose down
131182
```
132183

133-
### Pinning github actions
184+
### Pinning GitHub Actions
134185

135186
```shell
136187
pinact run # See https://dev.to/suzukishunsuke/pin-github-actions-to-a-full-length-commit-sha-for-security-2n7p
137188
```
138189

139-
### Copier
140190

141-
Update from template
191+
## Update from Template
192+
193+
Update project to latest version of [oe-python-template](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template) template.
142194

143195
```shell
144-
uv run nox -s update_from_template
196+
make update_from_template
145197
```
146198

199+
147200
## Pull Request Guidelines
148201

149-
1. Before starting to write code read the [code style guide](CODE_STYLE.md) document for mandatory coding style
150-
guidelines.
202+
1. Before starting to write code read the [code style](CODE_STYLE.md) document for mandatory coding style requirements.
151203
2. **Pre-Commit Hooks:** We use pre-commit hooks to ensure code quality. Please install the pre-commit hooks by running `uv run pre-commit install`. This ensure all tests, linting etc. pass locally before you can commit.
152204
3. **Squash Commits:** Before submitting a pull request, please squash your commits into a single commit.
153-
4. **Branch Naming:** Use descriptive branch names like `feature/your-feature` or `fix/issue-number`.
154-
5. **Testing:** Ensure new features have appropriate test coverage.
155-
6. **Documentation:** Update documentation to reflect any changes or new features.
205+
4. **Signed Commits:** Use [signed commits](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits).
206+
5. **Branch Naming:** Use descriptive branch names like `feature/your-feature` or `fix/issue-number`.
207+
6. **Testing:** Ensure new features have appropriate test coverage.
208+
7. **Documentation:** Update documentation to reflect any changes or new features.

0 commit comments

Comments
 (0)