ci: remove unused rules

This commit is contained in:
Fu Hanxi 2022-10-09 13:10:59 +08:00
parent d35bb630ab
commit 27e199605a
7 changed files with 13 additions and 1924 deletions

View File

@ -97,4 +97,4 @@ There are a few extra dependencies while generating the dependency tree graph, p
### CLI usage
`python generate_rules.py --graph OUTPUT_PATH`
`python $IDF_PATH/tools/ci/generate_rules.py --graph OUTPUT_PATH`

File diff suppressed because it is too large Load Diff

View File

@ -93,7 +93,7 @@ repos:
- PyYAML == 5.3.1
- id: check-generated-rules
name: Check rules are generated (based on .gitlab/ci/dependencies/dependencies.yml)
entry: .gitlab/ci/dependencies/generate_rules.py
entry: tools/ci/generate_rules.py
language: python
files: '\.gitlab/ci/dependencies/.+|\.gitlab/ci/rules\.yml'
pass_filenames: false

View File

@ -76,6 +76,10 @@ class YMLConfig:
YML_CONFIG = YMLConfig(ROOT_YML_FP)
def get_needed_rules() -> Set[str]:
return deepcopy(YML_CONFIG.all_extends)
def validate_needed_rules(rules_yml: 'os.PathLike[str]') -> int:
res = 0
needed_rules = deepcopy(YML_CONFIG.all_extends)

View File

@ -15,6 +15,7 @@ tools/ci/checkout_project_ref.py
tools/ci/ci_fetch_submodule.py
tools/ci/ci_get_mr_info.py
tools/ci/configure_ci_environment.sh
tools/ci/generate_rules.py
tools/ci/deploy_docs.py
tools/ci/envsubst.py
tools/ci/*exclude*.txt

View File

@ -1,4 +1,3 @@
.gitlab/ci/dependencies/generate_rules.py
components/app_update/otatool.py
components/efuse/efuse_table_gen.py
components/efuse/test_efuse_host/efuse_tests.py
@ -71,6 +70,7 @@ tools/ci/checkout_project_ref.py
tools/ci/deploy_docs.py
tools/ci/envsubst.py
tools/ci/fix_empty_prototypes.sh
tools/ci/generate_rules.py
tools/ci/get-full-sources.sh
tools/ci/get_supported_examples.sh
tools/ci/mirror-submodule-update.sh

View File

@ -11,6 +11,8 @@ from collections import defaultdict
from itertools import product
import yaml
from check_rules_yml import get_needed_rules
from idf_ci_utils import IDF_PATH
try:
import pygraphviz as pgv
@ -22,8 +24,6 @@ try:
except ImportError: # used for type hint
pass
IDF_PATH = os.path.abspath(os.getenv('IDF_PATH', os.path.join(os.path.dirname(__file__), '..', '..', '..')))
def _list(str_or_list): # type: (Union[str, list]) -> list
if isinstance(str_or_list, str):
@ -201,6 +201,9 @@ class RulesWriter:
def new_rules_str(self): # type: () -> str
res = []
for k, v in sorted(self.rules.items()):
if '.rules:' + k not in get_needed_rules():
print(f'WARNING: unused rule: {k}, skipping...')
continue
res.append(self.RULES_TEMPLATE.format(k, self._format_rule(k, v)))
return '\n\n'.join(res)