-
Notifications
You must be signed in to change notification settings - Fork 1.7k
107 lines (91 loc) · 3.62 KB
/
experiment.yaml
File metadata and controls
107 lines (91 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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: |
# The Engine: uv handles virtualenvs, nox delegates to uv
export NOX_DEFAULT_VENV_BACKEND=uv
# The Fix: Forces uv to install `pip` in the venv so legacy `pip freeze` commands don't crash
export UV_VENV_SEED=1
# Speed optimization: Pre-compile python bytecode
export UV_COMPILE_BYTECODE=1
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."