Skip to content

Commit 6722e3f

Browse files
chore(deps): update from template
1 parent b3f8760 commit 6722e3f

24 files changed

Lines changed: 265 additions & 83 deletions

.copier-answers.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
_commit: v0.8.2
1+
_commit: v0.8.4
22
_src_path: gh:helmut-hoffer-von-ankershoffen/oe-python-template
33
attestations_enabled: true
44
author_email: helmuthva@gmail.com
@@ -25,3 +25,4 @@ readthedocs_domain: readthedocs.org
2525
readthedocs_project_key: oe-python-template-example
2626
sonarqube_key: helmut-hoffer-von-ankershoffen_oe-python-template-example
2727
streamlit_project_key: oe-python-template-example
28+
vercel_function_enabled: true

.github/workflows/test-and-report.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
3131
- name: Install project specific dependencies
3232
run: |
33-
sudo apt-get install -y libcairo2
33+
# sudo apt-get install -y YOUR_PROJECT_DEPENDENCIES
3434
3535
- name: Install uv (python package manager)
3636
uses: astral-sh/setup-uv@f94ec6bedd8674c4426838e6b50417d36b6ab231 # v5.3.1
@@ -48,7 +48,6 @@ jobs:
4848
run: |
4949
TAG_VERSION=${GITHUB_REF#refs/tags/v}
5050
TOML_VERSION=$(uv run python -c "import tomli; print(tomli.load(open('pyproject.toml', 'rb'))['project']['version'])")
51-
5251
if [ "$TAG_VERSION" != "$TOML_VERSION" ]; then
5352
echo "Release version mismatch: Tag $TAG_VERSION != pyproject.toml $TOML_VERSION"
5453
exit 1
@@ -68,19 +67,19 @@ jobs:
6867

6968
- name: Validate installation
7069
run: |
71-
OUTPUT=$(uv run oe-python-template-example --help)
70+
OUTPUT=$(uv run --no-dev oe-python-template-example --help)
7271
if [[ "$OUTPUT" != *"built with love in Berlin"* ]]; then
7372
echo "Output does not contain 'built with love in Berlin'"
7473
exit 1
7574
fi
7675
7776
- name: Smoke tests
7877
run: |
79-
uv run oe-python-template-example hello-world
78+
uv run --no-dev oe-python-template-example hello-world
8079
8180
- name: Run unit tests, measure coverage, lint, and check vulnerabilities
8281
run: |
83-
uv run nox
82+
uv run --all-extras nox
8483
8584
- name: Upload test results
8685
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
@@ -108,6 +107,7 @@ jobs:
108107
uses: codecov/test-results-action@f2dba722c67b86c6caa034178c6e4d35335f6706 # v1.1.0
109108
with:
110109
token: ${{ secrets.CODECOV_TOKEN }}
110+
111111
- name: SonarQube Scan
112112
if: ${{ !cancelled() && (env.GITHUB_WORKFLOW_RUNTIME != 'ACT') }}
113113
uses: SonarSource/sonarqube-scan-action@0303d6b62e310685c0e34d0b9cde218036885c4d # v5.0.0
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Vercel Preview Deployment
2+
env:
3+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
4+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
5+
on:
6+
push:
7+
branches-ignore:
8+
- main
9+
jobs:
10+
Deploy-Preview:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Install Vercel CLI
16+
run: npm install --global vercel@latest
17+
18+
- name: Install Vercel CLI
19+
run: npm install --global vercel@latest
20+
21+
- name: Package and Deploy to Preview Environment
22+
run: |
23+
make dist_vercel
24+
cd dist_vercel
25+
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
26+
vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
27+
vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Vercel Production Deployment
2+
env:
3+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
4+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
5+
on:
6+
push:
7+
branches:
8+
- main
9+
jobs:
10+
Deploy-Production:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Install Vercel CLI
16+
run: npm install --global vercel@latest
17+
18+
- name: Install Vercel CLI
19+
run: npm install --global vercel@latest
20+
21+
- name: Package and Deploy to Production
22+
run: |
23+
make dist_vercel
24+
cd dist_vercel
25+
vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
26+
vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
27+
vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,9 @@ node_modules/
7575
# Copier
7676
*.rej
7777

78+
79+
# Vercel
80+
.vercel
81+
82+
7883
# Application specific

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ repos:
6464
args: ['--baseline', '.secrets.baseline']
6565
additional_dependencies: ["gibberish-detector"]
6666
- repo: https://github.com/astral-sh/uv-pre-commit
67-
rev: 0.6.5
67+
rev: 0.6.10
6868
hooks:
6969
- id: uv-lock
7070
- repo: local

ATTRIBUTIONS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9984,7 +9984,7 @@ License: LGPL-2.1-or-later
99849984

99859985
```
99869986

9987-
## oe-python-template-example (0.2.10) - MIT License
9987+
## oe-python-template-example (0.2.11) - MIT License
99889988

99899989
🧠 Example project scaffolded and kept up to date with OE Python Template (oe-python-template).
99909990

Makefile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Makefile for running common development tasks
22

33
# Define all PHONY targets
4-
.PHONY: all act audit bump clean dist docs docker_build lint setup setup test update_from_template
4+
.PHONY: all act audit bump clean dist dist_vercel docs docker_build lint setup setup test update_from_template
55

66
# Main target i.e. default sessions defined in noxfile.py
77
all:
88
uv run nox
99

1010
# Nox targets
11+
1112
## Call nox sessions passing parameters
1213
nox-cmd = @if [ "$@" = "test" ]; then \
1314
if [ -n "$(filter 3.%,$(MAKECMDGOALS))" ]; then \
@@ -23,8 +24,8 @@ else \
2324
uv run nox -s $@; \
2425
fi
2526

26-
# Individual Nox sessions
27-
act audit bump clean dist docs docker_build lint setup test update_from_template:
27+
## Individual Nox sessions
28+
act audit bump dist dist_vercel docs lint setup test update_from_template:
2829
$(nox-cmd)
2930

3031
# Standalone targets
@@ -45,14 +46,13 @@ clean:
4546
docker_build:
4647
docker build -t oe-python-template-example .
4748

48-
4949
# Special rule to catch any arguments (like patch, minor, major, pdf, Python versions, or x.y.z)
5050
# This prevents "No rule to make target" errors when passing arguments to make commands
5151
.PHONY: %
5252
%:
5353
@:
5454

55-
# Help text
55+
# Help
5656
help:
5757
@echo "🧠 Available targets for OE Python Template Example (v$(shell test -f VERSION && cat VERSION || echo 'unknown version'))"
5858
@echo ""
@@ -61,7 +61,8 @@ help:
6161
@echo " audit - Run security and license compliance audit"
6262
@echo " bump patch|minor|major|x.y.z - Bump version"
6363
@echo " clean - Clean build artifacts and caches"
64-
@echo " dist - Build wheel package with uv"
64+
@echo " dist - Build wheel and sdist into dist/"
65+
@echo " dist_vercel - Package as Vercel Function into dist_vercel/"
6566
@echo " docs [pdf] - Build documentation (add pdf for PDF format)"
6667
@echo " docker_build - Build Docker image oe-python-template-example"
6768
@echo " lint - Run linting and formatting checks"

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Beyond development tooling, projects generated with this template include the co
9292
6. Simple Web UI with [Streamlit](https://streamlit.io/)
9393
7. Configuration to run the CLI and API in a Docker container including setup for [Docker Compose](https://docs.docker.com/get-started/docker-concepts/the-basics/what-is-docker-compose/)
9494
8. Documentation including badges, setup instructions, contribution guide and security policy
95+
9. Preparation to deploy API as serverless function to Vercel
9596

9697
Explore [here](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example) for what's generated out of the box.
9798

@@ -242,6 +243,11 @@ uv sync --all-extras # Install streamlit dependen
242243
uv run streamlit run examples/streamlit.py # Serve on localhost:8501, opens browser
243244
```
244245

246+
### Vercel Serverless Function
247+
248+
Serve the API as a [serverless function on Vercel](https://oe-python-template-example.vercel.app/)
249+
250+
245251
## Notebooks
246252

247253
### Jupyter

VERCEL.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Vercel
2+
3+
You can host the API as a serverless function on Vercel
4+
5+
## Register at Vercel
6+
7+
[Sign-Up](https://vercel.com/signup) and create a "Hobby" account - it's free.
8+
9+
## Install Vercel CLI
10+
11+
```shell
12+
pnpm i -g vercel
13+
```
14+
15+
## Generate, link and deploy Vercel Distribution
16+
17+
```shell
18+
make dist_vercel
19+
vercel login
20+
vercel link --cwd dist_vercel --project oe-python-template-example --yes
21+
vercel deploy --cwd dist_vercel
22+
```
23+
24+
Visit the [production deployment](https://oe-python-template-example.vercel.app/)
25+
26+
## Wire the CI/CD
27+
28+
1. Show organisation and project id by executing `cat dist_vercel/.vercel/project.json`
29+
2. [Create secret](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/settings/secrets/actions/new) called `VERCEL_PROJECT_ID` with the value of `projectId` from step 1
30+
3. [Create secret](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/settings/secrets/actions/new) called `VERCEL_ORG_ID` with the value of `orgId` from step 1
31+
4. Goto [Vercel Account Settings](https://vercel.com/account/settings/tokens) and create a new token with project scope, copy the token to clipboard.
32+
5. [Create secret](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/settings/secrets/actions/new) called `VERCEL_TOKEN` with the value of `projectId` from the previous command
33+
34+
That's it. The rest is automatic, deploy happening on build of main.

0 commit comments

Comments
 (0)