Merge pull request #66 from roboticforce/develop #109
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: Task Type System Tests | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| paths: | |
| - 'sugar/main.py' | |
| - 'sugar/storage/task_type_manager.py' | |
| - 'sugar/storage/work_queue.py' | |
| - 'tests/test_task_types.py' | |
| - '.github/workflows/test-task-types.yml' | |
| pull_request: | |
| branches: [ main, develop ] | |
| paths: | |
| - 'sugar/main.py' | |
| - 'sugar/storage/task_type_manager.py' | |
| - 'sugar/storage/work_queue.py' | |
| - 'tests/test_task_types.py' | |
| - '.github/workflows/test-task-types.yml' | |
| jobs: | |
| test-task-types: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| python-version: ['3.11', '3.12'] | |
| exclude: | |
| # Reduce matrix size for efficiency while keeping good coverage | |
| - os: macos-latest | |
| python-version: '3.11' | |
| - os: windows-latest | |
| python-version: '3.11' | |
| env: | |
| # Fix Windows Unicode encoding for emoji in output | |
| PYTHONIOENCODING: utf-8 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache pip dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install -e . | |
| # Install test dependencies | |
| pip install pytest pytest-asyncio pytest-cov click | |
| - name: Run task type system tests | |
| run: | | |
| pytest tests/test_task_types.py -v --tb=short --cov=sugar.storage.task_type_manager --cov=sugar.main --cov-report=xml --cov-report=term-missing | |
| - name: Upload coverage to Codecov | |
| if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage.xml | |
| flags: task-types | |
| name: task-type-system | |
| fail_ci_if_error: false | |
| test-cli-regression: | |
| runs-on: ubuntu-latest | |
| needs: test-task-types | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install -e . | |
| - name: CLI Smoke Test - Basic Commands | |
| run: | | |
| # Test basic CLI functionality doesn't break with new task type system | |
| sugar --help | |
| sugar init --help | |
| sugar add --help | |
| sugar list --help | |
| sugar task-type --help | |
| - name: CLI Smoke Test - Task Type Workflow | |
| run: | | |
| # Initialize Sugar | |
| mkdir -p test-project | |
| cd test-project | |
| sugar init | |
| # Test task type operations | |
| sugar task-type list | |
| sugar task-type add smoke_test --name "Smoke Test" --emoji "💨" | |
| sugar task-type list | grep smoke_test | |
| sugar task-type show smoke_test | |
| # Test using custom type in tasks | |
| sugar add "Test custom type workflow" --type smoke_test --priority 3 | |
| sugar list --type smoke_test --limit 1 | |
| # Test editing and removing | |
| sugar task-type edit smoke_test --description "Updated smoke test description" | |
| sugar task-type show smoke_test | grep "Updated smoke test" | |
| # Remove the task first (required before removing task type) | |
| TASK_ID=$(sugar list --type smoke_test --format json | python3 -c "import sys, json; tasks=json.load(sys.stdin); print(tasks[0]['id'] if tasks else '')") | |
| if [ -n "$TASK_ID" ]; then | |
| sugar remove "$TASK_ID" | |
| fi | |
| sugar task-type remove smoke_test --force | |
| # Verify removal | |
| if sugar task-type show smoke_test 2>/dev/null; then | |
| echo "ERROR: Task type should have been removed" | |
| exit 1 | |
| fi | |
| echo " CLI smoke test passed!" | |
| test-backwards-compatibility: | |
| runs-on: ubuntu-latest | |
| needs: test-task-types | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install -e . | |
| - name: Test Migration from Old Database | |
| run: | | |
| mkdir -p migration-test | |
| cd migration-test | |
| # Initialize Sugar | |
| sugar init | |
| # Simulate old database by removing task_types table | |
| sqlite3 .sugar/sugar.db "DROP TABLE IF EXISTS task_types;" | |
| # Add a task (should trigger migration) | |
| sugar add "Migration test task" --type feature | |
| # Verify migration worked | |
| sugar task-type list | grep "feature (default)" | |
| # Verify we can still use default types | |
| sugar add "Another test" --type bug_fix --priority 5 | |
| sugar list --type bug_fix --limit 1 | |
| echo " Migration test passed!" | |
| performance-test: | |
| runs-on: ubuntu-latest | |
| needs: test-task-types | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install -e . | |
| - name: Performance Test - Task Type Operations | |
| run: | | |
| mkdir -p perf-test | |
| cd perf-test | |
| sugar init | |
| echo "Testing performance of task type operations..." | |
| # Time task type listing | |
| start_time=$(date +%s%N) | |
| for i in {1..100}; do | |
| sugar task-type list > /dev/null | |
| done | |
| end_time=$(date +%s%N) | |
| list_time=$(( (end_time - start_time) / 1000000 )) # Convert to milliseconds | |
| echo "100 task-type list operations: ${list_time}ms (avg: $((list_time/100))ms per operation)" | |
| # Performance threshold check (should be reasonably fast) | |
| # Note: 1000ms threshold accounts for Python startup, imports, asyncio, and database operations | |
| # GitHub Actions runners can be slower than local development machines | |
| if [ $((list_time/100)) -gt 1000 ]; then | |
| echo "ERROR: Performance regression: task-type list too slow (>1000ms per operation)" | |
| exit 1 | |
| fi | |
| # Time custom task type creation and usage | |
| start_time=$(date +%s%N) | |
| for i in {1..10}; do | |
| sugar task-type add "perf_test_$i" --name "Performance Test $i" --emoji "⚡" | |
| sugar add "Performance test task $i" --type "perf_test_$i" --priority 3 | |
| done | |
| end_time=$(date +%s%N) | |
| create_time=$(( (end_time - start_time) / 1000000 )) | |
| echo "10 custom type create+use operations: ${create_time}ms (avg: $((create_time/10))ms per operation)" | |
| echo " Performance test passed!" |