mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-01-25 02:08:11 +00:00
feat(ci): add ignored paths for docs and non-code files
Files matching ignored patterns (docs, markdown, configs, examples) will not trigger any tests, saving CI resources.
This commit is contained in:
37
.github/scripts/test-impact.py
vendored
37
.github/scripts/test-impact.py
vendored
@@ -51,6 +51,23 @@ def matches_pattern(file_path: str, pattern: str) -> bool:
|
|||||||
return fnmatch.fnmatch(file_path, pattern)
|
return fnmatch.fnmatch(file_path, pattern)
|
||||||
|
|
||||||
|
|
||||||
|
def filter_ignored_files(
|
||||||
|
changed_files: list[str], ignored_paths: list[str]
|
||||||
|
) -> list[str]:
|
||||||
|
"""Filter out files that match ignored patterns."""
|
||||||
|
filtered = []
|
||||||
|
for file_path in changed_files:
|
||||||
|
is_ignored = False
|
||||||
|
for pattern in ignored_paths:
|
||||||
|
if matches_pattern(file_path, pattern):
|
||||||
|
print(f" [IGNORED] {file_path} matches {pattern}", file=sys.stderr)
|
||||||
|
is_ignored = True
|
||||||
|
break
|
||||||
|
if not is_ignored:
|
||||||
|
filtered.append(file_path)
|
||||||
|
return filtered
|
||||||
|
|
||||||
|
|
||||||
def check_critical_paths(changed_files: list[str], critical_paths: list[str]) -> bool:
|
def check_critical_paths(changed_files: list[str], critical_paths: list[str]) -> bool:
|
||||||
"""Check if any changed file matches critical paths."""
|
"""Check if any changed file matches critical paths."""
|
||||||
for file_path in changed_files:
|
for file_path in changed_files:
|
||||||
@@ -159,6 +176,26 @@ def main():
|
|||||||
# Load configuration
|
# Load configuration
|
||||||
config = load_config()
|
config = load_config()
|
||||||
|
|
||||||
|
# Filter out ignored files (docs, configs, etc.)
|
||||||
|
ignored_paths = config.get("ignored", {}).get("paths", [])
|
||||||
|
changed_files = filter_ignored_files(changed_files, ignored_paths)
|
||||||
|
|
||||||
|
if not changed_files:
|
||||||
|
print("\nAll changed files are ignored (docs, configs, etc.)", file=sys.stderr)
|
||||||
|
print("No tests needed.", file=sys.stderr)
|
||||||
|
set_github_output("run-all", "false")
|
||||||
|
set_github_output("sdk-tests", "")
|
||||||
|
set_github_output("api-tests", "")
|
||||||
|
set_github_output("ui-e2e", "")
|
||||||
|
set_github_output("modules", "none-ignored")
|
||||||
|
set_github_output("has-tests", "false")
|
||||||
|
return
|
||||||
|
|
||||||
|
print(
|
||||||
|
f"\n{len(changed_files)} files remain after filtering ignored paths",
|
||||||
|
file=sys.stderr,
|
||||||
|
)
|
||||||
|
|
||||||
# Check critical paths
|
# Check critical paths
|
||||||
critical_paths = config.get("critical", {}).get("paths", [])
|
critical_paths = config.get("critical", {}).get("paths", [])
|
||||||
if check_critical_paths(changed_files, critical_paths):
|
if check_critical_paths(changed_files, critical_paths):
|
||||||
|
|||||||
34
.github/test-impact.yml
vendored
34
.github/test-impact.yml
vendored
@@ -3,6 +3,40 @@
|
|||||||
#
|
#
|
||||||
# Usage: Changes to paths in 'critical' always run all tests.
|
# Usage: Changes to paths in 'critical' always run all tests.
|
||||||
# Changes to paths in 'modules' run only the mapped tests.
|
# Changes to paths in 'modules' run only the mapped tests.
|
||||||
|
# Changes to paths in 'ignored' don't trigger any tests.
|
||||||
|
|
||||||
|
# Ignored paths - changes here don't trigger any tests
|
||||||
|
# Documentation, configs, and other non-code files
|
||||||
|
ignored:
|
||||||
|
paths:
|
||||||
|
# Documentation
|
||||||
|
- docs/**
|
||||||
|
- "*.md"
|
||||||
|
- "**/*.md"
|
||||||
|
- mkdocs.yml
|
||||||
|
|
||||||
|
# Config files that don't affect runtime
|
||||||
|
- .gitignore
|
||||||
|
- .gitattributes
|
||||||
|
- .editorconfig
|
||||||
|
- .pre-commit-config.yaml
|
||||||
|
- .backportrc.json
|
||||||
|
- CODEOWNERS
|
||||||
|
- LICENSE
|
||||||
|
|
||||||
|
# IDE/Editor configs
|
||||||
|
- .vscode/**
|
||||||
|
- .idea/**
|
||||||
|
|
||||||
|
# Examples and contrib (not production code)
|
||||||
|
- examples/**
|
||||||
|
- contrib/**
|
||||||
|
|
||||||
|
# Skills (AI agent configs, not runtime)
|
||||||
|
- skills/**
|
||||||
|
|
||||||
|
# Permissions docs
|
||||||
|
- permissions/**
|
||||||
|
|
||||||
# Critical paths - changes here run ALL tests
|
# Critical paths - changes here run ALL tests
|
||||||
# These are foundational/shared code that can affect anything
|
# These are foundational/shared code that can affect anything
|
||||||
|
|||||||
Reference in New Issue
Block a user