Test librarian with new wrkflw #41
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: CI Unit | |
| on: | |
| pull_request: | |
| branches: [ main, preview ] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| # ========================================== | |
| # 1. DISCOVERY & BUCKETING | |
| # ========================================== | |
| discover: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| buckets: ${{ steps.generate-matrix.outputs.buckets }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Detect Changed Packages | |
| id: changes | |
| uses: tj-actions/changed-files@v44 | |
| with: | |
| files: packages/** | |
| dir_names: true | |
| dir_names_max_depth: 2 | |
| matrix: false | |
| - name: Generate Balanced Buckets | |
| id: generate-matrix | |
| env: | |
| CHANGED_DIRS: ${{ steps.changes.outputs.all_changed_files }} | |
| run: python .github/scripts/matrix_generator.py --matrix-multiplier 6 --max-vms 40 | |
| # ========================================== | |
| # 2. HORIZONTAL EXECUTION | |
| # ========================================== | |
| unit-tests: | |
| needs: discover | |
| if: ${{ needs.discover.outputs.buckets != '[]' }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 60 | |
| matrix: | |
| chunk: ${{ fromJSON(needs.discover.outputs.buckets) }} | |
| python: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] | |
| name: Unit (Py ${{ matrix.python }}) | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v5 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| enable-cache: true | |
| - name: Optimize Core Dependencies | |
| run: git config --global url."${GITHUB_WORKSPACE}".insteadOf "https://github.com/googleapis/google-cloud-python" | |
| - name: Execute Chunk | |
| run: | | |
| export NOX_DEFAULT_VENV_BACKEND=uv | |
| FAILED=0 | |
| for pkg in ${{ matrix.chunk }}; do | |
| echo "==========================================================" | |
| echo "🚀 TESTING: $pkg (Python ${{ matrix.python }})" | |
| echo "==========================================================" | |
| cd "$pkg" | |
| # Clean, readable bash: Check if the session exists before running it | |
| if uvx --with 'nox[uv]' nox -l | grep -q "unit-${{ matrix.python }}"; then | |
| # Run the test and stream logs directly to the UI | |
| uvx --with 'nox[uv]' nox -s "unit-${{ matrix.python }}" || FAILED=1 | |
| else | |
| echo "⏭️ Session 'unit-${{ matrix.python }}' not defined for $pkg. Safely skipping." | |
| fi | |
| cd "$GITHUB_WORKSPACE" | |
| done | |
| exit $FAILED | |
| # ========================================== | |
| # 3. GATEKEEPER | |
| # ========================================== | |
| presubmit-passed: | |
| if: always() | |
| needs: [discover, unit-tests] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Evaluate Pipeline Status | |
| run: | | |
| if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" || "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then | |
| echo "::error::One or more required CI jobs failed or were cancelled." | |
| exit 1 | |
| fi | |
| echo "All dynamically generated CI jobs completed successfully." |