From fc09ffb8be0d90d613d00c5c91e689e8d419cd40 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Mar 2026 16:32:05 +0000 Subject: [PATCH 1/2] Add auto-push-to-main workflow triggered from testing branch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a push lands on the `testing` branch, the new workflow: 1. Runs ruff lint and pytest tests 2. Checks whether testing is ahead of main 3. Creates a PR (testing → main) if one does not already exist 4. Merges the PR immediately using the built-in GITHUB_TOKEN No extra secrets are required; the testing branch is preserved after merge. https://claude.ai/code/session_01YbWdZzfzmkn5sqW3ByjUB7 --- .github/workflows/auto-push-main.yml | 60 ++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/auto-push-main.yml diff --git a/.github/workflows/auto-push-main.yml b/.github/workflows/auto-push-main.yml new file mode 100644 index 0000000..fc3f2d5 --- /dev/null +++ b/.github/workflows/auto-push-main.yml @@ -0,0 +1,60 @@ +name: Auto Push to Main + +on: + push: + branches: [testing] + +permissions: + contents: write + pull-requests: write + +jobs: + lint-test-merge: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 # needed for ahead/behind check + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + pip install ruff + pip install -r tests/requirements.txt + + - name: Lint (ruff) + run: ruff check . + + - name: Tests (pytest) + run: pytest tests/ -v + + - name: Check if testing is ahead of main + id: ahead_check + run: | + git fetch origin main + AHEAD=$(git rev-list origin/main..HEAD --count) + echo "ahead=$AHEAD" >> "$GITHUB_OUTPUT" + + - name: Create PR (testing → main) + if: steps.ahead_check.outputs.ahead != '0' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr create \ + --base main \ + --head testing \ + --title "Auto-merge: testing → main (run #${{ github.run_number }})" \ + --body "Automatically created by **Auto Push to Main** workflow after lint and tests passed on the \`testing\` branch." \ + || echo "PR already exists — will merge existing PR" + + - name: Merge PR into main + if: steps.ahead_check.outputs.ahead != '0' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh pr merge testing --merge --delete-branch=false From bee0ecd54d2f09e97b59bf3492d67a9c2e9a2964 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Mar 2026 16:41:16 +0000 Subject: [PATCH 2/2] Fix all CI check failures on main Three issues were causing every CI run to fail: 1. web/app.py: remove unused `import time` (ruff F401) 2. tests/requirements.txt: add missing flask-wtf dependency required by test_web_app.py (importing web/app.py which uses CSRFProtect) 3. tests/test_web_app.py: set WTF_CSRF_ENABLED=False in the test client fixture so POST requests to /api/delete aren't blocked by CSRF validation (was returning 400 instead of 200/401) All 26 tests now pass and ruff reports no issues. https://claude.ai/code/session_01YbWdZzfzmkn5sqW3ByjUB7 --- tests/requirements.txt | 1 + tests/test_web_app.py | 1 + web/app.py | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/requirements.txt b/tests/requirements.txt index ff4c6b5..c40fa15 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,4 +1,5 @@ pytest>=7.0,<9 pytest-mock>=3.0,<4 flask>=2.3,<4 +flask-wtf>=1.1,<2 praw>=7.6,<8 diff --git a/tests/test_web_app.py b/tests/test_web_app.py index 753615d..2fbdaad 100644 --- a/tests/test_web_app.py +++ b/tests/test_web_app.py @@ -19,6 +19,7 @@ def client(): flask_app.config["TESTING"] = True flask_app.config["SECRET_KEY"] = "test-secret" + flask_app.config["WTF_CSRF_ENABLED"] = False with flask_app.test_client() as c: yield c diff --git a/web/app.py b/web/app.py index b0a7ecb..0472405 100644 --- a/web/app.py +++ b/web/app.py @@ -1,7 +1,6 @@ import json import os import sys -import time from datetime import datetime, timezone import praw