Skip to content
Draft

wip #16645

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 169 additions & 0 deletions .github/workflows/experiment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
name: Next-Gen CI Pipeline

on:
pull_request:
branches: [ main, preview ]
# Native Merge Queue support for exhaustive batching
merge_group:
types: [checks_requested]

# Stop burning money on abandoned iterative commits
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
# ==========================================
# 1. DISCOVERY ENGINE (The Router)
# ==========================================
discover:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.changes.outputs.all_changed_files }}
# Expose the dynamic Python matrix to downstream jobs
python_versions: ${{ steps.set-python.outputs.matrix }}
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
json: true
escape_json: false

- name: Determine Python Matrix (Risk-Tiering)
id: set-python
run: |
if [[ "${{ github.event_name }}" == "merge_group" ]]; then
echo "Merge Queue detected. Deploying exhaustive matrix."
echo 'matrix=["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]' >> $GITHUB_OUTPUT
else
echo "Pull Request detected. Deploying Min/Max Boundary matrix."
echo 'matrix=["3.9", "3.14"]' >> $GITHUB_OUTPUT
fi

# ==========================================
# 2. STATIC ANALYSIS (Grouped for Speed)
# ==========================================
static-checks:
needs: discover
if: ${{ needs.discover.outputs.packages != '[]' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package: ${{ fromJSON(needs.discover.outputs.packages) }}
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
python-version: "3.14"
enable-cache: true
cache-dependency-glob: "${{ matrix.package }}/setup.py"

- name: Run Lint and MyPy
run: |
cd ${{ matrix.package }}
export NOX_DEFAULT_VENV_BACKEND=uv
export UV_VENV_SEED=1
uvx --with 'nox[uv]' nox -s lint mypy lint_setup_py

# ==========================================
# 3. DOCUMENTATION BUILD
# ==========================================
docs-build:
needs: discover
if: ${{ needs.discover.outputs.packages != '[]' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package: ${{ fromJSON(needs.discover.outputs.packages) }}
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
python-version: "3.10"
enable-cache: true
cache-dependency-glob: "${{ matrix.package }}/setup.py"

- name: Build Docs and DocFX
run: |
cd ${{ matrix.package }}
export NOX_DEFAULT_VENV_BACKEND=uv
export UV_VENV_SEED=1
uvx --with 'nox[uv]' nox -s docs docfx

# ==========================================
# 4. UNIT TESTS (Dynamic 2D Matrix + Retries)
# ==========================================
unit-tests:
needs: discover
if: ${{ needs.discover.outputs.packages != '[]' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package: ${{ fromJSON(needs.discover.outputs.packages) }}
# Reads the array generated by the Discovery job
python: ${{ fromJSON(needs.discover.outputs.python_versions) }}
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python }}
enable-cache: true
cache-dependency-glob: "${{ matrix.package }}/setup.py"

- name: Execute Unit Tests (With Shock Absorbers)
run: |
cd ${{ matrix.package }}
export NOX_DEFAULT_VENV_BACKEND=uv
export UV_VENV_SEED=1
export UV_COMPILE_BYTECODE=1

# 3-Attempt retry loop to mask legacy flaky tests
for i in 1 2 3; do
echo "Attempt $i of 3 for Python ${{ matrix.python }}..."
if uvx --with 'nox[uv]' nox -s unit-${{ matrix.python }}; then
echo "Tests passed successfully!"
exit 0
fi
echo "Tests failed. Waiting 5 seconds before retrying..."
sleep 5
done

echo "::error::Tests failed after 3 attempts. This is a hard failure."
exit 1

# ==========================================
# 6. THE GATEKEEPER (Status Check Rollup)
# ==========================================
presubmit-passed:
if: always()
needs:
- discover
- static-checks
- docs-build
- 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

if [[ "${{ needs.discover.outputs.packages }}" == "[]" ]]; then
echo "No Python packages changed. Safely bypassing execution."
exit 0
fi

echo "All dynamically generated CI jobs completed successfully."
44 changes: 21 additions & 23 deletions .kokoro/system-single.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
#!/bin/bash
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# `-e` enables the script to automatically fail when a command fails
# `-o pipefail` sets the exit code to non-zero if any command fails,
# or zero if all commands in the pipeline exit successfully.
# Licensed under the Apache License, Version 2.0 (the "License"); ...
set -eo pipefail

pwd

# If NOX_SESSION is set, it only runs the specified session,
# otherwise run all the sessions.
NOX_SESSION_ARG=""

# IF NOX_FILE is set, it runs the specific nox file,
# otherwise it runs noxfile.py in the package directory.
NOX_FILE_ARG=""

[[ -z "${NOX_SESSION}" ]] || NOX_SESSION_ARG="-s ${NOX_SESSION}"

[[ -z "${NOX_FILE}" ]] || NOX_FILE_ARG="-f ${NOX_FILE}"

python3 -m nox ${NOX_SESSION_ARG} $NOX_FILE_ARG
# 3-Attempt retry loop to absorb GCP quota limits and network blips
for attempt in 1 2 3; do
echo "============================================"
echo "Execution attempt $attempt of 3..."
echo "============================================"

# Use the installed nox directly with the uv backend
if nox --backend uv ${NOX_SESSION_ARG} ${NOX_FILE_ARG}; then
echo "Tests passed successfully!"
exit 0
fi

if [[ $attempt -lt 3 ]]; then
echo "Tests failed. Backing off for 15 seconds to absorb quota limits..."
sleep 15
fi
done

echo "Tests failed after 3 attempts. Hard failure."
exit 1
2 changes: 1 addition & 1 deletion .kokoro/system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,4 @@ for path in `find 'packages' \
echo "No changes in ${package_name} and not a continuous build, skipping."
fi
done
exit ${RETVAL}
exit ${RETVAL}
1 change: 1 addition & 0 deletions packages/bigframes/.force_kokoro_trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Forcing system test execution for concurrency validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_fan_out_execution():
"""Verify L5 Fan-Out architecture executes successfully."""
assert True
1 change: 1 addition & 0 deletions packages/google-auth/.force_kokoro_trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Forcing system test execution for concurrency validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_fan_out_execution():
"""Verify L5 Fan-Out architecture executes successfully."""
assert True
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Forcing system test execution for concurrency validation
1 change: 1 addition & 0 deletions packages/google-cloud-bigtable/.force_kokoro_trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Forcing system test execution for concurrency validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_fan_out_execution():
"""Verify L5 Fan-Out architecture executes successfully."""
assert True
1 change: 1 addition & 0 deletions packages/google-cloud-datastore/.force_kokoro_trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Forcing system test execution for concurrency validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_fan_out_execution():
"""Verify L5 Fan-Out architecture executes successfully."""
assert True
1 change: 1 addition & 0 deletions packages/google-cloud-dns/.force_kokoro_trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Forcing system test execution for concurrency validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_fan_out_execution():
"""Verify L5 Fan-Out architecture executes successfully."""
assert True
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_fan_out_execution():
"""Verify L5 Fan-Out architecture executes successfully."""
assert True
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Forcing system test execution for concurrency validation
1 change: 1 addition & 0 deletions packages/google-cloud-firestore/.force_kokoro_trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Forcing system test execution for concurrency validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_fan_out_execution():
"""Verify L5 Fan-Out architecture executes successfully."""
assert True
1 change: 1 addition & 0 deletions packages/google-cloud-kms/tests/unit/test_dummy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# CI Prototype Verification
1 change: 1 addition & 0 deletions packages/google-cloud-logging/.force_kokoro_trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Forcing system test execution for concurrency validation
1 change: 1 addition & 0 deletions packages/google-cloud-ndb/.force_kokoro_trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Forcing system test execution for concurrency validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_fan_out_execution():
"""Verify L5 Fan-Out architecture executes successfully."""
assert True
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_fan_out_execution():
"""Verify L5 Fan-Out architecture executes successfully."""
assert True
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_fan_out_execution():
"""Verify L5 Fan-Out architecture executes successfully."""
assert True
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_fan_out_execution():
"""Verify L5 Fan-Out architecture executes successfully."""
assert True
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_fan_out_execution():
"""Verify L5 Fan-Out architecture executes successfully."""
assert True
1 change: 1 addition & 0 deletions packages/google-cloud-pubsub/.force_kokoro_trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Forcing system test execution for concurrency validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_fan_out_execution():
"""Verify L5 Fan-Out architecture executes successfully."""
assert True
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_fan_out_execution():
"""Verify L5 Fan-Out architecture executes successfully."""
assert True
1 change: 1 addition & 0 deletions packages/google-cloud-spanner/.force_kokoro_trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Forcing system test execution for concurrency validation
1 change: 1 addition & 0 deletions packages/google-cloud-storage/.force_kokoro_trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Forcing system test execution for concurrency validation
1 change: 1 addition & 0 deletions packages/google-cloud-storage/tests/unit/test_dummy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# CI Prototype Verification
1 change: 1 addition & 0 deletions packages/google-cloud-testutils/.force_kokoro_trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Forcing system test execution for concurrency validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_fan_out_execution():
"""Verify L5 Fan-Out architecture executes successfully."""
assert True
1 change: 1 addition & 0 deletions packages/pandas-gbq/.force_kokoro_trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Forcing system test execution for concurrency validation
1 change: 1 addition & 0 deletions packages/sqlalchemy-bigquery/.force_kokoro_trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Forcing system test execution for concurrency validation
1 change: 1 addition & 0 deletions packages/sqlalchemy-spanner/.force_kokoro_trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Forcing system test execution for concurrency validation
20 changes: 20 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Ensure you are on the sandbox branch
git checkout experiment-testing-infra

# Loop through the first 15 packages and inject an actual test file
for dir in $(find packages -mindepth 1 -maxdepth 1 -type d | head -n 15); do
# Ensure the target directory exists
mkdir -p "${dir}/tests/unit"

# Inject the passing test
cat << 'EOF' > "${dir}/tests/unit/test_scale_validation.py"
def test_fan_out_execution():
"""Verify L5 Fan-Out architecture executes successfully."""
assert True
EOF
done

# Commit and push the massive execution test
git add packages/
git commit -m "test: inject dummy unit tests across 15 packages to verify concurrent execution"
git push origin ci-architecture-prototype
Loading