diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..b946d56 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,15 @@ +## Problem and change + +Describe the concrete problem and resulting behavior. Link an issue if applicable. + +## Validation + +List the commands or manual checks run and their results. Explain checks not run. + +## Review checklist + +- [ ] The branch targets the current default branch and preserves unrelated work. +- [ ] Documentation and configuration match the implemented behavior. +- [ ] Tests cover changed behavior where appropriate. +- [ ] No credentials, personal records, or client data are included. +- [ ] Deployment, migration, dependency, and rollback implications are documented where relevant. diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 8d100e4..febd1b7 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -38,5 +38,8 @@ jobs: - name: Import smoke test run: python -c "import app; import engine.pipeline; import engine.lead_scraper; import engine.followup_engine; import engine.social_manager" + - name: Import regression tests + run: python -m unittest discover -s tests -v + - name: Check required configuration files run: python -c "from pathlib import Path; assert Path('.env.example').exists(); assert Path('README.md').exists(); assert Path('SECURITY.md').exists(); assert Path('CONTRIBUTING.md').exists()" diff --git a/engine/followup_engine.py b/engine/followup_engine.py index c39fbf2..93a3bdc 100644 --- a/engine/followup_engine.py +++ b/engine/followup_engine.py @@ -29,10 +29,10 @@ from typing import Optional, List, Dict, Tuple, Any # Ensure we can import from pipeline.py -try: +if __package__: + from .pipeline import load_and_validate_env, detect_smtp_provider, is_valid_email +else: from pipeline import load_and_validate_env, detect_smtp_provider, is_valid_email -except ImportError: - sys.exit("❌ Could not import from pipeline.py. Make sure pipeline.py is in the same directory.") # ════════════════════════════════════════════════════════════════════════════════ # LOGGING SETUP diff --git a/tests/test_imports.py b/tests/test_imports.py new file mode 100644 index 0000000..191f4ff --- /dev/null +++ b/tests/test_imports.py @@ -0,0 +1,22 @@ +"""Import regression tests; never run outbound sales workflows.""" +import subprocess +import sys +import unittest +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] + + +class ImportTests(unittest.TestCase): + def check_import(self, code): + result = subprocess.run([sys.executable, "-c", code], cwd=ROOT, + capture_output=True, text=True, timeout=30, check=False) + self.assertEqual(result.returncode, 0, result.stderr or result.stdout) + + def test_package_import(self): + self.check_import("from engine import followup_engine, pipeline; " + "assert followup_engine.is_valid_email is pipeline.is_valid_email") + + def test_script_import(self): + self.check_import("import sys, runpy; sys.path.insert(0, 'engine'); " + "runpy.run_path('engine/followup_engine.py', run_name='import_check')")