Skip to content

Optimize `**/*.EXT` to use `end_with?('.EXT')` over slow `fnmatch?`

Peter Leitzen requested to merge ci-rule-exists-extension-optimization into master

What does this MR do and why?

This MR implements an optimization for CI's rules.exists clause **/*.EXT.

Given this example:

eslint-sast:
  extends: .sast-analyzer
  rules:
    - if: $CI_COMMIT_BRANCH
      exists:
        - '**/*.html'
        - '**/*.js'

For large repositories (> 10k files) this clause would always match if the amount of (slow) comparisons (via fnmatch?) would exceed 10k.

Instead of increasing MAX_PATTERN_COMPARISON (#227632) we can use the much faster (24x) end_with? operation.

To protect GitLab.com this optimization is behind a feature flag. See gitlab-com/gl-infra/production#17531 (closed).

Draft?

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

TBD.

Edited by Peter Leitzen

Merge request reports