mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-03-25 00:16:44 +01:00
Note for PR creators added (#2279)
This commit is contained in:
parent
df1c5476d9
commit
0f6d5e5a41
.github
27
.github/scripts/check_language_properties.py
vendored
27
.github/scripts/check_language_properties.py
vendored
@ -11,6 +11,7 @@ adjusting the format.
|
||||
Usage:
|
||||
python script_name.py --reference-file <path_to_reference_file> --branch <branch_name> [--files <list_of_changed_files>]
|
||||
"""
|
||||
|
||||
import copy
|
||||
import glob
|
||||
import os
|
||||
@ -126,7 +127,7 @@ def read_properties(file_path):
|
||||
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]
|
||||
basename_reference_file = os.path.basename(reference_file)
|
||||
|
||||
@ -165,7 +166,6 @@ def check_for_differences(reference_file, file_list, branch):
|
||||
report.append(
|
||||
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:
|
||||
report.append("- **Test 1 Status:** ✅ Passed")
|
||||
|
||||
@ -201,23 +201,23 @@ def check_for_differences(reference_file, file_list, branch):
|
||||
report.append(
|
||||
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:
|
||||
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("")
|
||||
# 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:
|
||||
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:
|
||||
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:
|
||||
print("\n".join(report))
|
||||
@ -225,6 +225,11 @@ def check_for_differences(reference_file, file_list, branch):
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Find missing keys")
|
||||
parser.add_argument(
|
||||
"--actor",
|
||||
required=False,
|
||||
help="Actor from PR.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--reference-file",
|
||||
required=True,
|
||||
@ -251,4 +256,4 @@ if __name__ == "__main__":
|
||||
)
|
||||
update_missing_keys(args.reference_file, file_list)
|
||||
else:
|
||||
check_for_differences(args.reference_file, file_list, args.branch)
|
||||
check_for_differences(args.reference_file, file_list, args.branch, args.actor)
|
||||
|
8
.github/workflows/check_properties.yml
vendored
8
.github/workflows/check_properties.yml
vendored
@ -56,7 +56,7 @@ jobs:
|
||||
cd ..
|
||||
echo "Setting branch path..."
|
||||
BRANCH_PATH="pr-branch"
|
||||
|
||||
|
||||
echo "BRANCH_PATH=${BRANCH_PATH}" >> $GITHUB_ENV
|
||||
echo "Processing changed files..."
|
||||
mapfile -t CHANGED_FILES < changed_files.txt
|
||||
@ -87,6 +87,7 @@ jobs:
|
||||
run: |
|
||||
echo "Running Python script to check files..."
|
||||
python main-branch/.github/scripts/check_language_properties.py \
|
||||
--actor ${{ github.event.pull_request.user.login }} \
|
||||
--reference-file "${REFERENCE_FILE}" \
|
||||
--branch "${BRANCH_PATH}" \
|
||||
--files ${CHANGED_FILES} > failure.txt || true
|
||||
@ -123,7 +124,7 @@ jobs:
|
||||
});
|
||||
|
||||
const comment = comments.data.find(c => c.body.includes("## 🚀 Translation Verification Summary"));
|
||||
|
||||
|
||||
// Only allow the action user to update comments
|
||||
const expectedActor = "github-actions[bot]";
|
||||
|
||||
@ -200,7 +201,7 @@ jobs:
|
||||
- name: Create Pull Request
|
||||
id: cpr
|
||||
if: env.CHANGES_DETECTED == 'true'
|
||||
uses: peter-evans/create-pull-request@v6
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
commit-message: "Update translation files"
|
||||
@ -216,3 +217,4 @@ jobs:
|
||||
labels: Translation
|
||||
draft: false
|
||||
delete-branch: true
|
||||
sign-commits: true
|
||||
|
Loading…
Reference in New Issue
Block a user