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
52 changes: 6 additions & 46 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,55 +1,15 @@
# Git files
.git
.gitignore
.github

# Python cache
__pycache__
*.py[cod]
*$py.class
*.so

# Virtual environment
venv/
env/
ENV/
.venv

# IDE
.vscode
.idea
*.swp
*.swo
*~

# Testing
.claude
.ruff_cache
.pytest_cache
.coverage
htmlcov/
.tox/

# Database
*.sqlite3
db.sqlite3
db.sqlite3-journal

# Logs
*.log
logs/

# Documentation
README.md
docs/

# Build artifacts
build/
dist/
*.egg-info/

# Environment variables
__pycache__
*.py[cod]
db.sqlite3*
staticfiles/
.env
.env.*

# OS files
.DS_Store
Thumbs.db
25 changes: 14 additions & 11 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
DEBUG=true
SECRET_KEY="abc@cd"
DB_NAME=""
DB_USER=""
DB_PASSWORD="vvTx6HvG@"
DB_HOST="localhost"
DB_PORT="3306"
EMAIL_HOST="smtp.gmail.com"
EMAIL_PORT=587
EMAIL_USE_TLS=true
EMAIL_HOST_USER="***@gmail.com"
EMAIL_HOST_PASSWORD=""
SECRET_KEY=change-me
ALLOWED_HOSTS=localhost,127.0.0.1
# CSRF_TRUSTED_ORIGINS=https://example.com
# CORS_ALLOWED_ORIGINS=http://localhost:3000
CORS_ALLOW_ALL_ORIGINS=true

# Defaults to SQLite (db.sqlite3) when unset
# DATABASE_URL=postgres://postgres:postgres@localhost:5432/app

# Defaults to console backend when unset
# EMAIL_URL=smtp+tls://user@gmail.com:app-password@smtp.gmail.com:587
# DEFAULT_FROM_EMAIL=noreply@example.com

LOG_LEVEL=INFO
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Bug report
about: Something isn't working
labels: bug
---

**Describe the bug**

**Steps to reproduce**

1.

**Expected behavior**

**Environment** (OS, Python version, Docker or local)
9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: Feature request
about: Suggest an improvement to the template
labels: enhancement
---

**What problem would this solve?**

**Proposed solution**
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 2
updates:
- package-ecosystem: uv
directory: /
schedule:
interval: weekly
groups:
python:
patterns: ['*']

- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
groups:
actions:
patterns: ['*']

- package-ecosystem: docker
directory: /
schedule:
interval: weekly
9 changes: 9 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## What

<!-- What does this change and why? -->

## Checklist

- [ ] `make lint` passes
- [ ] `make test` passes
- [ ] Migrations added if models changed
97 changes: 97 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: CI

on:
push:
branches: ['main']
pull_request:
branches: ['main']

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
with:
enable-cache: true

- name: Check lockfile is up to date
run: uv lock --locked

- name: Ruff lint
run: |
uv sync --locked --no-build --only-dev
uv run --no-sync ruff check --output-format=github .

Check warning on line 32 in .github/workflows/ci.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Omitting "--no-build" can lead to the execution of setup scripts. Make sure it is safe here.

See more on https://sonarcloud.io/project/issues?id=pnstack_template-django&issues=AaDcG53j2DoGyeOZSruS&open=AaDcG53j2DoGyeOZSruS&pullRequest=43

- name: Ruff format
run: uv run --no-sync ruff format --check .

Check warning on line 35 in .github/workflows/ci.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Omitting "--no-build" can lead to the execution of setup scripts. Make sure it is safe here.

See more on https://sonarcloud.io/project/issues?id=pnstack_template-django&issues=AaDcG53j2DoGyeOZSruT&open=AaDcG53j2DoGyeOZSruT&pullRequest=43

test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.13', '3.14']
database: ['sqlite', 'postgres']
services:
postgres:
image: postgres:17-alpine
env:
POSTGRES_DB: app
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres

Check warning on line 50 in .github/workflows/ci.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

"PASSWORD" detected here, make sure this is not a hard-coded credential.

See more on https://sonarcloud.io/project/issues?id=pnstack_template-django&issues=AaDcF7p4mEp5MbUoQB6E&open=AaDcF7p4mEp5MbUoQB6E&pullRequest=43
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres -d app"
--health-interval 5s
--health-timeout 5s
--health-retries 10
env:
DATABASE_URL: ${{ matrix.database == 'postgres' && 'postgres://postgres:postgres@localhost:5432/app' || 'sqlite:///db.sqlite3' }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
with:
enable-cache: true
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --locked --no-build

- name: Django system checks
run: uv run --no-sync manage.py check

Check warning on line 72 in .github/workflows/ci.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Omitting "--no-build" can lead to the execution of setup scripts. Make sure it is safe here.

See more on https://sonarcloud.io/project/issues?id=pnstack_template-django&issues=AaDcG53j2DoGyeOZSruU&open=AaDcG53j2DoGyeOZSruU&pullRequest=43

- name: Check for missing migrations
run: uv run --no-sync manage.py makemigrations --check --dry-run

Check warning on line 75 in .github/workflows/ci.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Omitting "--no-build" can lead to the execution of setup scripts. Make sure it is safe here.

See more on https://sonarcloud.io/project/issues?id=pnstack_template-django&issues=AaDcG53j2DoGyeOZSruV&open=AaDcG53j2DoGyeOZSruV&pullRequest=43

- name: Test
run: uv run --no-sync pytest

Check warning on line 78 in .github/workflows/ci.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Omitting "--no-build" can lead to the execution of setup scripts. Make sure it is safe here.

See more on https://sonarcloud.io/project/issues?id=pnstack_template-django&issues=AaDcG53j2DoGyeOZSruW&open=AaDcG53j2DoGyeOZSruW&pullRequest=43

deploy-check:
runs-on: ubuntu-latest
env:
DEBUG: 'false'
SECRET_KEY: ci-deploy-check-${{ github.run_id }}-not-a-real-secret-value
SECURE_HSTS_SECONDS: '31536000'
EMAIL_URL: smtp+tls://user:pass@smtp.example.com:587
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
with:
enable-cache: true

- name: Django deployment checks
run: |
uv sync --locked --no-build --no-dev
uv run --no-sync manage.py check --deploy --fail-level ERROR

Check warning on line 97 in .github/workflows/ci.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Omitting "--no-build" can lead to the execution of setup scripts. Make sure it is safe here.

See more on https://sonarcloud.io/project/issues?id=pnstack_template-django&issues=AaDcG53j2DoGyeOZSruX&open=AaDcG53j2DoGyeOZSruX&pullRequest=43
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1

- name: Log in to the Container registry
uses: docker/login-action@v3
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
Expand All @@ -54,10 +54,10 @@ jobs:
# tag with pr number
type=ref,event=pr
# tag with commit sha
type=sha,prefix={{branch}}-
type=sha

- name: Build and push Docker image
uses: docker/build-push-action@v6
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,7 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# Django
staticfiles/
.ruff_cache/
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
11 changes: 8 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8"
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
},
"python.formatting.provider": "none"
}
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
"python.testing.pytestEnabled": true
}
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Contributing

Thanks for helping improve this template.

1. Fork the repo and create a branch from `main`.
2. `cp .env.example .env && make install && make migrate`
3. Make your change. Add tests for new behavior.
4. Run `make format`, `make lint` and `make test`.
5. Open a pull request describing what changed and why.

Dependencies are managed with [uv](https://docs.astral.sh/uv/): use `uv add <pkg>` and commit the updated `uv.lock`.
Loading
Loading