Skip to content

Commit b99a200

Browse files
authored
Merge pull request #1 from danfimov/add-first-project-version
2 parents a24d90c + d95b19c commit b99a200

54 files changed

Lines changed: 2953 additions & 1 deletion

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "uv"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"
7+
cooldown:
8+
default-days: 30
9+
- package-ecosystem: "github-actions"
10+
directory: "/"
11+
schedule:
12+
interval: "monthly"
13+
cooldown:
14+
default-days: 30

.github/workflows/code-check.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Tests
2+
on:
3+
push:
4+
branches: [ main ]
5+
paths-ignore:
6+
- 'docs/**'
7+
- '*.md'
8+
pull_request:
9+
branches: [ main ]
10+
paths-ignore:
11+
- 'docs/**'
12+
- '*.md'
13+
14+
permissions:
15+
actions: read
16+
contents: read
17+
pull-requests: read
18+
19+
jobs:
20+
test:
21+
name: Tests
22+
runs-on: ubuntu-latest
23+
strategy:
24+
matrix:
25+
python-version: [ "3.12", "3.13" ]
26+
fail-fast: false
27+
services:
28+
postgres:
29+
image: postgres:16-alpine
30+
env:
31+
POSTGRES_DB: knobs_example
32+
POSTGRES_USER: knobs
33+
POSTGRES_PASSWORD: knobs
34+
options: >-
35+
--health-cmd pg_isready
36+
--health-interval 10s
37+
--health-timeout 5s
38+
--health-retries 5
39+
ports:
40+
- 5432:5432
41+
steps:
42+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
43+
with:
44+
persist-credentials: false
45+
- id: setup-uv
46+
uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7.1.0
47+
with:
48+
enable-cache: true
49+
cache-suffix: ${{ matrix.python-version }}
50+
version: "latest"
51+
python-version: ${{ matrix.python-version }}
52+
- name: Install Dependencies
53+
run: uv sync --all-extras
54+
- name: Run tests
55+
run: uv run pytest

.github/workflows/docs.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Documentation
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
permissions:
8+
contents: read
9+
pages: write
10+
id-token: write
11+
12+
jobs:
13+
deploy:
14+
environment:
15+
name: github-pages
16+
url: ${{ steps.deployment.outputs.page_url }}
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/configure-pages@v5
20+
- uses: actions/checkout@v5
21+
- uses: actions/setup-python@v5
22+
with:
23+
python-version: 3.x
24+
- run: pip install zensical
25+
- run: zensical build --clean
26+
- uses: actions/upload-pages-artifact@v4
27+
with:
28+
path: site
29+
- uses: actions/deploy-pages@v4
30+
id: deployment

.github/workflows/release-docs.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Release docs
2+
on:
3+
push:
4+
branches: [ main ]
5+
6+
permissions:
7+
contents: write
8+
pages: write
9+
id-token: write
10+
11+
jobs:
12+
deploy:
13+
environment:
14+
name: github-pages
15+
url: ${{ steps.deployment.outputs.page_url }}
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0
19+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
20+
with:
21+
persist-credentials: true
22+
- uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7.1.0
23+
with:
24+
enable-cache: true
25+
python-version: "3.12"
26+
version: "latest"
27+
- run: uv sync --only-group docs
28+
- run: uv run zensical build --clean
29+
- uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
30+
with:
31+
path: site
32+
- uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
33+
id: deployment

.github/workflows/release-pypi.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Release PyPI Package
2+
3+
on:
4+
push:
5+
tags:
6+
# Publish on any tag starting with a `v`, e.g. v1.2.3
7+
- v*
8+
9+
jobs:
10+
pypi:
11+
name: Publish to PyPI
12+
runs-on: ubuntu-latest
13+
environment:
14+
name: release
15+
permissions:
16+
id-token: write
17+
steps:
18+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
19+
with:
20+
persist-credentials: false
21+
- uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7.1.0
22+
with:
23+
enable-cache: false
24+
python-version: "3.12"
25+
version: "latest"
26+
- run: uv version "${GITHUB_REF_NAME}"
27+
- run: uv build
28+
- run: uv publish --trusted-publishing always

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
fail_fast: false
2+
default_language_version:
3+
python: python3.12
4+
repos:
5+
- repo: https://github.com/astral-sh/ruff-pre-commit
6+
rev: v0.15.5
7+
hooks:
8+
- id: ruff-check
9+
args: [--fix]
10+
11+
- repo: builtin
12+
hooks:
13+
- id: trailing-whitespace
14+
- id: end-of-file-fixer

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.PHONY: run_infra migrate makemigrations createsuperuser run
2+
3+
run_infra:
4+
docker compose up -d
5+
6+
##@ Example app
7+
8+
migrate:
9+
cd example_app && uv run python manage.py migrate
10+
11+
makemigrations:
12+
cd example_app && uv run python manage.py makemigrations
13+
14+
createsuperuser:
15+
cd example_app && DJANGO_SUPERUSER_PASSWORD=admin uv run python manage.py createsuperuser --username admin --email admin@example.com --noinput
16+
17+
run:
18+
cd example_app && uv run granian --interface wsgi example_app.wsgi:application --blocking-threads 2 --reload

README.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,44 @@
11
# django-knobs
2-
Django library for dynamic settings
2+
3+
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django-knobs?style=for-the-badge&logo=python)](https://pypi.org/project/django-knobs/)
4+
[![PyPI](https://img.shields.io/pypi/v/django-knobs?style=for-the-badge&logo=pypi)](https://pypi.org/project/django-knobs/)
5+
[![Checks](https://img.shields.io/github/check-runs/danfimov/django-knobs/main?nameFilter=Tests%20(3.12)&style=for-the-badge)](https://github.com/danfimov/django-knobs)
6+
7+
Library for dynamic settings / feature flags that can be changed at runtime without restarting the application from Django admin panel.
8+
9+
```bash
10+
pip install django-knobs
11+
```
12+
13+
![](docs/assets/banner.png)
14+
15+
16+
## Setup
17+
18+
**1. Add to `INSTALLED_APPS`:**
19+
20+
```python
21+
INSTALLED_APPS = [
22+
...
23+
"knobs",
24+
]
25+
```
26+
27+
**2. Run migrations:**
28+
29+
```bash
30+
python manage.py migrate
31+
```
32+
33+
**3. Define your config values in `settings.py`:**
34+
35+
```python
36+
from knobs import Knob
37+
38+
KNOBS_CONFIG = {
39+
"MAX_LOGIN_ATTEMPTS": Knob(default=5, help_text="Max failed logins before lockout", category="auth"),
40+
"FEATURE_NEW_UI": Knob(default=False, help_text="Enable redesigned UI", category="features"),
41+
"API_TIMEOUT": Knob(default=30.0, help_text="Outbound request timeout (seconds)", category="api"),
42+
"WELCOME_MSG": Knob(default="Hello!", help_text="Welcome banner text", category="general"),
43+
}
44+
```

docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
services:
2+
db:
3+
image: postgres:16-alpine
4+
environment:
5+
POSTGRES_DB: knobs_example
6+
POSTGRES_USER: knobs
7+
POSTGRES_PASSWORD: knobs
8+
ports:
9+
- "5432:5432"
10+
healthcheck:
11+
test: ["CMD-SHELL", "pg_isready -U knobs -d knobs_example"]
12+
interval: 3s
13+
timeout: 5s
14+
retries: 10

docs/assets/banner.png

683 KB
Loading

0 commit comments

Comments
 (0)