-
Notifications
You must be signed in to change notification settings - Fork 182
Closed
Labels
Description
Objective
Implement incremental linting in CI using --new-from-rev flag to achieve 50-75% faster linting runs.
Context
Currently, the CI runs golangci-lint on the entire repository (~3-4 minutes). By using the --new-from-rev flag, we can lint only changed files, significantly reducing CI time.
Approach
- Update CI workflow to use
--new-from-revfor pull requests - Keep full repository scan for main branch merges
- Test performance improvement
- Document the optimization in Makefile comments
Files to Modify
.github/workflows/ci.yml- Update golangci-lint step (lines 418-419)Makefile- Consider adding agolint-incrementaltarget
Implementation
# .github/workflows/ci.yml
- name: Run golangci-lint
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
# Incremental linting on PRs
golangci-lint run --new-from-rev=origin/${{ github.base_ref }}
else
# Full scan on main branch
make golint
fiAlternative: Add Makefile target
golint-incremental:
`@if` [ -n "$(BASE_REF)" ]; then \
golangci-lint run --new-from-rev=$(BASE_REF); \
else \
echo "Error: BASE_REF not set. Use: make golint-incremental BASE_REF=origin/main"; \
exit 1; \
fiAcceptance Criteria
- PR builds use incremental linting
- Main branch builds use full linting
- CI time reduced by 50-75% on PRs
- All changed files are still linted
- No regressions slip through
- Performance improvement documented
Testing
- Create a test PR with small changes
- Monitor CI execution time
- Compare with previous full scan times
- Verify all changed files are checked
Expected Results
- Before: ~3-4 minutes full scan
- After: ~30-60 seconds incremental (on small PRs)
- Large PRs: Still benefit but less dramatic improvement
Notes
This optimization applies only to PRs. Full repository scans on main branch ensure comprehensive coverage.
Related to #7375
AI generated by Plan Command for discussion #7356
Reactions are currently unavailable