Skip to content

[plan] Optimize CI performance with incremental linting #7380

Description

@github-actions

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions