Commit 877025f
authored
feat: Optimize CI/CD workflows with conditional job execution and file change detection (#10)
## Summary
This PR significantly improves CI/CD efficiency by implementing
conditional job execution based on file changes. Jobs now only run when
relevant files are modified, reducing unnecessary workflow runs and
improving build times.
## Key Improvements
### 🚀 Performance Optimization
- **Smart File Change Detection**: Added `Detect Changes` job using
`dorny/paths-filter` to identify modified file types
- **Conditional Job Execution**: Jobs only run when their relevant files
change (e.g., Go tests run only when `.go` files change)
- **Resource Efficiency**: Reduces CI minutes usage by skipping
irrelevant jobs
### 📋 Workflow Changes
#### CI Workflow (`ci.yml`)
- Added `changes` job that detects modifications in:
- Go files (`*.go`, `go.mod`, `go.sum`, `.golangci.yml`)
- Scripts and workflow files
- Made all jobs conditional based on detected changes:
- `lint`: Runs only when Go files change
- `test`: Runs only when Go files change
- `acceptance-test`: Runs only when Go files change
- `build-provider`: Runs only when Go files change
- `terraform-compatibility`: Runs only when Go files change
- Updated `ci-status` job to handle skipped jobs correctly
#### Validation Workflow (`validation.yml`)
- Added file change detection for:
- Markdown files (`*.md`)
- YAML files (`*.yml`, `*.yaml`)
- JSON files (`*.json`, `*.jsonc`)
- Terraform files (`*.tf`, `*.tfvars`)
- Scripts
- Made validation jobs conditional:
- `file-validation`: Runs specific checks only when relevant files
change
- `markdown-lint`: Runs only when Markdown files change
- `terraform-fmt`: Runs only when Terraform files change
#### Pre-release Workflow
- **Separated Concerns**: Extracted pre-release job into dedicated
workflow (`.github/workflows/pre-release.yml`)
- **Simplified Triggers**: Removed `push` triggers from `ci.yml` and
`pre-commit.yml`
- **Better Organization**: Pre-release now triggers only on pushes to
`main` branch
### 🔧 Technical Details
#### Status Check Script Enhancement
Updated `scripts/ci-status-check.sh` to properly handle job statuses:
- `skipped` jobs are now considered acceptable (when no relevant files
changed)
- Better status reporting with counts of successful vs skipped jobs
- Improved error handling for cancelled jobs
## Benefits
1. **Faster PR Feedback**: Developers get quicker CI results by running
only relevant checks
2. **Cost Savings**: Reduced GitHub Actions minutes usage
3. **Better Maintainability**: Clearer separation of concerns with
dedicated workflows
4. **Improved Developer Experience**: Less waiting for irrelevant jobs
to complete
## Testing
- All conditional logic has been tested with various file change
scenarios
- Status checks properly handle skipped jobs
- Pre-release workflow functions independently on main branch
## Migration Notes
No action required. These changes are backward compatible and will
automatically optimize future CI runs.1 parent 1fe1955 commit 877025f
5 files changed
Lines changed: 263 additions & 145 deletions
File tree
- .github/workflows
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | 4 | | |
9 | 5 | | |
10 | 6 | | |
| |||
21 | 17 | | |
22 | 18 | | |
23 | 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 | + | |
24 | 44 | | |
25 | 45 | | |
26 | 46 | | |
| 47 | + | |
| 48 | + | |
27 | 49 | | |
28 | 50 | | |
29 | 51 | | |
| |||
37 | 59 | | |
38 | 60 | | |
39 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
40 | 73 | | |
| 74 | + | |
41 | 75 | | |
42 | 76 | | |
43 | 77 | | |
44 | 78 | | |
45 | 79 | | |
| 80 | + | |
46 | 81 | | |
47 | 82 | | |
48 | 83 | | |
| |||
53 | 88 | | |
54 | 89 | | |
55 | 90 | | |
| 91 | + | |
| 92 | + | |
56 | 93 | | |
57 | 94 | | |
58 | 95 | | |
| |||
95 | 132 | | |
96 | 133 | | |
97 | 134 | | |
98 | | - | |
| 135 | + | |
| 136 | + | |
99 | 137 | | |
100 | 138 | | |
101 | 139 | | |
| |||
149 | 187 | | |
150 | 188 | | |
151 | 189 | | |
152 | | - | |
| 190 | + | |
| 191 | + | |
153 | 192 | | |
154 | 193 | | |
155 | 194 | | |
| |||
184 | 223 | | |
185 | 224 | | |
186 | 225 | | |
187 | | - | |
| 226 | + | |
| 227 | + | |
188 | 228 | | |
189 | 229 | | |
190 | 230 | | |
| |||
260 | 300 | | |
261 | 301 | | |
262 | 302 | | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | 303 | | |
391 | 304 | | |
392 | 305 | | |
393 | 306 | | |
394 | 307 | | |
395 | 308 | | |
396 | | - | |
| 309 | + | |
397 | 310 | | |
398 | 311 | | |
399 | 312 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | 10 | | |
13 | 11 | | |
14 | 12 | | |
| |||
0 commit comments