From 621076f329f77585356f1c48111c0fafa28b637f Mon Sep 17 00:00:00 2001 From: krzychb Date: Fri, 16 Mar 2018 07:54:58 +0100 Subject: [PATCH] Introduced a CI check if folders with localized documentation are in sync, i.e. if they contain the same list of files --- .gitlab-ci.yml | 4 +++- docs/check_lang_folder_sync.sh | 36 ++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100755 docs/check_lang_folder_sync.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ea4323ac19..f98f2b9707 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -208,7 +208,9 @@ build_docs: - docs/zh_CN/_build/html expire_in: 1 mos script: - - cd docs/en + - cd docs + - ./check_lang_folder_sync.sh + - cd en - make gh-linkcheck - make html - ../check_doc_warnings.sh diff --git a/docs/check_lang_folder_sync.sh b/docs/check_lang_folder_sync.sh new file mode 100755 index 0000000000..96de9994cb --- /dev/null +++ b/docs/check_lang_folder_sync.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# Check if folders with localized documentation are in sync +# +# 1. Traverse each folder with language version and generate a sorted list +# of all the files inside +# 2. Compare the sorted lists of files and flag differences +# +# Note: +# All differences between folders with language versions should be resolved +# before releasing documentation +# + +RESULT=0 +STARS='***************************************************' + +find en -type f | cut -d/ -f2- | sort > file_list_en +find zh_CN -type f | cut -d/ -f2- | sort > file_list_zh_CN + +# format is to display new or different filenames +DIFF_FORMAT="--unchanged-line-format= --old-line-format=[en]:%L --new-line-format=[zh_CN]:%L" + +FOLDER_DIFFERENCES=$(diff $DIFF_FORMAT file_list_en file_list_zh_CN) +if ! [ -z "$FOLDER_DIFFERENCES" ]; then + echo "$STARS" + echo "Build failed due to the following differences in 'en' and 'zh_CN' folders:" + echo "$FOLDER_DIFFERENCES" + echo "$STARS" + echo "Please synchronize contents of 'en' and 'zh_CN' folders to contain files with identical names" + RESULT=1 +fi + +# remove temporary files +rm file_list_en file_list_zh_CN + +exit $RESULT