Skip to content

Optimize CI linting with incremental scanning on PRs#7560

Merged
pelikhan merged 2 commits intomainfrom
copilot/optimize-ci-linting
Dec 24, 2025
Merged

Optimize CI linting with incremental scanning on PRs#7560
pelikhan merged 2 commits intomainfrom
copilot/optimize-ci-linting

Conversation

Copy link
Contributor

Copilot AI commented Dec 24, 2025

CI currently lints the entire repository (~3-4 minutes). For PRs, only changed files need linting.

Changes

  • CI workflow: Conditional linting based on event type

    • PRs: golangci-lint run --new-from-rev=origin/${{ github.base_ref }}
    • Main branch: Full repository scan (unchanged)
  • Makefile: New golint-incremental target

    • Requires BASE_REF parameter with validation
    • Usable locally: make golint-incremental BASE_REF=origin/main
    • Original golint target unchanged

Expected Impact

  • Small PRs: ~30-60s (down from ~3-4min)
  • Large PRs: Proportional improvement
  • Main branch: No change

All changed files are still linted. No coverage gaps introduced.

Original prompt

This section details on the original issue you should resolve

<issue_title>[plan] Optimize CI performance with incremental linting</issue_title>
<issue_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

  1. Update CI workflow to use --new-from-rev for pull requests
  2. Keep full repository scan for main branch merges
  3. Test performance improvement
  4. Document the optimization in Makefile comments

Files to Modify

  • .github/workflows/ci.yml - Update golangci-lint step (lines 418-419)
  • Makefile - Consider adding a golint-incremental target

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
    fi

Alternative: 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; \
	fi

Acceptance 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

  1. Create a test PR with small changes
  2. Monitor CI execution time
  3. Compare with previous full scan times
  4. 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

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement incremental linting in CI for performance Optimize CI linting with incremental scanning on PRs Dec 24, 2025
Copilot AI requested a review from mnkiefer December 24, 2025 22:09
@pelikhan pelikhan marked this pull request as ready for review December 24, 2025 22:14
@pelikhan pelikhan merged commit e46d6ee into main Dec 24, 2025
4 checks passed
@pelikhan pelikhan deleted the copilot/optimize-ci-linting branch December 24, 2025 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[plan] Optimize CI performance with incremental linting

3 participants