Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,30 @@ jobs:
- name: Install docs dependencies
run: |
pip install -r requirements-docs.txt
# Web generator page: assets from this commit's wheel, checked against
# the CLI before anything is deployed.
- uses: actions/setup-node@v4
with:
node-version: "22"
- uses: actions/cache@v4
with:
path: .cache/web-generator
key: web-generator-${{ hashFiles('scripts/web_generator/pyodide.toml') }}
- name: Build and install the fastkit wheel
run: |
python -m pip wheel --no-deps -w dist .
python -m pip install dist/fastapi_fastkit-*.whl
- name: Build the web generator assets
run: >-
python scripts/web_generator/build_assets.py
--wheel dist/fastapi_fastkit-*.whl
--out docs/en/assets/fastkit-generator
--commit "$GITHUB_SHA"
- name: Compare web output with the CLI
run: >-
python scripts/web_generator/compare_with_cli.py
--assets docs/en/assets/fastkit-generator
--cases tests/fixtures/web_generator/cases.json
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
name: "Pull Request Labeler"
on:
- pull_request_target
pull_request:
types: [opened, synchronize, reopened]

permissions: {}

jobs:
labeler:
# pull_request_target is blocked on public repositories by GitHub's default
# policy; with pull_request a fork's token cannot write labels, so forks
# are skipped and labelled by hand.
if: github.event.pull_request.head.repo.full_name == github.repository
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5
- uses: actions/labeler@v6
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ jobs:
# PDM is already installed via setup-pdm action

- name: Install dependencies
run: pdm install -G dev
# test-runtime: FastAPI and friends, so the tests that start generated
# applications run instead of skipping.
run: pdm install -G dev -G test-runtime

- name: Run tests with coverage
if: runner.os == 'Linux'
Expand Down Expand Up @@ -102,7 +104,9 @@ jobs:
pip install poetry

- name: Install dependencies
run: pdm install -G dev
# test-runtime: FastAPI and friends, so the tests that start generated
# applications run instead of skipping.
run: pdm install -G dev -G test-runtime

- name: Fail on implicit text encodings in fastapi_fastkit
env:
Expand Down
77 changes: 77 additions & 0 deletions .github/workflows/web-generator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Web generator

# The docs site's web generator runs fastkit in the browser with Pyodide.
# This job runs the page's generator core under Node with the same assets and
# compares every case with the `fastkit init` CLI from the same wheel, then
# builds the docs site and checks the page in every locale.

on:
pull_request:
paths:
- "src/**"
- "docs/js/**"
- "docs/css/web-generator.css"
- "docs/*/start/web-generator.md"
- "scripts/web_generator/**"
- "tests/fixtures/web_generator/**"
- "pyproject.toml"
- "mkdocs.yml"
- "requirements-docs.txt"
- ".github/workflows/web-generator.yml"
push:
branches:
- main

permissions:
contents: read

jobs:
web-vs-cli:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "22"

- name: Cache Pyodide downloads
uses: actions/cache@v4
with:
path: .cache/web-generator
key: web-generator-${{ hashFiles('scripts/web_generator/pyodide.toml') }}

- name: Build and install the fastkit wheel
run: |
python -m pip install --upgrade pip
python -m pip wheel --no-deps -w dist .
python -m pip install dist/fastapi_fastkit-*.whl

- name: Build the web generator assets
run: >-
python scripts/web_generator/build_assets.py
--wheel dist/fastapi_fastkit-*.whl
--out docs/en/assets/fastkit-generator
--commit "$GITHUB_SHA"

- name: Compare web output with the CLI
run: >-
python scripts/web_generator/compare_with_cli.py
--assets docs/en/assets/fastkit-generator
--cases tests/fixtures/web_generator/cases.json

- name: Build the docs site
run: |
python -m pip install -r requirements-docs.txt
mkdocs build --strict -d site

- name: Check the web generator page
run: python scripts/web_generator/check_site.py site
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ temp/
*_api_key.txt
translation_cache/

# Web generator assets (built by scripts/web_generator/build_assets.py) and downloads
docs/en/assets/fastkit-generator/
.cache/web-generator/

.pdm-python
### VisualStudioCode template
.vscode/*
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ Every 401 carries `WWW-Authenticate`, and each project reads its configuration f
- When `startdemo` or `init` fails or is interrupted after overwriting files in an existing directory, those files get their original content back and the files the run created are removed; a file that cannot be restored keeps its original copy in a backup directory whose path is printed. An existing `.env` is kept even when a custom template ships one.
- `addroute` no longer treats a router registration or import under `if TYPE_CHECKING:` or `if False:` as present, and inserts imports below `from __future__` imports when the import anchor sits above them.

### Web generator

- A web generator page on the documentation site, in all seven languages, creates a project in your browser and downloads it as a zip with the same files as `fastkit init ... --no-venv`; it shows the matching command line and the next steps, and nothing you enter is uploaded.
- Level, feature and next-step texts are translated for the documentation languages; the CLI and the generated files stay English.

### `fastkit init` options

- **JWT** generates an OAuth2 password flow: `POST /api/v1/auth/register`, `POST /api/v1/auth/token` and `GET /api/v1/users/me`, with users stored in the selected SQL database or MongoDB (in memory otherwise).
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ This project was inspired by the `SpringBoot initializer` & Python Django's `dja

Install `FastAPI-fastkit` in your Python environment.

To try fastkit without installing anything, use the [web generator](https://bnbong.github.io/FastAPI-fastkit/start/web-generator/) in your browser.

```console
$ pip install FastAPI-fastkit
```
Expand Down
Loading
Loading