Skip to content
Closed
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
9 changes: 9 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@ FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT}
ARG USERNAME=vscode
ARG UV_VERSION=v0.4.30

# Install dependencies for lychee (link checker)
USER root
RUN apt-get update && apt-get install -y gcc pkg-config libssl-dev && rm -rf /var/lib/apt/lists/*

USER ${USERNAME}

# Install Rust and lychee link checker
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
. $HOME/.cargo/env && \
cargo install lychee

RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
mkdir -p /home/${USERNAME}/.cache && \
chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/.cache
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
// Dev Container definition for python_package
"name": "python_package",
// Dev Container definition for python_template
"name": "python_template",
"dockerComposeFile": ["docker-compose.yaml"],
"service": "app",
"workspaceFolder": "/workspace",
Expand Down
3 changes: 2 additions & 1 deletion .devcontainer/postStartCommand.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -euo pipefail
echo "Configuring git safe directory (idempotent)..."
git config --global --add safe.directory /workspace 2>/dev/null || true

uv sync --frozen
echo "Adding copier as tool"
uv tool install copier

echo "PostStart complete"
15 changes: 0 additions & 15 deletions .github/workflows/ci.yaml

This file was deleted.

115 changes: 115 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Build and Deploy Template

on:
push:
branches:
- template

jobs:
test-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout template branch
uses: actions/checkout@v4
with:
ref: template
fetch-depth: 0

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Check markdown links
uses: lycheeverse/lychee-action@v2
with:
args: --verbose --no-progress --exclude 'file://' --exclude 'host\.docker\.internal' '**/*.md' '**/*.md.jinja'
fail: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Avoid rate limiting when checking GitHub URLs

- name: Run template tests
run: make test

- name: Build template output
run: make build

- name: Get template commit SHA
id: template_sha
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Prepare PR body
id: pr_body
run: |
cat << 'EOF' > /tmp/pr_body.md
## 🤖 Automated Template Build

This PR contains the rendered template from the latest changes on the `template` branch.

**Source commit:** `${{ steps.template_sha.outputs.sha }}`
**Build timestamp:** ${{ github.event.head_commit.timestamp }}

### ✅ Validation
- Link checking passed
- Template tests passed
- Pre-commit hooks validated
EOF
echo "body_file=/tmp/pr_body.md" >> $GITHUB_OUTPUT

- name: Clone repository for main branch
run: |
cd ..
git clone https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/${{ github.repository }}.git main-repo
cd main-repo
# Try to checkout main, or create orphan if it doesn't exist
git checkout main 2>/dev/null || git checkout --orphan main

- name: Apply build output to main branch
run: |
cd ../main-repo
# Remove all files except .git
find . -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +
# Copy build output
cp -r ../${{ github.event.repository.name }}/build_output/. .
# Remove copier answers file (shouldn't be in generated project)
rm -f .copier-answers.yml

- name: Check for changes
id: check_changes
run: |
cd ../main-repo
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

# Ensure main branch exists
if ! git ls-remote --heads origin main | grep -q main; then
git checkout --orphan main
git add -A
git commit -m "Initial commit from template@${{ steps.template_sha.outputs.sha }}"
git push origin main
else
git checkout main 2>/dev/null || git checkout --orphan main
fi

git add -A
if git diff --staged --quiet; then
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "has_changes=true" >> $GITHUB_OUTPUT
fi

- name: Create Pull Request
if: steps.check_changes.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.PAT_TOKEN }}
path: ../main-repo
branch: template-build
base: main
title: "Build from template@${{ steps.template_sha.outputs.sha }}"
body-path: ${{ steps.pr_body.outputs.body_file }}
commit-message: "Build from template@${{ steps.template_sha.outputs.sha }}"
committer: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
171 changes: 16 additions & 155 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,160 +1,21 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py
# Copier template testing outputs
temp_out/
test_output/
build_output/

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Python cache from test runs
__pycache__/
*.pyc

# Celery stuff
celerybeat-schedule
celerybeat.pid
# OS files
.DS_Store
Thumbs.db

# SageMath parsed files
*.sage.py
# Editor files
.idea/
*.swp
*.swo
*~

# Environments
.env
# Template environment
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
Loading