3da61ba891eb7f1ecd80eae52300e56dfa17b63e
4 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d4d43862e3 |
fix: Create fresh DB template and atomically swap it
- Unit tests tend to fail due inconsitent DB file. - Create a fresh copy on a temporary location and the atomically swap it. - To always provide a completely initialized and migrated DB. |
||
|
|
0c5b140d29 |
fix(database): include alembic files in package distribution
CI / push-validation (pull_request) Successful in 18s
CI / lint (pull_request) Successful in 26s
CI / helm (pull_request) Successful in 38s
CI / build (pull_request) Successful in 48s
CI / quality (pull_request) Successful in 54s
CI / security (pull_request) Successful in 55s
CI / typecheck (pull_request) Successful in 57s
CI / e2e_tests (pull_request) Successful in 4m48s
CI / unit_tests (pull_request) Successful in 8m5s
CI / integration_tests (pull_request) Successful in 9m23s
CI / docker (pull_request) Successful in 1m23s
CI / coverage (pull_request) Successful in 12m29s
CI / benchmark-regression (push) Failing after 0s
CI / benchmark-publish (push) Failing after 0s
CI / status-check (pull_request) Successful in 1s
CI / push-validation (push) Successful in 12s
CI / helm (push) Successful in 29s
CI / build (push) Successful in 3m23s
CI / lint (push) Successful in 3m38s
CI / quality (push) Successful in 3m40s
CI / security (push) Successful in 4m3s
CI / typecheck (push) Successful in 4m5s
CI / e2e_tests (push) Successful in 6m42s
CI / unit_tests (push) Successful in 10m7s
CI / integration_tests (push) Successful in 10m13s
CI / docker (push) Successful in 1m46s
CI / coverage (push) Successful in 10m58s
CI / status-check (push) Successful in 2s
Move alembic configuration and migration files from repository root into the Python package structure to ensure they are included in the wheel distribution. This fix resolves the FileNotFoundError when running `agents init` in Docker containers or any environment using the built wheel distribution. Changes: - Move alembic/ directory from repo root to src/cleveragents/infrastructure/database/migrations/ - Move alembic.ini to the same new location and update script_location setting - Update MigrationRunner._find_alembic_ini() to search from the new canonical location within the package - Update create_template_db.py to point to the new alembic.ini location - Update documentation references to reflect new migration file locations - Create __init__.py for migrations package - The env.py file is imported when running tests that verify all modules can be imported without errors. However, context.config is only available when alembic is actually running migrations, not during normal module imports. This caused an AttributeError when the test tried to import the migrations.env module. - Fix by using getattr() with a default value to safely access context.config, and guard all code that uses config with None checks. This allows the module to be safely imported while still functioning correctly during migrations. Testing: - Verified MigrationRunner can locate alembic.ini in new location - Tested agents init succeeds in creating project with database - Template database creation works correctly - All migration tests should pass without changes Alembic files now follow standard Python packaging conventions, making them automatically included in wheel distributions without special configuration. ISSUES CLOSED: #4180 |
||
|
|
4c0f3e1da9 |
fix(tests): fix create_template_db.py to create writable SQLite template database
CI / push-validation (push) Successful in 17s
CI / helm (push) Successful in 23s
CI / build (push) Successful in 30s
CI / lint (push) Successful in 43s
CI / quality (push) Successful in 48s
CI / typecheck (push) Successful in 53s
CI / security (push) Successful in 53s
CI / e2e_tests (push) Successful in 3m22s
CI / integration_tests (push) Successful in 6m42s
CI / unit_tests (push) Successful in 7m47s
CI / docker (push) Successful in 1m31s
CI / coverage (push) Successful in 12m9s
CI / status-check (push) Successful in 1s
CI / push-validation (pull_request) Successful in 13s
CI / helm (pull_request) Successful in 26s
CI / lint (pull_request) Successful in 33s
CI / build (pull_request) Successful in 38s
CI / quality (pull_request) Successful in 45s
CI / typecheck (pull_request) Successful in 49s
CI / security (pull_request) Successful in 55s
CI / e2e_tests (pull_request) Successful in 3m38s
CI / integration_tests (pull_request) Successful in 6m40s
CI / unit_tests (pull_request) Successful in 7m44s
CI / docker (pull_request) Successful in 10s
CI / coverage (pull_request) Successful in 12m9s
CI / status-check (pull_request) Successful in 3s
Added os.chmod(db_path, 0o664) after database creation to ensure the template database has writable permissions. This prevents sqlite3.OperationalError: attempt to write a readonly database when tests copy and modify the template during test setup. The template database is now created with rw-rw-r-- (664) permissions instead of the default rw-r--r-- (644), allowing the test runner process to write to it. ISSUES CLOSED: #9372 |
||
|
|
a8f7ed57cb |
perf(tests): reduce per-feature startup cost with shared fixtures and lazy imports
Created scripts/create_template_db.py that builds a pre-migrated SQLite template database using Base.metadata.create_all() + alembic stamp (~5ms for 34 tables, vs ~0.5-3s x 25 Alembic migrations per scenario). Nox unit_tests and coverage_report sessions generate the template before test execution and propagate CLEVERAGENTS_TEMPLATE_DB env var to all workers. features/environment.py before_all() installs a monkey-patch on MigrationRunner.init_or_upgrade that copies the template for fresh scenario temp DBs, falling through to real migrations for :memory:, existing files, and migration-runner unit tests. Quick wins: sleep(0.5) -> sleep(0.05) in cli_streaming wait step; removed redundant Background re-declaration in cli_streaming.feature scenario 7. ISSUES CLOSED: #483 |