Skip to content

Fix concurrency issues across storage layer #394

Fix concurrency issues across storage layer

Fix concurrency issues across storage layer #394

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
release:
types: [ published ]
permissions:
contents: read
packages: write
id-token: write
jobs:
test:
name: Test Suite
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
python-version: ['3.11', '3.12', '3.13']
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@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pytest pytest-asyncio pytest-cov 'black>=24.0.0,<26.0.0' flake8 mypy
- name: Lint with flake8
run: |
# Stop build if there are Python syntax errors or undefined names
flake8 sugar --count --select=E9,F63,F7,F82 --show-source --statistics
# Exit-zero treats all errors as warnings
flake8 sugar --count --exit-zero --max-complexity=10 --max-line-length=88 --statistics
- name: Check code formatting with black
run: |
black --check sugar tests
- name: Type check with mypy
run: |
# Temporarily disabled for release - TODO: Fix type annotations
echo "Type checking temporarily disabled - extensive type annotation work needed"
echo "Skipping mypy to unblock CI pipeline"
- name: Validate V3 SDK Integration
run: |
python -c "from sugar.agent.base import SugarAgent; print('Agent SDK OK')"
python -c "from sugar.executor.agent_sdk_executor import AgentSDKExecutor; print('Executor OK')"
- name: Test with pytest
run: |
pytest tests/ -v --cov=sugar --cov-report=xml --cov-report=term-missing --tb=short --ignore=tests/plugin/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
fail_ci_if_error: false
integration-test:
name: Integration Tests
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Sugar
run: |
python -m pip install --upgrade pip
pip install -e .
- name: Mock Claude CLI for testing
run: |
# Create a mock Claude CLI for integration tests
mkdir -p /tmp/mock-claude
echo '#!/bin/bash' > /tmp/mock-claude/claude
echo 'echo "Mock Claude CLI response"' >> /tmp/mock-claude/claude
chmod +x /tmp/mock-claude/claude
echo "/tmp/mock-claude" >> $GITHUB_PATH
- name: Integration test - Initialize project
run: |
mkdir test-project
cd test-project
sugar init
ls -la .sugar/
cat .sugar/config.yaml
- name: Integration test - Add and list tasks
run: |
cd test-project
sugar add "Test task" --type feature --priority 3
sugar list
sugar status
security-scan:
name: Security Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install security tools
run: |
pip install bandit safety
- name: Run bandit security linter
run: |
bandit -r sugar/ -f json -o bandit-results.json || true
- name: Check dependencies for known vulnerabilities
run: |
safety check --json --output safety-results.json || true
- name: Upload security results
uses: actions/upload-artifact@v4
with:
name: security-scan-results
path: |
bandit-results.json
safety-results.json
build:
name: Build Package
runs-on: ubuntu-latest
needs: [test, integration-test]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history for proper versioning
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: |
python -m build
- name: Check package
run: |
twine check dist/*
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist-packages
path: dist/
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [test, integration-test, build]
if: github.event_name == 'release' && github.event.action == 'published'
environment: release
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist-packages
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
docker:
name: Build Docker Image
runs-on: ubuntu-latest
needs: [test, integration-test]
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up Python for version extraction
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from pyproject.toml
id: version
run: |
VERSION=$(python -c "import tomllib; f=open('pyproject.toml','rb'); print(tomllib.load(f)['project']['version'])")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Found version: $VERSION"
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }}
build-args: |
VERSION=${{ steps.version.outputs.version }}
tags: |
ghcr.io/${{ github.repository_owner }}/sugar:latest
ghcr.io/${{ github.repository_owner }}/sugar:v${{ steps.version.outputs.version }}
${{ github.ref == 'refs/heads/main' && format('ghcr.io/{0}/sugar:main', github.repository_owner) || '' }}
cache-from: type=gha
cache-to: type=gha,mode=max