Skip to content

Commit

Permalink
#2033 ci-run-test Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
Howard Soh committed Feb 11, 2022
2 parents 42aad8a + 0f25d3c commit ae13219
Show file tree
Hide file tree
Showing 47 changed files with 813 additions and 784 deletions.
2 changes: 2 additions & 0 deletions .github/dummy_for_action
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#update me to add action comment

20 changes: 17 additions & 3 deletions .github/jobs/copy_diff_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@

LOG_DIR = '/met/logs'

LINE_BREAK = '# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #'

def get_files_with_diffs(log_file):
files_to_copy = set()
error_text_list = []

with open(log_file, 'r') as file_handle:
file_content = file_handle.read()

missing_section, *test_sections = file_content.split(
'\n# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #\n'
f'\n{LINE_BREAK}\n'
)

# parse list of missing files
if 'ERROR:' in missing_section:
error_text_list.append(missing_section)
for missing_group in missing_section.split('ERROR:')[1:]:
dir_str, *rel_paths = missing_group.splitlines()
dir_str = dir_str.split()[1]
Expand All @@ -36,13 +40,14 @@ def get_files_with_diffs(log_file):

# parse file paths out of sections that have errors
error_sections = [item for item in test_sections if 'ERROR:' in item]
error_text_list.extend(error_sections)
for error_section in error_sections:
for line in error_section.splitlines():
for item in line.split():
if OUTPUT_DIR in item or TRUTH_DIR in item:
files_to_copy.add(item)

return files_to_copy
return files_to_copy, error_text_list

def copy_files_to_diff_dir(files_to_copy):

Expand All @@ -69,12 +74,21 @@ def copy_files_to_diff_dir(files_to_copy):
os.makedirs(output_dir)
shutil.copyfile(filename, output_path)


def main():
log_file = os.path.join(LOG_DIR, 'comp_dir.log')
print(f"Parsing {log_file}")
all_files_to_copy = get_files_with_diffs(log_file)
all_files_to_copy, error_text_list = get_files_with_diffs(log_file)

copy_files_to_diff_dir(all_files_to_copy)

# print error summary
if error_text_list:
print("\n\n**************\nERROR SUMMARY:\n**************\n")

print(f'\n{LINE_BREAK}\n'.join(error_text_list))

print("End of script")

if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions .github/jobs/run_diff_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ if [ $? != 0 ]; then
fi

if [ "$(ls -A ${LOCAL_DIFF_DIR})" ]; then
cat ${LOCAL_LOG_DIR}/copy_diff_files.log

echo "ERROR: Differences exist in the output"

# only exit non-zero (job fails) if not updating truth data
Expand Down
Loading

0 comments on commit ae13219

Please sign in to comment.