CI: enforce result for files changed in PR
This commit is contained in:
@@ -14,9 +14,15 @@ jobs:
|
||||
pip install polib PyGithub
|
||||
|
||||
- name: Check that .po files are up to date
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
if [[ "${{github.ref}}" == 'refs/heads/master' ]] ; then
|
||||
tools/check_po.py --manage-issues --github-repository "${{ github.repository }}" --github-token "${{ github.token }}"
|
||||
elif [[ "${{github.base_ref}}" != "" ]] ; then
|
||||
FILES=$(gh api repos/${{github.repository}}/pulls/${{github.event.pull_request.number}}/files | jq --raw-output '[.[].filename | select(. | startswith("locale/"))] | join(",")')
|
||||
echo "Locale files changed by pull request: ${FILES}"
|
||||
tools/check_po.py --fail-on "${FILES}"
|
||||
else
|
||||
tools/check_po.py
|
||||
fi
|
||||
|
||||
+9
-1
@@ -35,6 +35,7 @@ if __name__ == "__main__":
|
||||
parser.add_argument("--github-repository")
|
||||
parser.add_argument("--github-token")
|
||||
parser.add_argument("--manage-issues", action="store_true")
|
||||
parser.add_argument("--fail-on", default="")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -50,6 +51,8 @@ if __name__ == "__main__":
|
||||
repo = gh.get_repo(args.github_repository)
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
return_code = 0
|
||||
|
||||
client_pot = os.path.join(tmpdir, "client.pot")
|
||||
dashboard_pot = os.path.join(tmpdir, "dashboard.pot")
|
||||
|
||||
@@ -115,7 +118,11 @@ if __name__ == "__main__":
|
||||
lang_issues[po].append(repr(i.msgid))
|
||||
|
||||
if missing > 0:
|
||||
print(f"::warning file={po}::{lang} {missing} translations missing")
|
||||
level = "warning"
|
||||
if po in args.fail_on:
|
||||
level = "error"
|
||||
return_code = 1
|
||||
print(f"::{level} file={po}::{lang} {missing} translations missing")
|
||||
|
||||
if args.manage_issues:
|
||||
issues = [
|
||||
@@ -149,3 +156,4 @@ if __name__ == "__main__":
|
||||
else:
|
||||
for issue in issues:
|
||||
issue.edit(state="closed", body="All translations are up to date")
|
||||
exit(return_code)
|
||||
|
||||
Reference in New Issue
Block a user