Skip to content
Merged

Dev #45

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
60 changes: 60 additions & 0 deletions .github/workflows/auto-push-main.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions tests/test_web_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion web/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json
import os
import sys
import time
from datetime import datetime, timezone

import praw
Expand Down