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
23 changes: 23 additions & 0 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"template": "https://github.com/viseshrp/yapc",
"commit": "b123cc504566db88232428f02c8c72f913433f9b",
"checkout": null,
"context": {
"cookiecutter": {
"author": "Visesh Prasad",
"email": "viseshrprasad@gmail.com",
"github_username": "viseshrp",
"pypi_username": "viseshrp",
"project_name": "pydynamicreporting",
"project_slug": "pydynamicreporting",
"project_description": "This is a template repository for Python projects that use uv for their dependency management.",
"cli_tool": "n",
"codecov": "y",
"git_init": "n",
"github_actions": "y",
"_template": "https://github.com/viseshrp/yapc",
"_commit": "b123cc504566db88232428f02c8c72f913433f9b"
}
},
"directory": null
}
44 changes: 0 additions & 44 deletions .flake8

This file was deleted.

16 changes: 16 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Always use LF line endings in the repository, normalize line endings
* text=auto eol=lf

# Explicitly set for Python files
*.py text eol=lf

# Explicitly set for Markdown and YAML
*.md text eol=lf
*.yml text eol=lf
*.yaml text eol=lf

# Set for TOML
*.toml text eol=lf

# Set for GitHub Actions
.github/** text eol=lf
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 @@
# Pull Request

Fixes #

## Proposed Changes

-
-
-
52 changes: 52 additions & 0 deletions .github/actions/setup-python-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "Setup Python Environment"
description: "Set up Python environment for the given Python version"

inputs:
python-version:
description: "Python version to use"
required: false
default: "3.13"
uv-version:
description: "uv version to use"
required: false
default: "latest"

runs:
using: "composite"
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: ${{ inputs.uv-version }}
enable-cache: true
cache-suffix: ${{ inputs.python-version }}

- name: Cache .venv directory
uses: actions/cache@v4
with:
path: .venv
key: uv-venv-${{ inputs.python-version }}-${{ hashFiles('pyproject.toml', 'uv.lock') }}
restore-keys: |
uv-venv-${{ inputs.python-version }}-

- name: Disable pip version check (optional)
run: echo "PIP_DISABLE_PIP_VERSION_CHECK=1" >> $GITHUB_ENV
shell: bash

- name: Install Python dependencies
run: make install
shell: bash

- name: Add .venv to PATH (cross-platform)
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
echo "$(pwd)/.venv/Scripts" >> $GITHUB_PATH
else
echo "$(pwd)/.venv/bin" >> $GITHUB_PATH
fi
shell: bash
16 changes: 14 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
# 1. Python dependencies from pyproject.toml
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 1
labels:
- "dependencies"
- "automerge"

# 2. GitHub-hosted things:
# - GitHub Actions in .github/workflows/
# - pre-commit hook revs in .pre-commit-config.yaml
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 1
labels:
- "dependencies"
- "automerge"
44 changes: 44 additions & 0 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Automerge

on:
workflow_dispatch:
pull_request:
types:
- labeled
- synchronize
- opened
- reopened

permissions:
contents: write
pull-requests: write
issues: write

jobs:
automerge:
if: contains(github.event.pull_request.labels.*.name, 'automerge')
runs-on: ubuntu-latest
steps:
- name: Debug PR info
run: |
echo "PR author: ${{ github.event.pull_request.user.login }}"
echo "Labels: ${{ toJson(github.event.pull_request.labels) }}"

- name: Auto-approve
if: |
github.event.pull_request.user.login == 'github-actions[bot]' ||
github.event.pull_request.user.login == 'dependabot[bot]' ||
github.event.pull_request.user.login == 'viseshrp'
uses: hmarr/auto-approve-action@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
pull-request-number: ${{ github.event.pull_request.number }}

- name: Enable auto-merge
uses: peter-evans/enable-pull-request-automerge@v3
env:
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
merge-method: squash
pull-request-number: ${{ github.event.pull_request.number }}
48 changes: 48 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: "CodeQL Python"

on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Every night at 11:00 PM Eastern / 04:00 AM UTC
- cron: '0 4 * * *'

jobs:
analyze:
name: CodeQL Python Analysis
runs-on: ubuntu-latest

permissions:
# Required to upload code scanning results
security-events: write

# Only needed if you pull in private/internal packs
packages: read

# Required to read your repo’s contents
actions: read
contents: read

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python + Environment
uses: ./.github/actions/setup-python-env

- name: Initialize CodeQL for Python
uses: github/codeql-action/init@v3
with:
languages: python
# Python is interpreted; no build step required
build-mode: none
queries: +security-extended,security-and-quality

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
# Tag results clearly for Python
category: "/language:python"
52 changes: 52 additions & 0 deletions .github/workflows/create-draft-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Create Draft Release

on:
workflow_dispatch:
push:
tags:
- 'v*'

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

jobs:
draft-release:
runs-on: ubuntu-latest
permissions:
contents: write # needed to create a release & upload artifacts

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Set up Python Env
uses: ./.github/actions/setup-python-env

- name: Run version checks
run: make check-version

- name: Build package
run: make build

- name: Check for existing release
run: |
if gh release view "${{ github.ref_name }}" > /dev/null 2>&1; then
echo "❌ Release for tag '${{ github.ref_name }}' already exists."
exit 1
fi
env:
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

- name: Create Draft GitHub Release with Artifacts
run: |
gh release create "${{ github.ref_name }}" \
--title "Release ${GITHUB_REF_NAME}" \
--notes "See [CHANGELOG.md](./CHANGELOG.md)" \
--draft \
dist/*
env:
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
71 changes: 71 additions & 0 deletions .github/workflows/pre-commit-autoupdate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Pre-commit Autoupdate

on:
schedule:
- cron: '0 4 * * *' # Daily at 4 AM UTC / 11 PM Eastern
workflow_dispatch:

permissions:
pull-requests: write
contents: write
issues: write # Needed to create labels

jobs:
autoupdate:
if: startsWith(github.ref, 'refs/heads/main') # Ensure we only run from main
name: Autoupdate Pre-commit Hooks
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
fetch-depth: 0

- name: Cache pre-commit hooks
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Set up Python + Environment
uses: ./.github/actions/setup-python-env

- name: Run pre-commit autoupdate
run: uv run pre-commit autoupdate
continue-on-error: true

- name: Run pre-commit checks
run: make check

- name: Show updated hooks (if any)
run: git diff .pre-commit-config.yaml || true

- name: Commit changes
run: |
git add .pre-commit-config.yaml
git commit -m "chore(pre-commit): Update pre-commit hooks" || echo "No changes to commit"

- name: Ensure labels exist
run: |
gh label create dependencies --description "Dependency updates" --color FFCD00 || echo "Label 'dependencies' already exists"
gh label create chore --description "Chores and maintenance" --color 00CED1 || echo "Label 'chore' already exists"
gh label create automerge --description "automerge" --color 3E0651 || echo "Label 'automerge' already exists"
env:
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

- name: Create Pull Request for Updated Hooks
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
base: main
branch: chore/pre-commit-update
title: "chore(pre-commit): Update pre-commit hooks"
commit-message: "chore(pre-commit): Update pre-commit hooks"
body: |
# Update pre-commit hooks

- This PR updates the versions of pre-commit hooks to their latest releases.
labels: dependencies, chore, automerge
delete-branch: true
Loading
Loading