Sync Extension: v2.4.0 #352
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| jobs: | |
| test: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| python-version: ['3.11'] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install Playwright browsers | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install playwright | |
| playwright install chromium | |
| - name: Install dependencies | |
| shell: bash | |
| run: | | |
| pip cache purge || true | |
| pip uninstall -y sentienceapi || true | |
| # Clean any bytecode cache (cross-platform Python approach) | |
| python -c "import pathlib; [p.unlink() for p in pathlib.Path('.').rglob('*.pyc')]" || true | |
| python -c "import pathlib, shutil; [shutil.rmtree(p) for p in pathlib.Path('.').rglob('__pycache__') if p.is_dir()]" || true | |
| pip install --no-cache-dir -e ".[dev]" | |
| pip install pre-commit mypy types-requests | |
| - name: Verify installed package | |
| shell: bash | |
| run: | | |
| echo "=== Installed sentience location ===" | |
| python -c "import sentience; print(sentience.__file__)" | |
| echo "=== Check assert_done in installed package ===" | |
| python -c "import inspect; from sentience.agent_runtime import AgentRuntime; source = inspect.getsource(AgentRuntime.assert_done); print(source); exit(1) if 'assertTrue' in source else print('Good: assert_ is correctly used')" | |
| - name: Verify source code | |
| shell: bash | |
| run: | | |
| python << 'EOF' | |
| # Check agent_runtime.py line 345 | |
| print("=== Checking agent_runtime.py line 345 ===") | |
| with open('sentience/agent_runtime.py', 'r', encoding='utf-8') as f: | |
| lines = f.readlines() | |
| print(''.join(lines[339:350])) | |
| # Verify assert_ method exists | |
| print("\n=== Verifying assert_ method exists ===") | |
| with open('sentience/agent_runtime.py', 'r', encoding='utf-8') as f: | |
| lines = f.readlines() | |
| for i, line in enumerate(lines, 1): | |
| if 'def assert_' in line: | |
| print(f'{i}:{line}', end='') | |
| # Check for problematic assertTrue patterns (should NOT exist) | |
| print("\n=== Checking for assertTrue patterns (should NOT exist) ===") | |
| import re | |
| with open('sentience/agent_runtime.py', 'r', encoding='utf-8') as f: | |
| content = f.read() | |
| # Check for self.assertTrue( - this is the bug | |
| if re.search(r'self\.assertTrue\s*\(', content): | |
| print('ERROR: Found self.assertTrue( - should be self.assert_( instead!') | |
| exit(1) | |
| # Check for assertTrue( without self. - unittest style (also wrong) | |
| if re.search(r'(?<!self\.)assertTrue\s*\(', content): | |
| print('ERROR: Found assertTrue( without self. - should use self.assert_( instead!') | |
| exit(1) | |
| print('Good: no problematic assertTrue patterns found') | |
| EOF | |
| - name: Lint with pre-commit | |
| continue-on-error: true | |
| run: | | |
| pre-commit run --all-files | |
| - name: Type check with mypy | |
| continue-on-error: true | |
| run: | | |
| mypy sentience --ignore-missing-imports --no-strict-optional | |
| - name: Check code style | |
| continue-on-error: true | |
| run: | | |
| black --check sentience tests --line-length=100 | |
| isort --check-only --profile black sentience tests | |
| flake8 sentience tests --max-line-length=100 --extend-ignore=E203,W503,E501 --max-complexity=15 | |
| - name: Build extension (if needed) | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| run: | | |
| if [ -d "../sentience-chrome" ]; then | |
| cd ../sentience-chrome && ./build.sh || echo "Extension build skipped (may not be available in CI)" | |
| else | |
| echo "Extension directory not found, skipping build" | |
| fi | |
| - name: Pre-test verification | |
| shell: bash | |
| run: | | |
| echo "=== Final check before tests ===" | |
| python << 'EOF' | |
| import re | |
| # Check the source file directly (not the installed package) | |
| # This ensures we're checking what's actually in the repo | |
| with open('sentience/agent_runtime.py', 'r', encoding='utf-8') as f: | |
| content = f.read() | |
| # Find assert_done method - look for the method definition and its body | |
| # Match from "def assert_done" until the next method/class at same indentation level | |
| assert_done_pattern = r'def assert_done\([^)]*\):.*?(?=\n def |\nclass |\Z)' | |
| assert_done_match = re.search(assert_done_pattern, content, re.DOTALL) | |
| if assert_done_match: | |
| assert_done_source = assert_done_match.group(0) | |
| print('assert_done method found') | |
| # Check for problematic patterns | |
| # Pattern 1: self.assertTrue( - this is the bug we're checking for | |
| if re.search(r'self\.assertTrue\s*\(', assert_done_source): | |
| print('ERROR: Found self.assertTrue( - should be self.assert_( instead!') | |
| print('\nassert_done source:') | |
| print(assert_done_source) | |
| exit(1) | |
| # Pattern 2: Check that assert_ is used correctly | |
| if 'self.assert_(' in assert_done_source: | |
| print('OK: self.assert_ is used correctly in assert_done') | |
| else: | |
| print('WARNING: self.assert_( not found in assert_done') | |
| print('\nassert_done source:') | |
| print(assert_done_source) | |
| exit(1) | |
| else: | |
| # Fallback: check entire file for the problematic pattern | |
| print('Could not isolate assert_done method, checking entire file...') | |
| if re.search(r'self\.assertTrue\s*\(', content): | |
| print('ERROR: Found self.assertTrue( in agent_runtime.py - should be self.assert_( instead!') | |
| exit(1) | |
| if 'self.assert_(' in content: | |
| print('OK: self.assert_ is used in agent_runtime.py') | |
| else: | |
| print('WARNING: Could not verify assert_ usage') | |
| EOF | |
| - name: Run tests | |
| run: | | |
| pytest tests/ -v | |
| env: | |
| CI: true |