No description
  • HTML 57.6%
  • Python 42.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Foster Cavender 716acdd2f6
Some checks failed
CI / format (push) Failing after 7s
CI / test (push) Failing after 8s
Validate capture files / validate (push) Successful in 7s
Merge pull request 'feature/backup-methods-network-grants-collapsed-default' (#20) from dev into main
Reviewed-on: #20
2026-08-27 23:28:42 +00:00
.forgejo debug: added debug step to push-drive workflow to sanity check secret contents. 2026-08-26 23:06:34 -06:00
docs docs: document multi-model backups, separate_storage_gb, and grants_netwrok_features. 2026-08-27 17:19:52 -06:00
ISSUE_TEMPLATE Revert "chore: add test comments to verify sync workflow." 2026-05-26 09:00:20 -06:00
providers fix: added fixed wip files with provider.name field. 2026-08-26 17:41:57 -06:00
schema feat: backups as array of methods, separate_storage_gb, and addon.grants_network_features. 2026-08-27 17:18:22 -06:00
scripts fix: moved scripts/ folder from inside .forgejo to project root. 2026-08-26 22:50:17 -06:00
src fix: request full drive scope in upload_file, matching what the OAuth refresh token was granted. 2026-08-26 23:17:27 -06:00
tests test: cover backups array shape and addon.grants_network_features acceptance/rejeciton. 2026-08-27 17:20:35 -06:00
tools/capture-form feat: multi-method backups editor, separate storage amounts, network feature grant checkboxes, collapsed-by-default-cards. 2026-08-27 17:19:08 -06:00
.editorconfig feat: add .editorconfig for Python projects. 2026-05-26 09:51:33 -06:00
.gitattributes chore: normalize line endings to LF and add .gitattributes. 2026-08-26 17:45:26 -06:00
.gitignore feat: add .gitignore for Python projects. 2026-05-26 09:51:58 -06:00
pull_request_template.md Update pull_request_template.md 2026-05-24 12:32:32 +00:00
pyproject.toml feat: add push-drive workflow to sync local provider files to the shared Drive folder. 2026-08-26 22:15:20 -06:00
README.md fix: fixed incorrect spacing in REAME.md. 2026-05-30 04:35:43 -06:00
xegames.config.yml fix: rename xegames.confi.yml to xegames.config.yml. 2026-05-30 04:36:46 -06:00

template-python

Template for XeplosionGames Python projects. Includes ruff formatting and linting, pytest testing, virtual environment management, and systemd service deployment to hub via CI/CD workflows.


Creating a repo from this template

  1. Click Use this template on Forgejo
  2. Update pyproject.toml — set name and description
  3. Follow the setup checklist below

Setup checklist

  • Set RELEASE_TOKEN secret in Settings → Secrets
  • Update name and description in pyproject.toml
  • Set SERVICE_NAME and DEPLOY_PATH in scripts/service-start.sh and scripts/service-stop.sh
  • Set healthcheck.endpoint in xegames.config.yml if service exposes HTTP
  • Create the service directory on hub:
  sudo mkdir -p /opt/
  sudo chown cicd:cicd /opt/
  • Clone repo on hub as cicd user:
  sudo -u cicd git clone git@git.xegames.online:XeplosionGames/.git /opt/
  • Create the systemd service file (see below)
  • Add sudoers entry on hub for service restart
  • Run create-project.sh from XeplosionGames/.forgejo to seed project board
  • Push to main and verify CI passes
  • Enable notify.zulip: true once service is stable

Virtual environment

This template uses Python's built-in venv for dependency isolation. The venv lives at <DEPLOY_PATH>/venv/ on the server and is created automatically by service-start.sh on first deploy.

Dependencies are defined in pyproject.toml:

  • [project.dependencies] — runtime dependencies
  • [project.optional-dependencies.dev] — dev/test dependencies (ruff, pytest)

To set up locally:

python -m venv venv
source venv/bin/activate        # Linux/Mac
venv\Scripts\activate           # Windows
pip install -e ".[dev]"

Systemd service

Python services run via systemd using the venv Python directly — no shell activation needed. Create a service file at /etc/systemd/system/<service>.service on hub:

[Unit]
Description=
After=network.target

[Service]
Type=simple
User=
WorkingDirectory=/opt/
ExecStart=/opt//venv/bin/python -m 
Restart=always
RestartSec=5
Environment=PYTHONUNBUFFERED=1

[Install]
WantedBy=multi-user.target

Then enable and start:

sudo systemctl daemon-reload
sudo systemctl enable 
sudo systemctl start 

Add a sudoers entry for the cicd user: cicd ALL=(ALL) NOPASSWD: /bin/systemctl restart cicd ALL=(ALL) NOPASSWD: /bin/systemctl stop


Code style

This repo uses ruff for both formatting and linting, configured via pyproject.toml.

To check locally:

ruff format --check .
ruff check .

To fix locally:

ruff format .
ruff check --fix .

Conventions

Rule Value
Indentation 4 spaces
Quotes Double quotes
Line length 100 characters
Line endings LF
Import sorting Enforced via ruff I rules

Testing

Tests live in tests/ and use pytest. Add test files following the test_*.py naming convention.

To run tests locally:

pytest

To run with coverage:

pytest --cov=src --cov-report=term-missing

Workflows

Workflow Trigger Purpose
ci-python.yml Every push / PR Format check + lint + pytest
deploy-production.yml Push to main Deploy to hub, setup venv, restart service
deploy-test.yml Push to dev Deploy to test environment (if enabled)
rollback.yml Manual / auto Roll back to previous commit
healthcheck.yml Scheduled Periodic service health check
release.yml Tag push v* Generate release notes + attach artifacts

Branch structure

Branch Purpose
main Production-ready, auto-deploys to hub
dev Active development, auto-deploys to test (if enabled)
feature/* Short-lived feature branches, PR to dev
hotfix/* Urgent fixes off main, PR to both main and dev

Commit convention

All commits use Conventional Commits format with a trailing period: : .

Type Use for
feat: New functionality
fix: Bug fixes
chore: Dependencies, tooling, refactors
docs: Documentation only
ci: CI/CD workflow changes
perf: Performance improvements
test: Adding or updating tests
style: Formatting only, no logic change