ci: move check_tools_files_patterns to pre-commit

This commit is contained in:
Fu Hanxi 2021-10-12 10:47:28 +08:00
parent b4432d49cc
commit 0b7a0d7cbd
4 changed files with 29 additions and 35 deletions

View File

@ -193,12 +193,3 @@ check_commit_msg:
- git log -n10 --oneline
# commit start with "WIP: " need to be squashed before merge
- 'git log --pretty=%s master.. -- | grep "^WIP: " && exit 1 || exit 0'
check_tools_file_patterns:
extends: .pre_check_job_template
image: $CI_DOCKER_REGISTRY/ubuntu-test-env$BOT_DOCKER_IMAGE_TAG
variables:
PYTHON_VER: 3.7.7
script:
- python tools/ci/check_tools_files_patterns.py
allow_failure: true

View File

@ -108,6 +108,14 @@ repos:
language: python
files: \.(py|c|h|cpp|hpp|ld)$
require_serial: true
- id: check-tools-files-patterns
name: Check tools dir files patterns
entry: tools/ci/check_tools_files_patterns.py
language: python
files: '^tools/.+'
additional_dependencies:
- PyYAML == 5.3.1
pass_filenames: false
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:

View File

@ -3974,7 +3974,6 @@ tools/ci/check_public_headers.py
tools/ci/check_readme_links.py
tools/ci/check_rules_yml.py
tools/ci/check_soc_struct_headers.py
tools/ci/check_tools_files_patterns.py
tools/ci/check_type_comments.py
tools/ci/checkout_project_ref.py
tools/ci/ci_fetch_submodule.py

View File

@ -1,18 +1,7 @@
#!/usr/bin/env python
#
# Copyright 2021 Espressif Systems (Shanghai) CO LTD
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import argparse
import fnmatch
@ -35,9 +24,9 @@ def _ishidden(path): # pylint: disable=W0613
fnmatch.translate = translate
glob.magic_check = magic_check
glob.magic_check_bytes = magic_check_bytes
glob._ishidden = _ishidden # pylint: disable=W0212
glob.magic_check = magic_check # type: ignore
glob.magic_check_bytes = magic_check_bytes # type: ignore
glob._ishidden = _ishidden # type: ignore # pylint: disable=W0212
# ends here
@ -80,15 +69,22 @@ if __name__ == '__main__':
res = 0
not_included_files, dup_patterns = check(args.pattern_yml, args.exclude_list)
if not_included_files:
print('Missing Files: (please add to tools/ci/exclude_check_tools_files.txt')
for file in not_included_files:
print(file)
res = 1
if dup_patterns:
print('Duplicated Patterns: (please check .gitlab/ci/rules.yml and tools/ci/exclude_check_tools_files.txt')
for pattern in dup_patterns:
print(pattern)
if not_included_files or dup_patterns:
res = 1
print('This test is used for making sure of all the tools dir files are recorded in .gitlab/ci/rules.yml to '
'trigger the related tests, except those files should be excluded.')
if not_included_files:
print('Missing Files:')
for file in not_included_files:
print('\t' + file)
print('Please add these files or glob patterns to ".gitlab/ci/rules.yml" and put related files under '
'".patterns-<test_group>" block to trigger related tests.\n'
'Or add them to "tools/ci/exclude_check_tools_files.txt" to exclude them.')
if dup_patterns:
print('Duplicated Patterns:')
for pattern in dup_patterns:
print('\t' + pattern)
print('Please remove them from tools/ci/exclude_check_tools_files.txt')
sys.exit(res)