mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-29 18:27:31 +02:00
fix(wifi_remote): Fix checking API compat against reference dir
rather than git history, as it might now work in GitHub CI (due to shallow cloning)
This commit is contained in:
3
.github/workflows/wifi_remote__build.yml
vendored
3
.github/workflows/wifi_remote__build.yml
vendored
@ -24,8 +24,9 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
. ${IDF_PATH}/export.sh
|
. ${IDF_PATH}/export.sh
|
||||||
pip install idf-component-manager idf-build-apps --upgrade
|
pip install idf-component-manager idf-build-apps --upgrade
|
||||||
|
cp -r ./components/esp_wifi_remote ./components/esp_wifi_remote_base
|
||||||
cd ./components/esp_wifi_remote/scripts
|
cd ./components/esp_wifi_remote/scripts
|
||||||
python generate_and_check.py
|
python generate_and_check.py --base-dir ../../esp_wifi_remote_base
|
||||||
|
|
||||||
build_wifi_remote:
|
build_wifi_remote:
|
||||||
if: contains(github.event.pull_request.labels.*.name, 'wifi_remote') || github.event_name == 'push'
|
if: contains(github.event.pull_request.labels.*.name, 'wifi_remote') || github.event_name == 'push'
|
||||||
|
@ -332,6 +332,25 @@ def generate_kconfig(idf_path, component_path):
|
|||||||
return [remote_kconfig]
|
return [remote_kconfig]
|
||||||
|
|
||||||
|
|
||||||
|
def compare_files(base_dir, component_path, files_to_check):
|
||||||
|
failures = []
|
||||||
|
for file_path in files_to_check:
|
||||||
|
relative_path = os.path.relpath(file_path, component_path)
|
||||||
|
base_file = os.path.join(base_dir, relative_path)
|
||||||
|
|
||||||
|
if not os.path.exists(base_file):
|
||||||
|
failures.append((relative_path, 'File does not exist in base directory'))
|
||||||
|
continue
|
||||||
|
|
||||||
|
diff_cmd = ['diff', '-I', 'Copyright', file_path, base_file]
|
||||||
|
result = subprocess.run(diff_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
|
if result.returncode != 0: # diff returns 0 if files are identical
|
||||||
|
failures.append((relative_path, result.stdout.decode('utf-8')))
|
||||||
|
|
||||||
|
return failures
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='Build all projects',
|
description='Build all projects',
|
||||||
@ -346,6 +365,7 @@ Please be aware that the pregenerated files use the same copyright header, so af
|
|||||||
making changes you might need to modify 'copyright_header.h' in the script directory.
|
making changes you might need to modify 'copyright_header.h' in the script directory.
|
||||||
''')
|
''')
|
||||||
parser.add_argument('-s', '--skip-check', help='Skip checking the versioned files against the re-generated', action='store_true')
|
parser.add_argument('-s', '--skip-check', help='Skip checking the versioned files against the re-generated', action='store_true')
|
||||||
|
parser.add_argument('--base-dir', help='Base directory to compare generated files against', required=True)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
component_path = os.path.normpath(os.path.join(os.path.realpath(__file__),'..', '..'))
|
component_path = os.path.normpath(os.path.join(os.path.realpath(__file__),'..', '..'))
|
||||||
@ -371,21 +391,17 @@ making changes you might need to modify 'copyright_header.h' in the script direc
|
|||||||
|
|
||||||
files_to_check += generate_kconfig(idf_path, component_path)
|
files_to_check += generate_kconfig(idf_path, component_path)
|
||||||
|
|
||||||
fail_test = False
|
if args.skip_check:
|
||||||
failures = []
|
exit(0)
|
||||||
for f in files_to_check:
|
|
||||||
print(f'checking {f}')
|
|
||||||
rc, out, err, cmd = exec_cmd(['git', 'difftool', '-y', '-x', 'diff -I Copyright', '--', f])
|
|
||||||
if out == '' or out.isspace():
|
|
||||||
print(' - ok')
|
|
||||||
else:
|
|
||||||
print(' - FAILED!')
|
|
||||||
failures.append((f, out))
|
|
||||||
fail_test = True
|
|
||||||
|
|
||||||
if fail_test:
|
failures = compare_files(args.base_dir, component_path, files_to_check)
|
||||||
|
|
||||||
|
if failures:
|
||||||
print(parser.epilog)
|
print(parser.epilog)
|
||||||
print('\nDIfferent files:\n')
|
print('\nDifferent files:\n')
|
||||||
for i in failures:
|
for file, diff in failures:
|
||||||
print(f'{i[0]}\nChanges:\n{i[1]}')
|
print(f'{file}\nChanges:\n{diff}')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
else:
|
||||||
|
print('All files are identical to the base directory.')
|
||||||
|
exit(0)
|
||||||
|
Reference in New Issue
Block a user