[ English | русский | 日本語 | 中文 (简体, 中国) | English (United Kingdom) | Deutsch | Indonesia | 한국어 (대한민국) ]

작업 스크립트 디버깅

빈번한 일은 아니나, 번역 작업 스크립트를 디버깅하고 싶을 경우가 있을 것입니다. 이 섹션에서는 해당 경우에 대해 자세히 설명합니다. propose_translation_update.sh 를 주로 다룰 것입니다.

참고

디버깅을 위한 완벽한 문서가 아직은 아닙니다. 참고를 위해 작성하였습니다. 자유롭게 더 많은 주제를 추가해주세요.

환경

It is better to use the same environment (e.g., Linux distribution version) used in the translation job. To find the information, check nodeset of the propose-translation-update job definition in zuul configuration in openstack/project-config repository. As of Feb 2021, ubuntu-bionic is used.

준비

prepare-zanata-client role 을 참고하여 의존성있는 부분을 준비할 수 있습니다.

필요한 것:

  • Zanata CLI와 의존 패키지를 설치하십시요. zanata-cli 명령어가 나의 path에서 찾을 수 있는지 확인합니다.

  • ~/.config/zanata.ini 파일을 준비합니다. :ref:`Zanata CLI<zanata-cli>`에서 자세한 내용을 확인할 수 있습니다.

  • openstack-zuul-jobs/roles/prepare-zanata-client/files 에서 작업 디렉터리로 번역 스크립트를 복사합니다. 추가로, project-config/roles/copy-proposal-common-scripts/files 에 있는 common.sh` 를 동일한 작업 디렉터리에 복사할 필요가 있습니다.

CI에 특화된 코드 주석 처리

The job scripts contain codes specific to OpenStack CI. For example, there is a code to communicate with OpenStack gerrit and the account is hardcoded. It looks convenient to comment out such code blocks to debug the scripts in a local env. It should be useful unless you are debuging a CI-specific issue.

Code blocks which look better to be commented out are:

  • common_translation_update.sh

    • trap "finish" EXIT (It depends on testrepository and usually fails in local envs)

  • propose_translation_update.sh

    • setup_review and a logic to check an existing change (It is unnecessary as we do not propose a real change to gerrit. The account used is hardcoded and it always fails in local runs.)

    • send_patch (실제 변경 사항을 gerrit에 제안하지 않으므로 불필요합니다.)

    • (optional) The main logic (from case "$PROJECT" in to filter_commits) (we will debug the main logic, so perhaps we would like to run the script piece by piece.)

변경 사항은 http://paste.openstack.org/show/802260/ 과 같을 것입니다.

upper-constraints.txt 복사

The job scripts assume that upper-constraints.txt exists in the top directory of the target project repository.

$ cd $PROJECT_DIR
$ wget https://releases.openstack.org/constraints/upper/master

Note that you need to adjust the URL of the upper-constraints file when you work on a stable branch.

~/.venv 가상환경 생성

The job scripts assume that required python modules are installed in ~/.venv virtualenv. In the zuul job, this virtualenv is prepared via ensure-sphinx and ensure-babel roles in zuul/zuul-jobs. You need to do the same.

Note that doc/requirements.txt in most projects are almost samer so perhaps you can reuse this virtualenv for most projects. If it does not work, consider recreating the virtualenv.

$ python3 -m venv ~/.venv
$ . ~/.venv/bin/activate
# $PROJECT_DIR is a target project repository like horizon, ironic-ui ....
(.venv) $ cd $PROJECT_DIR
# Install sphinx related modules ensure-sphinx installs
(.venv) $ pip install -r doc/requirements.txt -c ../requirements/upper-constraints.txt
# Install modules ensure-babel installs
(.venv) $ pip install Babel lxml pbr requests -c ../requirements/upper-constraints.txt
(.venv) $ deactivate

스크립트 불러오기

# It is better to start a new shell when debugging the script
$ bash
> cd $PROJECT_REPO
# The arguments are: {{ zuul.project.short_name }} {{ zuul.branch }} {{ zuul.job }} $HORIZON_REPO
> . $WORKDIR/propose_translation_update.sh ironic-ui master propose-translation-update ../horizon
>

Simulating translation changes

If you would like to simulate translation changes, you can download translations in advance (using zanata-cli) and modify them as you want. In such case, you can modify the script as follows:

--- a/roles/prepare-zanata-client/files/common_translation_update.sh
+++ b/roles/prepare-zanata-client/files/common_translation_update.sh
@@ -734,7 +732,8 @@ function pull_from_zanata {
     # Since Zanata does not currently have an option to not download new
     # files, we download everything, and then remove new files that are not
     # translated enough.
-    zanata-cli -B -e pull
+    #zanata-cli -B -e pull
+    cp -r $DOWNLOAD_TRANSLATIONS/$project/* .

     # We skip directories starting with '.' because they never contain
     # translations for the project (in particular, '.tox'). Likewise

You can download translations as below. zanata.xml will be created once you run the propose_translation_update.sh (or you can prepare it by following Zanata CLI “Project configuration”).

$ cd $DOWNLOAD_TRANSLATIONS/$project
$ zanata-cli -B -e pull --project-config $PROJECT_DIR/zanata.xml