From a04fad2b7339e162526c64e7dc858a920ad854ad Mon Sep 17 00:00:00 2001 From: Wikid82 Date: Tue, 18 Nov 2025 10:57:03 -0500 Subject: [PATCH] feat: update issue templates and workflows; add python compile check and sourcery integration --- .github/ISSUE_TEMPLATE/alpha-feature.yml | 4 +-- .../beta-monitoring-feature.yml | 4 +-- .../ISSUE_TEMPLATE/beta-security-feature.yml | 4 +-- .github/workflows/auto-label-issues.yml | 2 +- .github/workflows/ci.yml | 3 ++ .github/workflows/create-labels.yml | 4 +-- .github/workflows/propagate-changes.yml | 1 - .pre-commit-config.yaml | 26 ++++++----------- .sourcery.yml | 4 +++ CaddyProxyManagerPlus.code-workspace | 2 +- ISSUE_5_43_IMPORT_IMPLEMENTATION.md | 4 +-- README.md | 2 ++ create_issues.sh | 2 +- requirements.dev.txt | 1 - tools/python_compile_check.sh | 5 ++++ tools/sourcery_precommit_wrapper.sh | 28 +++++++++++++++++++ 16 files changed, 64 insertions(+), 32 deletions(-) create mode 100644 .sourcery.yml create mode 100755 tools/python_compile_check.sh create mode 100755 tools/sourcery_precommit_wrapper.sh diff --git a/.github/ISSUE_TEMPLATE/alpha-feature.yml b/.github/ISSUE_TEMPLATE/alpha-feature.yml index f42236b2..51d0cc0d 100644 --- a/.github/ISSUE_TEMPLATE/alpha-feature.yml +++ b/.github/ISSUE_TEMPLATE/alpha-feature.yml @@ -50,7 +50,7 @@ body: - [ ] Task 2 - [ ] Task 3 value: | - - [ ] + - [ ] validations: required: true @@ -63,7 +63,7 @@ body: - [ ] Criteria 1 - [ ] Criteria 2 value: | - - [ ] + - [ ] validations: required: true diff --git a/.github/ISSUE_TEMPLATE/beta-monitoring-feature.yml b/.github/ISSUE_TEMPLATE/beta-monitoring-feature.yml index 5373fc4b..b1965956 100644 --- a/.github/ISSUE_TEMPLATE/beta-monitoring-feature.yml +++ b/.github/ISSUE_TEMPLATE/beta-monitoring-feature.yml @@ -77,7 +77,7 @@ body: - [ ] Task 2 - [ ] Task 3 value: | - - [ ] + - [ ] validations: required: true @@ -91,7 +91,7 @@ body: - [ ] Updates in real-time - [ ] Performance is acceptable value: | - - [ ] + - [ ] validations: required: true diff --git a/.github/ISSUE_TEMPLATE/beta-security-feature.yml b/.github/ISSUE_TEMPLATE/beta-security-feature.yml index 2ffcc0ca..d28c9d0d 100644 --- a/.github/ISSUE_TEMPLATE/beta-security-feature.yml +++ b/.github/ISSUE_TEMPLATE/beta-security-feature.yml @@ -77,7 +77,7 @@ body: - [ ] Task 2 - [ ] Task 3 value: | - - [ ] + - [ ] validations: required: true @@ -90,7 +90,7 @@ body: - [ ] Security test 1 - [ ] Security test 2 value: | - - [ ] + - [ ] validations: required: true diff --git a/.github/workflows/auto-label-issues.yml b/.github/workflows/auto-label-issues.yml index 87a7b935..92c8974e 100644 --- a/.github/workflows/auto-label-issues.yml +++ b/.github/workflows/auto-label-issues.yml @@ -69,6 +69,6 @@ jobs: issue_number: issue.number, labels: labels }); - + console.log(`Added labels: ${labels.join(', ')}`); } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ab40aad..866cf3ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,9 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.dev.txt + - name: Run pre-commit + run: | + pre-commit run --all-files - name: Run ruff run: | ruff check . diff --git a/.github/workflows/create-labels.yml b/.github/workflows/create-labels.yml index da3abb81..35523829 100644 --- a/.github/workflows/create-labels.yml +++ b/.github/workflows/create-labels.yml @@ -20,12 +20,12 @@ jobs: { name: 'high', color: 'D93F0B', description: 'Important feature, should be included' }, { name: 'medium', color: 'FBCA04', description: 'Nice to have, can be deferred' }, { name: 'low', color: '0E8A16', description: 'Future enhancement, not urgent' }, - + // Milestone labels { name: 'alpha', color: '5319E7', description: 'Part of initial alpha release' }, { name: 'beta', color: '0052CC', description: 'Part of beta release' }, { name: 'post-beta', color: '006B75', description: 'Post-beta enhancement' }, - + // Category labels { name: 'architecture', color: 'C5DEF5', description: 'System design and structure' }, { name: 'backend', color: '1D76DB', description: 'Server-side code' }, diff --git a/.github/workflows/propagate-changes.yml b/.github/workflows/propagate-changes.yml index ee3db098..ec3d4f3c 100644 --- a/.github/workflows/propagate-changes.yml +++ b/.github/workflows/propagate-changes.yml @@ -93,4 +93,3 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SOURCE_BRANCH: ${{ steps.branches.outputs.source }} TARGET_BRANCH: ${{ steps.branches.outputs.target }} - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 33cbad67..c0812f31 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,22 +5,19 @@ repos: - id: black language_version: python3 - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.15.0 + rev: v0.14.5 hooks: - id: ruff args: ["--fix"] - - repo: https://github.com/sourcery-ai/sourcery - rev: v1.22.0 + - repo: local hooks: - - id: sourcery - args: ["--diff=git diff HEAD", "--no-summary", "--min-level=medium"] - # Only flag critical, high, and medium severity issues - # Low severity issues are excluded as they may be intentional - - repo: https://github.com/pre-commit/mirrors-isort - rev: v5.12.0 - hooks: - - id: isort - name: isort (python) + - id: python-compile + name: python compile check + entry: tools/python_compile_check.sh + language: script + files: ".*\\.py$" + pass_filenames: false + always_run: true - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 hooks: @@ -28,8 +25,3 @@ repos: - id: trailing-whitespace - id: check-yaml - id: check-added-large-files - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.6 - hooks: - - id: mypy - additional_dependencies: [] diff --git a/.sourcery.yml b/.sourcery.yml new file mode 100644 index 00000000..628ec063 --- /dev/null +++ b/.sourcery.yml @@ -0,0 +1,4 @@ +version: 1 +exclude: + - frontend/dist/** + - frontend/node_modules/** diff --git a/CaddyProxyManagerPlus.code-workspace b/CaddyProxyManagerPlus.code-workspace index 876a1499..57097327 100644 --- a/CaddyProxyManagerPlus.code-workspace +++ b/CaddyProxyManagerPlus.code-workspace @@ -5,4 +5,4 @@ } ], "settings": {} -} \ No newline at end of file +} diff --git a/ISSUE_5_43_IMPORT_IMPLEMENTATION.md b/ISSUE_5_43_IMPORT_IMPLEMENTATION.md index d342b5cd..e6bb7e8a 100644 --- a/ISSUE_5_43_IMPORT_IMPLEMENTATION.md +++ b/ISSUE_5_43_IMPORT_IMPLEMENTATION.md @@ -148,11 +148,11 @@ User actions: 1. **Handler Tests** (`backend/internal/api/handlers/*_test.go`) - RemoteServer CRUD tests mirroring `proxy_host_handler_test.go` - Import workflow tests (upload, preview, commit, cancel) - + 2. **Service Tests** (`backend/internal/services/*_test.go`) - Uniqueness validation tests - Domain conflict detection - + 3. **Importer Tests** (`backend/internal/caddy/importer_test.go`) - Caddyfile parsing with fixtures in `testdata/` - Host extraction edge cases diff --git a/README.md b/README.md index 755fe97c..45515526 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ pre-commit install pre-commit run --all-files ``` + The `pre-commit` configuration now includes a `python compile check` hook (backed by `python -m compileall`) so syntax errors are caught locally before hitting CI. + Development notes - Branching model: `development` is the main working branch; create `feature/**` branches from `development`. - CI enforces lint and coverage (75% fail-under) in `.github/workflows/ci.yml`. diff --git a/create_issues.sh b/create_issues.sh index 0706b453..90f24f92 100755 --- a/create_issues.sh +++ b/create_issues.sh @@ -32,7 +32,7 @@ create_issue() { local title="$1" local labels="$2" local body="$3" - + echo "Creating: $title" gh issue create \ --repo "$REPO" \ diff --git a/requirements.dev.txt b/requirements.dev.txt index ed54bd6c..f43f029a 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -12,7 +12,6 @@ pre-commit>=3.4 bandit>=1.8 tox>=4.11 pytest-timeout==2.4.0 -sourcery>=1.22.0 # Add more dev tools as required diff --git a/tools/python_compile_check.sh b/tools/python_compile_check.sh new file mode 100755 index 00000000..3221756c --- /dev/null +++ b/tools/python_compile_check.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Run python -m compileall quietly to catch syntax errors in the repo. +python -m compileall -q . diff --git a/tools/sourcery_precommit_wrapper.sh b/tools/sourcery_precommit_wrapper.sh new file mode 100755 index 00000000..eec81323 --- /dev/null +++ b/tools/sourcery_precommit_wrapper.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Wrapper for Sourcery pre-commit hook. +# Run Sourcery if the CLI is available or a token is provided. +# This supports both interactive `sourcery login` and token-based CI usage. + +if command -v sourcery >/dev/null 2>&1; then + exec sourcery "$@" +fi + +# Try python -m sourcery as a fallback +if python -m sourcery --version >/dev/null 2>&1; then + exec python -m sourcery "$@" +fi + +# If CLI not found but token env var present, try to run via 'sourcery' anyway +if [ -n "${SOURCERY_TOKEN:-}" ] || [ -n "${SOURCERY_API_TOKEN:-}" ] || [ -n "${SOURCERY_API_KEY:-}" ]; then + if command -v sourcery >/dev/null 2>&1; then + exec sourcery "$@" + fi + if python -m sourcery --version >/dev/null 2>&1; then + exec python -m sourcery "$@" + fi +fi + +echo "Sourcery CLI not available and no token detected; skipping sourcery pre-commit check." +exit 0