Files
hermes-agent/.github/workflows/tests.yml
Timmy Time ca737412ef
Some checks failed
Forge CI / smoke-and-build (pull_request) Failing after 35s
Fix #293: Poka-yoke - prevent hardcoded ~/.hermes paths
Added error-proofing to prevent hardcoded ~/.hermes paths that break
profile isolation. This is a poka-yoke (mistake-proofing) measure.

Changes:
1. Added .githooks/check_hardcoded_paths.py - pre-commit hook that detects:
   - Path.home() / '.hermes' patterns
   - '~/.hermes' in string literals
   - os.path.expanduser('~/.hermes') patterns
   - os.path.join(expanduser('~'), '.hermes') patterns

2. Updated .githooks/pre-commit.py to run the hardcoded path check

3. Added CI job in .github/workflows/tests.yml to check for hardcoded paths

4. Added comprehensive tests in tests/test_hardcoded_paths.py:
   - Tests for pattern detection
   - Tests for get_hermes_home() and display_hermes_home() functions
   - Tests for profile isolation
   - Integration tests for pre-commit hook

The hook ignores:
- hermes_constants.py (source of truth)
- Test files (can mock/test behavior)
- Documentation files (.md, README, etc.)
- Comments and docstrings

This prevents the recurring pattern of hardcoded paths that break
profile isolation, as mentioned in issue #293.

Fixes #293
2026-04-13 20:37:38 -04:00

89 lines
2.1 KiB
YAML

name: Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
# Cancel in-progress runs for the same PR/branch
concurrency:
group: tests-${{ github.ref }}
cancel-in-progress: true
jobs:
check-hardcoded-paths:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Check for hardcoded ~/.hermes paths
run: |
python .githooks/check_hardcoded_paths.py
# This will fail if any hardcoded paths are found
test:
runs-on: ubuntu-latest
container: catthehacker/ubuntu:act-22.04
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Set up Python 3.11
run: uv python install 3.11
- name: Install dependencies
run: |
uv venv .venv --python 3.11
source .venv/bin/activate
uv pip install -e ".[all,dev]"
- name: Run tests
run: |
source .venv/bin/activate
python -m pytest tests/ -q --ignore=tests/integration --ignore=tests/e2e --tb=short -n auto
env:
# Ensure tests don't accidentally call real APIs
OPENROUTER_API_KEY: ""
OPENAI_API_KEY: ""
NOUS_API_KEY: ""
e2e:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Set up Python 3.11
run: uv python install 3.11
- name: Install dependencies
run: |
uv venv .venv --python 3.11
source .venv/bin/activate
uv pip install -e ".[all,dev]"
- name: Run e2e tests
run: |
source .venv/bin/activate
python -m pytest tests/e2e/ -v --tb=short
env:
OPENROUTER_API_KEY: ""
OPENAI_API_KEY: ""
NOUS_API_KEY: ""