mirror of
https://github.com/halfwaystudent/douyin-sparkflow.git
synced 2026-09-06 07:57:09 +08:00
fix: isolate CI tests from runtime user data
This commit is contained in:
@@ -32,6 +32,8 @@ jobs:
|
|||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
|
env:
|
||||||
|
USER_DATA: "[]"
|
||||||
run: python -m unittest discover -s tests -v
|
run: python -m unittest discover -s tests -v
|
||||||
- name: Test Douyin accessibility
|
- name: Test Douyin accessibility
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ from utils.config import get_config, get_userData, normalize_unique_id, save_use
|
|||||||
from utils.logger import setup_logger
|
from utils.logger import setup_logger
|
||||||
|
|
||||||
|
|
||||||
config = get_config()
|
|
||||||
user_data = get_userData()
|
|
||||||
logger = setup_logger(level=logging.DEBUG)
|
logger = setup_logger(level=logging.DEBUG)
|
||||||
debug_artifacts_dir = Path("logs/debug_artifacts")
|
debug_artifacts_dir = Path("logs/debug_artifacts")
|
||||||
debug_artifacts_dir.mkdir(parents=True, exist_ok=True)
|
debug_artifacts_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -27,6 +29,21 @@ class ConfigContractTests(unittest.TestCase):
|
|||||||
self.assertFalse(loaded["useProtocolSender"])
|
self.assertFalse(loaded["useProtocolSender"])
|
||||||
self.assertTrue(loaded["persistentBrowserProfiles"]["enabled"])
|
self.assertTrue(loaded["persistentBrowserProfiles"]["enabled"])
|
||||||
|
|
||||||
|
def test_tasks_import_does_not_require_runtime_user_data(self):
|
||||||
|
source_root = Path(__file__).resolve().parents[1]
|
||||||
|
env = os.environ.copy()
|
||||||
|
env["GITHUB_ACTIONS"] = "true"
|
||||||
|
env.pop("USER_DATA", None)
|
||||||
|
result = subprocess.run(
|
||||||
|
[sys.executable, "-c", "import core.tasks"],
|
||||||
|
cwd=source_root,
|
||||||
|
env=env,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
timeout=30,
|
||||||
|
)
|
||||||
|
self.assertEqual(0, result.returncode, result.stderr)
|
||||||
|
|
||||||
def test_profile_root_environment_override_wins(self):
|
def test_profile_root_environment_override_wins(self):
|
||||||
with patch.dict(os.environ, {"SPARKFLOW_BROWSER_PROFILE_ROOT": "/tmp/sparkflow-profiles"}):
|
with patch.dict(os.environ, {"SPARKFLOW_BROWSER_PROFILE_ROOT": "/tmp/sparkflow-profiles"}):
|
||||||
normalized = tasks._normalize_persistent_profile_config(config_module.DEFAULT_CONFIG)
|
normalized = tasks._normalize_persistent_profile_config(config_module.DEFAULT_CONFIG)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class DeploymentContractTests(unittest.TestCase):
|
|||||||
self.assertIn("working-directory: DouYinSparkFlow", text)
|
self.assertIn("working-directory: DouYinSparkFlow", text)
|
||||||
self.assertIn("SPARKFLOW_BROWSER_PROFILE_ROOT", text)
|
self.assertIn("SPARKFLOW_BROWSER_PROFILE_ROOT", text)
|
||||||
self.assertIn("SPARKFLOW_MANUAL_RUN", text)
|
self.assertIn("SPARKFLOW_MANUAL_RUN", text)
|
||||||
|
self.assertIn('USER_DATA: "[]"', text)
|
||||||
self.assertIn("path: DouYinSparkFlow/logs/", text)
|
self.assertIn("path: DouYinSparkFlow/logs/", text)
|
||||||
|
|
||||||
def test_github_actions_are_pinned_to_commit_shas(self):
|
def test_github_actions_are_pinned_to_commit_shas(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user