Test librarian with new wrkflw #28
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: Next-Gen CI Pipeline | |
| on: | |
| pull_request: | |
| branches: [ main, preview ] | |
| merge_group: | |
| types: [checks_requested] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| # ========================================== | |
| # 1. DISCOVERY ENGINE (The Matrix Sharder) | |
| # ========================================== | |
| discover: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| chunks: ${{ steps.build-matrix.outputs.chunks }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Detect Changed Packages | |
| id: changes | |
| uses: tj-actions/changed-files@v44 | |
| with: | |
| files: packages/** | |
| dir_names: true | |
| dir_names_max_depth: 2 | |
| - name: Build Dynamic Shards | |
| id: build-matrix | |
| env: | |
| RAW_LIST: ${{ steps.changes.outputs.all_changed_files }} | |
| run: | | |
| python -c ' | |
| import os, json | |
| packages = os.environ.get("RAW_LIST", "").split() | |
| print(f"Detected {len(packages)} changed packages.") | |
| if not packages: | |
| chunks = [] | |
| else: | |
| # Shard into groups of 10 to completely bypass GitHubs 256 total job limit | |
| chunk_size = 10 | |
| chunks = [" ".join(packages[i:i+chunk_size]) for i in range(0, len(packages), chunk_size)] | |
| print(f"Created {len(chunks)} matrix shards.") | |
| with open(os.environ["GITHUB_OUTPUT"], "a") as f: | |
| f.write(f"chunks={json.dumps(chunks)}\n") | |
| ' | |
| # ========================================== | |
| # 2. STATIC ANALYSIS | |
| # ========================================== | |
| static-checks: | |
| needs: discover | |
| if: ${{ needs.discover.outputs.chunks != '[]' }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| chunk: ${{ fromJSON(needs.discover.outputs.chunks) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v5 | |
| with: | |
| python-version: "3.14" | |
| enable-cache: true | |
| - name: Run Lint and MyPy | |
| run: | | |
| export NOX_DEFAULT_VENV_BACKEND=uv | |
| export UV_VENV_SEED=1 | |
| FAILED=0 | |
| for pkg in ${{ matrix.chunk }}; do | |
| echo "::group::Linting $pkg" | |
| cd $pkg | |
| if ! uvx --with 'nox[uv]' nox -s lint mypy lint_setup_py; then | |
| echo "::error::Linting failed in $pkg" | |
| FAILED=1 | |
| fi | |
| cd $GITHUB_WORKSPACE | |
| echo "::endgroup::" | |
| done | |
| exit $FAILED | |
| # ========================================== | |
| # 3. DOCUMENTATION BUILD | |
| # ========================================== | |
| docs-build: | |
| needs: discover | |
| if: ${{ needs.discover.outputs.chunks != '[]' }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| chunk: ${{ fromJSON(needs.discover.outputs.chunks) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v5 | |
| with: | |
| python-version: "3.10" | |
| enable-cache: true | |
| - name: Build Docs and DocFX | |
| run: | | |
| export NOX_DEFAULT_VENV_BACKEND=uv | |
| export UV_VENV_SEED=1 | |
| FAILED=0 | |
| for pkg in ${{ matrix.chunk }}; do | |
| echo "::group::Docs $pkg" | |
| cd $pkg | |
| if ! uvx --with 'nox[uv]' nox -s docs docfx; then | |
| echo "::error::Docs failed in $pkg" | |
| FAILED=1 | |
| fi | |
| cd $GITHUB_WORKSPACE | |
| echo "::endgroup::" | |
| done | |
| exit $FAILED | |
| # ========================================== | |
| # 4a. UNIT TESTS (Python 3.9) | |
| # ========================================== | |
| unit-tests-3-9: | |
| needs: discover | |
| if: ${{ needs.discover.outputs.chunks != '[]' }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| chunk: ${{ fromJSON(needs.discover.outputs.chunks) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v5 | |
| with: | |
| python-version: "3.9" | |
| enable-cache: true | |
| - name: Execute Unit Tests (Python 3.9) | |
| run: | | |
| export NOX_DEFAULT_VENV_BACKEND=uv | |
| export UV_VENV_SEED=1 | |
| export UV_COMPILE_BYTECODE=1 | |
| FAILED=0 | |
| for pkg in ${{ matrix.chunk }}; do | |
| echo "::group::Testing $pkg" | |
| cd $pkg | |
| if ! uvx --with 'nox[uv]' nox -s unit-3.9; then | |
| echo "::error::Failed in $pkg" | |
| FAILED=1 | |
| fi | |
| cd $GITHUB_WORKSPACE | |
| echo "::endgroup::" | |
| done | |
| exit $FAILED | |
| # ========================================== | |
| # 4b. UNIT TESTS (Python 3.14) | |
| # ========================================== | |
| unit-tests-3-14: | |
| needs: discover | |
| if: ${{ needs.discover.outputs.chunks != '[]' }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| chunk: ${{ fromJSON(needs.discover.outputs.chunks) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v5 | |
| with: | |
| python-version: "3.14" | |
| enable-cache: true | |
| - name: Execute Unit Tests (Python 3.14) | |
| run: | | |
| export NOX_DEFAULT_VENV_BACKEND=uv | |
| export UV_VENV_SEED=1 | |
| export UV_COMPILE_BYTECODE=1 | |
| FAILED=0 | |
| for pkg in ${{ matrix.chunk }}; do | |
| echo "::group::Testing $pkg" | |
| cd $pkg | |
| if ! uvx --with 'nox[uv]' nox -s unit-3.14; then | |
| echo "::error::Failed in $pkg" | |
| FAILED=1 | |
| fi | |
| cd $GITHUB_WORKSPACE | |
| echo "::endgroup::" | |
| done | |
| exit $FAILED | |
| # ========================================== | |
| # 5. CORE DEPS FROM SOURCE | |
| # ========================================== | |
| unit-core-deps-from-source: | |
| needs: discover | |
| if: ${{ needs.discover.outputs.chunks != '[]' }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| chunk: ${{ fromJSON(needs.discover.outputs.chunks) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v5 | |
| with: | |
| python-version: "3.14" | |
| enable-cache: true | |
| - name: Execute Core Deps | |
| run: | | |
| export NOX_DEFAULT_VENV_BACKEND=uv | |
| export UV_VENV_SEED=1 | |
| export UV_COMPILE_BYTECODE=1 | |
| FAILED=0 | |
| for pkg in ${{ matrix.chunk }}; do | |
| echo "::group::Testing $pkg" | |
| cd $pkg | |
| # THE FIX: Look before you leap. | |
| # Grep the nox list to see if the session actually exists here. | |
| if uvx --with 'nox[uv]' nox -l | grep -q "core_deps_from_source"; then | |
| echo "Session found in $pkg. Executing..." | |
| # Run the test using the explicit name and python flag | |
| if ! uvx --with 'nox[uv]' nox -s "core_deps_from_source-3.14"; then | |
| echo "::error::Failed in $pkg" | |
| FAILED=1 | |
| fi | |
| else | |
| echo "Skipping: 'core_deps_from_source' is not defined for $pkg." | |
| fi | |
| cd $GITHUB_WORKSPACE | |
| echo "::endgroup::" | |
| done | |
| exit $FAILED | |
| # ========================================== | |
| # 6. THE GATEKEEPER | |
| # ========================================== | |
| presubmit-passed: | |
| if: always() | |
| needs: | |
| - discover | |
| - static-checks | |
| - docs-build | |
| - unit-tests-3-9 | |
| - unit-tests-3-14 | |
| - unit-core-deps-from-source | |
| 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." | |
| exit 1 | |
| fi | |
| if [[ "${{ needs.discover.outputs.chunks }}" == "[]" ]]; then | |
| echo "No packages changed. Safely bypassing execution." | |
| exit 0 | |
| fi | |
| echo "All jobs passed." |