Merge pull request #313 from HenriquesLab/fix/jacquemet-citation-v1.22.1 #679
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: Unified CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [main, dev] | |
| paths: | |
| - 'src/**' | |
| - 'tests/**' | |
| - 'pyproject.toml' | |
| - 'uv.lock' | |
| - 'noxfile.py' | |
| - '.github/workflows/ci.yml' | |
| pull_request: | |
| branches: [main, dev] | |
| paths: | |
| - 'src/**' | |
| - 'tests/**' | |
| - 'pyproject.toml' | |
| - 'uv.lock' | |
| - 'noxfile.py' | |
| - '.github/workflows/ci.yml' | |
| workflow_dispatch: | |
| inputs: | |
| test_suite: | |
| description: 'Test suite to run' | |
| required: false | |
| default: 'fast' | |
| type: choice | |
| options: | |
| - fast | |
| - full | |
| - system | |
| os_matrix: | |
| description: 'Operating systems to test' | |
| required: false | |
| default: 'ubuntu-latest' | |
| type: choice | |
| options: | |
| - ubuntu-latest | |
| - all | |
| python_matrix: | |
| description: 'Python versions to test' | |
| required: false | |
| default: '3.11' | |
| type: choice | |
| options: | |
| - '3.11' | |
| - all | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| FORCE_COLOR: 1 | |
| UV_SYSTEM_PYTHON: 1 | |
| PYTHONIOENCODING: utf-8 | |
| LC_ALL: C.UTF-8 | |
| LANG: C.UTF-8 | |
| jobs: | |
| # Job 1: Fast unit tests and linting (always runs) | |
| fast-tests: | |
| name: Fast Tests (${{ matrix.os }}, Python ${{ matrix.python-version }}) | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 15 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.os_matrix == 'all' && fromJson('["ubuntu-latest", "windows-latest", "macos-latest"]') || fromJson('["ubuntu-latest"]') }} | |
| python-version: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.python_matrix == 'all' && fromJson('["3.11", "3.12", "3.13"]') || fromJson('["3.11"]') }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: 'latest' | |
| enable-cache: true | |
| - name: Cache dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cache/uv | |
| .venv | |
| key: ci-fast-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/uv.lock') }} | |
| restore-keys: | | |
| ci-fast-${{ runner.os }}-${{ matrix.python-version }}- | |
| - name: Install dependencies | |
| run: | | |
| uv sync --frozen --extra dev | |
| - name: Run linting (Ubuntu only) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| echo "🔍 Running linting checks..." | |
| uv run nox -s lint | |
| echo "✅ Linting passed" | |
| - name: Run fast unit tests | |
| run: | | |
| echo "🧪 Running fast unit tests..." | |
| uv run nox -s "test(test_type='fast')" | |
| echo "✅ Fast tests passed" | |
| # Job 2: Integration tests (runs on successful fast tests) | |
| integration-tests: | |
| name: Integration Tests (${{ matrix.os }}, Python ${{ matrix.python-version }}) | |
| runs-on: ${{ matrix.os }} | |
| needs: fast-tests | |
| if: github.event.inputs.test_suite != 'fast' || github.event_name != 'workflow_dispatch' | |
| timeout-minutes: 25 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.os_matrix == 'all' && fromJson('["ubuntu-latest", "windows-latest", "macos-latest"]') || fromJson('["ubuntu-latest"]') }} | |
| python-version: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.python_matrix == 'all' && fromJson('["3.11", "3.12", "3.13"]') || fromJson('["3.11"]') }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: 'latest' | |
| enable-cache: true | |
| - name: Cache dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cache/uv | |
| .venv | |
| key: ci-integration-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/uv.lock') }} | |
| restore-keys: | | |
| ci-integration-${{ runner.os }}-${{ matrix.python-version }}- | |
| - name: Install dependencies | |
| run: | | |
| uv sync --frozen --extra dev | |
| - name: Run integration tests | |
| run: | | |
| echo "🧪 Running integration tests..." | |
| uv run nox -s "test(test_type='integration')" | |
| echo "✅ Integration tests passed" | |
| # Job 3: Build validation (runs in parallel with integration tests) | |
| build-validation: | |
| name: Build & Package Validation | |
| runs-on: ubuntu-latest | |
| needs: fast-tests | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.11' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: 'latest' | |
| enable-cache: true | |
| - name: Install dependencies | |
| run: | | |
| uv sync --frozen --extra dev | |
| - name: Run build validation | |
| run: | | |
| echo "📦 Running build validation..." | |
| uv run nox -s build | |
| echo "✅ Build validation passed" | |
| # Job 4: Coverage validation (runs after fast and integration tests) | |
| coverage-validation: | |
| name: Coverage Validation | |
| runs-on: ubuntu-latest | |
| needs: [fast-tests, integration-tests] | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.11' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: 'latest' | |
| enable-cache: true | |
| - name: Install dependencies | |
| run: | | |
| uv sync --frozen --extra dev | |
| - name: Run full test suite with coverage | |
| run: | | |
| echo "📊 Running full test suite with coverage validation..." | |
| uv run nox -s "test(test_type='full')" | |
| echo "✅ Coverage validation passed" | |
| # Job 5: System tests (manual trigger or specific conditions) | |
| system-tests: | |
| name: System Tests | |
| runs-on: ubuntu-latest | |
| needs: [integration-tests, build-validation] | |
| if: | | |
| github.event.inputs.test_suite == 'system' || | |
| (github.event_name == 'workflow_dispatch' && github.event.inputs.test_suite == 'full') || | |
| (github.event_name == 'pull_request' && contains(github.event.pull_request.changed_files, 'tests/system/')) | |
| timeout-minutes: 45 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.11' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: 'latest' | |
| enable-cache: true | |
| - name: Setup Docker for system tests | |
| run: | | |
| echo "🐳 Docker is pre-installed for system tests" | |
| docker --version | |
| - name: Install dependencies | |
| run: | | |
| uv sync --frozen --extra dev | |
| - name: Run system tests | |
| run: | | |
| echo "🧪 Running comprehensive system tests..." | |
| uv run nox -s test_system | |
| echo "✅ System tests passed" | |
| # Job 6: Security scanning (runs in parallel) | |
| security-scan: | |
| name: Security Scanning | |
| runs-on: ubuntu-latest | |
| needs: fast-tests | |
| if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.11' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: 'latest' | |
| enable-cache: true | |
| - name: Install dependencies | |
| run: | | |
| uv sync --frozen --extra dev | |
| - name: Run security checks | |
| run: | | |
| echo "🔒 Running security scanning..." | |
| uv run nox -s security | |
| echo "✅ Security checks passed" | |
| # Job 7: Documentation validation (runs in parallel) | |
| docs-validation: | |
| name: Documentation Validation | |
| runs-on: ubuntu-latest | |
| needs: fast-tests | |
| if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.11' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: 'latest' | |
| enable-cache: true | |
| - name: Install dependencies | |
| run: | | |
| uv sync --frozen --extra dev | |
| - name: Generate and validate documentation | |
| run: | | |
| echo "📚 Generating API documentation..." | |
| uv run nox -s docs | |
| echo "✅ Documentation validation passed" | |
| - name: Upload documentation artifacts | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: api-documentation | |
| path: docs/api/ | |
| retention-days: 30 | |
| # Summary job | |
| ci-summary: | |
| name: CI Pipeline Summary | |
| runs-on: ubuntu-latest | |
| needs: [fast-tests, integration-tests, build-validation, coverage-validation, system-tests, security-scan, docs-validation] | |
| if: always() | |
| steps: | |
| - name: Generate comprehensive summary | |
| run: | | |
| echo "## 🚀 Unified CI/CD Pipeline Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Stage | Status | Duration |" >> $GITHUB_STEP_SUMMARY | |
| echo "|-------|--------|----------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| Fast Tests | ${{ needs.fast-tests.result == 'success' && '✅ Passed' || '❌ Failed' }} | ~10min |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Integration Tests | ${{ needs.integration-tests.result == 'success' && '✅ Passed' || (needs.integration-tests.result == 'skipped' && '⏭️ Skipped') || '❌ Failed' }} | ~20min |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Build Validation | ${{ needs.build-validation.result == 'success' && '✅ Passed' || '❌ Failed' }} | ~10min |" >> $GITHUB_STEP_SUMMARY | |
| echo "| System Tests | ${{ needs.system-tests.result == 'success' && '✅ Passed' || (needs.system-tests.result == 'skipped' && '⏭️ Skipped') || '❌ Failed' }} | ~40min |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Security Scan | ${{ needs.security-scan.result == 'success' && '✅ Passed' || (needs.security-scan.result == 'skipped' && '⏭️ Skipped') || '❌ Failed' }} | ~10min |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Documentation | ${{ needs.docs-validation.result == 'success' && '✅ Passed' || (needs.docs-validation.result == 'skipped' && '⏭️ Skipped') || '❌ Failed' }} | ~5min |" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| # Determine overall pipeline status | |
| CORE_JOBS_PASSED=${{ needs.fast-tests.result == 'success' && needs.integration-tests.result == 'success' && needs.build-validation.result == 'success' }} | |
| OPTIONAL_JOBS_OK=${{ | |
| (needs.system-tests.result == 'success' || needs.system-tests.result == 'skipped') && | |
| (needs.security-scan.result == 'success' || needs.security-scan.result == 'skipped') && | |
| (needs.docs-validation.result == 'success' || needs.docs-validation.result == 'skipped') | |
| }} | |
| if [[ "$CORE_JOBS_PASSED" == "true" && "$OPTIONAL_JOBS_OK" == "true" ]]; then | |
| echo "🎉 **All CI pipeline stages completed successfully!**" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### ✨ Optimizations Active:" >> $GITHUB_STEP_SUMMARY | |
| echo "- ✅ Unified workflow with intelligent matrix strategies" >> $GITHUB_STEP_SUMMARY | |
| echo "- ✅ Leverages nox parametrized test sessions" >> $GITHUB_STEP_SUMMARY | |
| echo "- ✅ Conditional execution based on file changes" >> $GITHUB_STEP_SUMMARY | |
| echo "- ✅ Parallel job execution for faster feedback" >> $GITHUB_STEP_SUMMARY | |
| echo "- ✅ Cross-platform testing (Ubuntu, Windows, macOS)" >> $GITHUB_STEP_SUMMARY | |
| echo "- ✅ Multi-Python version support (3.11, 3.12, 3.13)" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "⚠️ **Some CI pipeline stages failed - check individual job logs**" >> $GITHUB_STEP_SUMMARY | |
| fi |