Units 16-17: Infrastructure validation and deployment patterns #118
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: Run coderipple tests and upload coverage | |
| # Updated CI/CD pipeline with dependency fixes to achieve 100% test success rate | |
| # Key additions: strands-agents, boto3, markdown-it-py, pytest | |
| # These dependencies resolve import errors and module detection issues | |
| on: | |
| push | |
| jobs: | |
| test_coderipple: # Renamed job for clarity, indicating it tests 'coderipple' | |
| name: Run coderipple tests and collect coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Validate Python version | |
| run: | | |
| echo "Validating Python version for CodeRipple compatibility..." | |
| python scripts/validate_python_version.py | |
| - name: Install dependencies for coderipple | |
| run: | | |
| # Upgrade pip to latest version | |
| pip install --upgrade pip | |
| # Install core dependencies that resolve test failures | |
| pip install strands-agents boto3 markdown-it-py pytest pytest-cov | |
| # Install application-specific dependencies for 'coderipple' from its requirements.txt | |
| # This now explicitly points to coderipple/requirements.txt | |
| if [ -f coderipple/requirements.txt ]; then | |
| pip install -r coderipple/requirements.txt | |
| else | |
| echo "Error: coderipple/requirements.txt not found. Please ensure it exists." | |
| exit 1 # Fail the job if requirements.txt is missing | |
| fi | |
| - name: Add coderipple/src to Python path | |
| # This is crucial so that Python can find modules from coderipple/src | |
| # when running tests from the coderipple directory. | |
| run: | | |
| echo "PYTHONPATH=$GITHUB_WORKSPACE/coderipple/src:$PYTHONPATH" >> $GITHUB_ENV | |
| - name: Run coderipple tests | |
| # Navigate to the 'coderipple' directory where its tests reside. | |
| # --cov=src tells pytest-cov to measure coverage specifically for the 'src' directory | |
| # within the current working directory ('coderipple'). | |
| run: | | |
| cd coderipple | |
| pytest --cov=src --cov-branch --cov-report=xml | |
| - name: Upload coderipple results to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| # The coverage XML report will be generated inside the 'coderipple' directory | |
| # because pytest was run from there. | |
| files: ./coderipple/coverage.xml | |
| # A helpful flag for Codecov when dealing with sub-modules | |
| # It tells Codecov to apply coverage to files relative to the 'coderipple' directory | |
| # rather than the root of the repo. | |
| flags: coderipple | |
| test_lambda: # New job to test AWS Lambda functions | |
| name: Run AWS Lambda tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install lambda dependencies | |
| run: | | |
| # Upgrade pip to latest version | |
| pip install --upgrade pip | |
| # Install core dependencies that resolve test failures | |
| pip install strands-agents boto3 markdown-it-py pytest pytest-cov | |
| # First install main coderipple package dependencies | |
| if [ -f coderipple/requirements.txt ]; then | |
| pip install -r coderipple/requirements.txt | |
| else | |
| echo "Error: coderipple/requirements.txt not found. Please ensure it exists." | |
| exit 1 | |
| fi | |
| # Install main coderipple package in editable mode | |
| pip install -e coderipple/ | |
| # Install lambda orchestrator package in editable mode | |
| if [ -f aws/lambda_orchestrator/requirements.txt ]; then | |
| pip install -r aws/lambda_orchestrator/requirements.txt | |
| pip install -e aws/lambda_orchestrator/ | |
| else | |
| echo "Error: aws/lambda_orchestrator/requirements.txt not found. Please ensure it exists." | |
| exit 1 | |
| fi | |
| - name: Run lambda tests with coverage | |
| env: | |
| # Mock AWS credentials for testing | |
| AWS_ACCESS_KEY_ID: test-key-id | |
| AWS_SECRET_ACCESS_KEY: test-secret-key | |
| AWS_DEFAULT_REGION: us-east-1 | |
| run: | | |
| cd aws/lambda_orchestrator | |
| # Run tests with coverage on lambda_handler.py | |
| pytest tests/ --cov=lambda_handler --cov-branch --cov-report=xml | |
| - name: Upload lambda results to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ./aws/lambda_orchestrator/coverage.xml | |
| flags: lambda |