Commit c27d3c2
authored
Intelligent CI Test Selection for PRs (#536)
# Intelligent CI Test Selection for PRs
## Summary
This PR implements intelligent test selection for pull requests,
automatically determining which integration test suites to run based on
changed files. This reduces CI time and costs by running only relevant
tests while maintaining safety through fallback mechanisms.
## Problem
Previously, all integration test suites ran on every PR regardless of
what code changed. This resulted in:
- Unnecessary CI execution time and costs
- Slower feedback cycles for developers
- Resource waste when only a small portion of the codebase changed
## Solution
The implementation analyzes changed files in PRs and maps them to
specific test suites. It includes:
- **Automatic test selection**: Runs only test suites relevant to
changed code paths
- **Safety fallbacks**: Runs all tests when changes touch critical
infrastructure or when analysis fails
- **Manual override**: Option to force running all tests via workflow
dispatch
## Changes
### 1. Test Suite Mapping Script
(`.github/scripts/determine-test-suites.py`)
- Analyzes git diff to identify changed files
- Maps code paths to test suites:
- `pinecone/db_control/` → control tests (serverless, resources/index,
resources/collections, asyncio variants)
- `pinecone/db_data/` → data tests (sync, asyncio, gRPC)
- `pinecone/inference/` → inference tests (sync, asyncio)
- `pinecone/admin/` → admin tests
- `pinecone/grpc/` → gRPC-specific tests
- Plugin-related files → plugin tests
- Identifies critical paths that require full test suite:
- `pinecone/config/`, `pinecone/core/`, `pinecone/openapi_support/`
- `pinecone/utils/`, `pinecone/exceptions/`
- Core interface files (`pinecone.py`, `pinecone_asyncio.py`, etc.)
- Falls back to running all tests if:
- Script execution fails
- No files match any mapping
- Critical paths are touched
### 2. Updated PR Workflow (`.github/workflows/on-pr.yaml`)
- Added `determine-test-suites` job that runs before integration tests
- Added `run_all_tests` input parameter for manual override via workflow
dispatch
- Passes selected test suites to integration test workflow
- Includes error handling and validation
### 3. Updated Integration Test Workflow
(`.github/workflows/testing-integration.yaml`)
- Added optional inputs for each job type's test suites:
- `rest_sync_suites_json`
- `rest_asyncio_suites_json`
- `grpc_sync_suites_json`
- `admin_suites_json`
- Filters test matrix based on provided suites
- Skips jobs when their test suite array is empty
- Maintains backward compatibility (runs all tests when inputs not
provided)
## Usage
### Automatic (Default)
On every PR, the workflow automatically:
1. Analyzes changed files
2. Determines relevant test suites
3. Runs only those test suites
### Manual Override
To force running all tests on a PR:
1. Go to Actions → "Testing (PR)" workflow
2. Click "Run workflow"
3. Check "Run all integration tests regardless of changes"
4. Run the workflow
## Safety Features
1. **Critical path detection**: Changes to core infrastructure (config,
utils, exceptions, etc.) trigger full test suite
2. **Fallback on failure**: If the analysis script fails, falls back to
running all tests
3. **Empty result handling**: If no tests match, runs all tests as a
safety measure
4. **Main branch unchanged**: Main branch workflows continue to run all
tests
## Example Scenarios
### Scenario 1: Change only `pinecone/db_data/index.py`
- **Runs**: `data`, `data_asyncio`, `data_grpc_futures` test suites
- **Skips**: `control/*`, `inference/*`, `admin`, `plugins` test suites
- **Result**: ~70% reduction in test execution
### Scenario 2: Change `pinecone/config/pinecone_config.py`
- **Runs**: All test suites (critical path)
- **Reason**: Configuration changes affect all functionality
### Scenario 3: Change `pinecone/inference/inference.py`
- **Runs**: `inference/sync`, `inference/asyncio` test suites
- **Skips**: Other test suites
- **Result**: ~85% reduction in test execution
## Testing
The implementation has been tested with:
- ✅ YAML syntax validation
- ✅ Python script syntax validation
- ✅ Test suite mapping logic verification
- ✅ Edge case handling (empty arrays, failures, etc.)
## Benefits
- **Cost savings**: Reduce CI costs by running only relevant tests
- **Faster feedback**: Developers get test results faster when only
subset runs
- **Better resource utilization**: CI runners are used more efficiently
- **Maintainability**: Easy to update mappings as codebase evolves
## Backward Compatibility
- Main branch workflows unchanged (still run all tests)
- PR workflows backward compatible (can manually trigger full suite)
- Existing test suite structure unchanged
- No changes to test code itself
## Future Improvements
Potential enhancements for future PRs:
- Track test execution time savings
- Add metrics/logging for test selection decisions
- Fine-tune mappings based on actual usage patterns
- Consider test dependencies (e.g., if A changes, also run B)1 parent e872037 commit c27d3c2
File tree
4 files changed
+325
-22
lines changed- .github
- scripts
- workflows
4 files changed
+325
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
20 | 26 | | |
21 | 27 | | |
22 | 28 | | |
| |||
34 | 40 | | |
35 | 41 | | |
36 | 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 | + | |
37 | 99 | | |
38 | 100 | | |
39 | 101 | | |
40 | 102 | | |
41 | 103 | | |
42 | 104 | | |
43 | 105 | | |
| 106 | + | |
44 | 107 | | |
45 | 108 | | |
46 | 109 | | |
47 | 110 | | |
48 | 111 | | |
| 112 | + | |
49 | 113 | | |
50 | 114 | | |
51 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
52 | 120 | | |
53 | 121 | | |
54 | 122 | | |
| |||
0 commit comments