mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-05-01 01:16:43 +02:00
Note for PR creators added (#2279)
This commit is contained in:
parent
df1c5476d9
commit
0f6d5e5a41
27
.github/scripts/check_language_properties.py
vendored
27
.github/scripts/check_language_properties.py
vendored
@ -11,6 +11,7 @@ adjusting the format.
|
|||||||
Usage:
|
Usage:
|
||||||
python script_name.py --reference-file <path_to_reference_file> --branch <branch_name> [--files <list_of_changed_files>]
|
python script_name.py --reference-file <path_to_reference_file> --branch <branch_name> [--files <list_of_changed_files>]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
@ -126,7 +127,7 @@ def read_properties(file_path):
|
|||||||
return file.read().splitlines()
|
return file.read().splitlines()
|
||||||
|
|
||||||
|
|
||||||
def check_for_differences(reference_file, file_list, branch):
|
def check_for_differences(reference_file, file_list, branch, actor):
|
||||||
reference_branch = reference_file.split("/")[0]
|
reference_branch = reference_file.split("/")[0]
|
||||||
basename_reference_file = os.path.basename(reference_file)
|
basename_reference_file = os.path.basename(reference_file)
|
||||||
|
|
||||||
@ -165,7 +166,6 @@ def check_for_differences(reference_file, file_list, branch):
|
|||||||
report.append(
|
report.append(
|
||||||
f" - **Issue:** Too many lines! Check your translation files! Details: {reference_line_count} (reference) vs {current_line_count} (current)."
|
f" - **Issue:** Too many lines! Check your translation files! Details: {reference_line_count} (reference) vs {current_line_count} (current)."
|
||||||
)
|
)
|
||||||
# update_missing_keys(reference_file, [file_path], branch + "/")
|
|
||||||
else:
|
else:
|
||||||
report.append("- **Test 1 Status:** ✅ Passed")
|
report.append("- **Test 1 Status:** ✅ Passed")
|
||||||
|
|
||||||
@ -201,23 +201,23 @@ def check_for_differences(reference_file, file_list, branch):
|
|||||||
report.append(
|
report.append(
|
||||||
f" - **Issue:** There are keys in ***{basename_reference_file}*** `{extra_keys_str}` that are not present in ***{basename_current_file}***!"
|
f" - **Issue:** There are keys in ***{basename_reference_file}*** `{extra_keys_str}` that are not present in ***{basename_current_file}***!"
|
||||||
)
|
)
|
||||||
# update_missing_keys(reference_file, [file_path], branch + "/")
|
|
||||||
else:
|
else:
|
||||||
report.append("- **Test 2 Status:** ✅ Passed")
|
report.append("- **Test 2 Status:** ✅ Passed")
|
||||||
# if has_differences:
|
|
||||||
# report.append("")
|
|
||||||
# report.append(f"#### 🚧 ***{basename_current_file}*** will be corrected...")
|
|
||||||
report.append("")
|
report.append("")
|
||||||
report.append("---")
|
report.append("---")
|
||||||
report.append("")
|
report.append("")
|
||||||
# update_file_list = glob.glob(branch + "/src/**/messages_*.properties", recursive=True)
|
|
||||||
# update_missing_keys(reference_file, update_file_list)
|
|
||||||
# report.append("---")
|
|
||||||
# report.append("")
|
|
||||||
if has_differences:
|
if has_differences:
|
||||||
report.append("## ❌ Overall Check Status: **_Failed_**")
|
report.append("## ❌ Overall Check Status: **_Failed_**")
|
||||||
|
report.append("")
|
||||||
|
report.append(
|
||||||
|
f"@{actor} please check your translation if it conforms to the standard. Follow the format of [messages_en_GB.properties](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/src/main/resources/messages_en_GB.properties)"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
report.append("## ✅ Overall Check Status: **_Success_**")
|
report.append("## ✅ Overall Check Status: **_Success_**")
|
||||||
|
report.append("")
|
||||||
|
report.append(
|
||||||
|
f"Thanks @{actor} for your help in keeping the translations up to date."
|
||||||
|
)
|
||||||
|
|
||||||
if not only_reference_file:
|
if not only_reference_file:
|
||||||
print("\n".join(report))
|
print("\n".join(report))
|
||||||
@ -225,6 +225,11 @@ def check_for_differences(reference_file, file_list, branch):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser(description="Find missing keys")
|
parser = argparse.ArgumentParser(description="Find missing keys")
|
||||||
|
parser.add_argument(
|
||||||
|
"--actor",
|
||||||
|
required=False,
|
||||||
|
help="Actor from PR.",
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--reference-file",
|
"--reference-file",
|
||||||
required=True,
|
required=True,
|
||||||
@ -251,4 +256,4 @@ if __name__ == "__main__":
|
|||||||
)
|
)
|
||||||
update_missing_keys(args.reference_file, file_list)
|
update_missing_keys(args.reference_file, file_list)
|
||||||
else:
|
else:
|
||||||
check_for_differences(args.reference_file, file_list, args.branch)
|
check_for_differences(args.reference_file, file_list, args.branch, args.actor)
|
||||||
|
4
.github/workflows/check_properties.yml
vendored
4
.github/workflows/check_properties.yml
vendored
@ -87,6 +87,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "Running Python script to check files..."
|
echo "Running Python script to check files..."
|
||||||
python main-branch/.github/scripts/check_language_properties.py \
|
python main-branch/.github/scripts/check_language_properties.py \
|
||||||
|
--actor ${{ github.event.pull_request.user.login }} \
|
||||||
--reference-file "${REFERENCE_FILE}" \
|
--reference-file "${REFERENCE_FILE}" \
|
||||||
--branch "${BRANCH_PATH}" \
|
--branch "${BRANCH_PATH}" \
|
||||||
--files ${CHANGED_FILES} > failure.txt || true
|
--files ${CHANGED_FILES} > failure.txt || true
|
||||||
@ -200,7 +201,7 @@ jobs:
|
|||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
id: cpr
|
id: cpr
|
||||||
if: env.CHANGES_DETECTED == 'true'
|
if: env.CHANGES_DETECTED == 'true'
|
||||||
uses: peter-evans/create-pull-request@v6
|
uses: peter-evans/create-pull-request@v7
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
commit-message: "Update translation files"
|
commit-message: "Update translation files"
|
||||||
@ -216,3 +217,4 @@ jobs:
|
|||||||
labels: Translation
|
labels: Translation
|
||||||
draft: false
|
draft: false
|
||||||
delete-branch: true
|
delete-branch: true
|
||||||
|
sign-commits: true
|
||||||
|
Loading…
Reference in New Issue
Block a user