Test librarian with new wrkflw #39
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 "::group::Testing $pkg (Python ${{ matrix.python }})" | |
| cd "$pkg" | |
| # Run test, pipe to log for clean UI folding | |
| if uvx --with 'nox[uv]' nox -s "unit-${{ matrix.python }}" > nox_output.log 2>&1; then | |
| cat nox_output.log | |
| else | |
| cat nox_output.log | |
| # Gracefully skip if the Python version isn't supported by this legacy package | |
| grep -q "Sessions not found:" nox_output.log || FAILED=1 | |
| fi | |
| cd "$GITHUB_WORKSPACE" | |
| echo "::endgroup::" | |
| 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." |