workflow for github actions to check translation formats
This commit is contained in:
parent
4c991db68f
commit
b0e236badd
1 changed files with 42 additions and 0 deletions
42
.github/workflows/check_translation_format.yml
vendored
Normal file
42
.github/workflows/check_translation_format.yml
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
name: Check format
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
jobs:
|
||||
check_translation:
|
||||
name: Check format
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Setup python3
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: 3.6
|
||||
- name: Run check_translation for pull_request
|
||||
run: |
|
||||
import os
|
||||
import subprocess
|
||||
import re
|
||||
errors_encounter = 0
|
||||
pattern = re.compile(r"_\(([\"']{,3})(?P<message>((?!\1).)*)\1(\s*,\s*context\s*=\s*([\"'])(?P<py_context>((?!\5).)*)\5)*(\s*,\s*(.)*?\s*(,\s*([\"'])(?P<js_context>((?!\11).)*)\11)*)*\)")
|
||||
temp = re.compile(r"_\(([\"']{,3})")
|
||||
subprocess.run('git fetch origin '+os.environ['GITHUB_BASE_REF']+ ' :' +os.environ['GITHUB_BASE_REF']+ ' -q', shell=True)
|
||||
files = subprocess.check_output('git diff --name-only '+os.environ['GITHUB_BASE_REF'], shell=True)
|
||||
files = files.decode('utf-8')
|
||||
files = files.split()
|
||||
for file in files:
|
||||
with open(file, 'r') as f:
|
||||
for num, line in enumerate(f, 1):
|
||||
all_matches = temp.finditer(line)
|
||||
if all_matches:
|
||||
for match in all_matches:
|
||||
verify = pattern.search(line)
|
||||
if not verify:
|
||||
errors_encounter += 1
|
||||
print(num)
|
||||
print(line)
|
||||
if errors_encounter > 0 :
|
||||
assert 1+1 == 3
|
||||
shell: python
|
||||
Loading…
Add table
Reference in a new issue