From aaaea0dce25d1b70b760b3fa8324e0b17dd1a4d9 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 28 Nov 2023 23:30:25 +0100 Subject: [PATCH] ci: rework the translation+doc stages, have a 'bot' stage for everything that is likely to create a PR instead --- .gitlab/ci/bot.gitlab-ci.yml | 71 ++++++++++++++++++++++++++++ .gitlab/ci/doc.gitlab-ci.yml | 31 ------------ .gitlab/ci/lint.gitlab-ci.yml | 18 +------ .gitlab/ci/translation.gitlab-ci.yml | 36 -------------- 4 files changed, 73 insertions(+), 83 deletions(-) create mode 100644 .gitlab/ci/bot.gitlab-ci.yml delete mode 100644 .gitlab/ci/doc.gitlab-ci.yml delete mode 100644 .gitlab/ci/translation.gitlab-ci.yml diff --git a/.gitlab/ci/bot.gitlab-ci.yml b/.gitlab/ci/bot.gitlab-ci.yml new file mode 100644 index 000000000..fe178eeb9 --- /dev/null +++ b/.gitlab/ci/bot.gitlab-ci.yml @@ -0,0 +1,71 @@ +generate-helpers-doc: + stage: bot + image: "before-install" + needs: [] + before_script: + - git config --global user.email "yunohost@yunohost.org" + - git config --global user.name "$GITHUB_USER" + script: + - cd doc + - python3 generate_helper_doc.py + - python3 generate_resource_doc.py > resources.md + - python3 generate_configpanel_and_formoptions_doc.py > forms.md + - hub clone https://$GITHUB_TOKEN:x-oauth-basic@github.com/YunoHost/doc.git doc_repo + - cp helpers.md doc_repo/pages/06.contribute/10.packaging_apps/80.resources/11.helpers/packaging_apps_helpers.md + - cp resources.md doc_repo/pages/06.contribute/10.packaging_apps/80.resources/15.appresources/packaging_apps_resources.md + - cp forms doc_repo/pages/06.contribute/15.dev/03.forms/forms.md + - cd doc_repo + # replace ${CI_COMMIT_REF_NAME} with ${CI_COMMIT_TAG} ? + - hub checkout -b "${CI_COMMIT_REF_NAME}" + - hub commit -am "[CI] Update app helpers/resources for ${CI_COMMIT_REF_NAME}" + - hub pull-request -m "[CI] Update app helpers/resources for ${CI_COMMIT_REF_NAME}" -p # GITHUB_USER and GITHUB_TOKEN registered here https://gitlab.com/yunohost/yunohost/-/settings/ci_cd + artifacts: + paths: + - doc/helpers.md + - doc/resources.md + only: + - tags + +black: + stage: bot + image: "before-install" + needs: [] + before_script: + - git config --global user.email "yunohost@yunohost.org" + - git config --global user.name "$GITHUB_USER" + - hub clone --branch ${CI_COMMIT_REF_NAME} "https://$GITHUB_TOKEN:x-oauth-basic@github.com/YunoHost/yunohost.git" github_repo + - cd github_repo + script: + # create a local branch that will overwrite distant one + - git checkout -b "ci-format-${CI_COMMIT_REF_NAME}" --no-track + - tox -e py311-black-run + - '[ $(git diff | wc -l) != 0 ] || exit 0' # stop if there is nothing to commit + - git commit -am "[CI] Format code with Black" || true + - git push -f origin "ci-format-${CI_COMMIT_REF_NAME}":"ci-format-${CI_COMMIT_REF_NAME}" + - hub pull-request -m "[CI] Format code with Black" -b Yunohost:dev -p || true # GITHUB_USER and GITHUB_TOKEN registered here https://gitlab.com/yunohost/yunohost/-/settings/ci_cd + only: + - tags + +autofix-translated-strings: + stage: bot + image: "before-install" + needs: [] + before_script: + - git config --global user.email "yunohost@yunohost.org" + - git config --global user.name "$GITHUB_USER" + - hub clone --branch ${CI_COMMIT_REF_NAME} "https://$GITHUB_TOKEN:x-oauth-basic@github.com/YunoHost/yunohost.git" github_repo + - cd github_repo + script: + # create a local branch that will overwrite distant one + - git checkout -b "ci-autofix-translated-strings-${CI_COMMIT_REF_NAME}" --no-track + - python3 maintenance/missing_i18n_keys.py --fix + - python3 maintenance/autofix_locale_format.py + - '[ $(git diff --ignore-blank-lines --ignore-all-space --ignore-space-at-eol --ignore-cr-at-eol | wc -l) != 0 ] || exit 0' # stop if there is nothing to commit + - git commit -am "[CI] Reformat / remove stale translated strings" || true + - git push -f origin "ci-autofix-translated-strings-${CI_COMMIT_REF_NAME}":"ci-remove-stale-translated-strings-${CI_COMMIT_REF_NAME}" + - hub pull-request -m "[CI] Reformat / remove stale translated strings" -b Yunohost:$CI_COMMIT_REF_NAME -p || true # GITHUB_USER and GITHUB_TOKEN registered here https://gitlab.com/yunohost/yunohost/-/settings/ci_cd + only: + variables: + - $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH + changes: + - locales/* diff --git a/.gitlab/ci/doc.gitlab-ci.yml b/.gitlab/ci/doc.gitlab-ci.yml deleted file mode 100644 index d76fcdee1..000000000 --- a/.gitlab/ci/doc.gitlab-ci.yml +++ /dev/null @@ -1,31 +0,0 @@ -######################################## -# DOC -######################################## - -generate-helpers-doc: - stage: doc - image: "before-install" - needs: [] - before_script: - - git config --global user.email "yunohost@yunohost.org" - - git config --global user.name "$GITHUB_USER" - script: - - cd doc - - python3 generate_helper_doc.py - - python3 generate_resource_doc.py > resources.md - - python3 generate_configpanel_and_formoptions_doc.py > forms.md - - hub clone https://$GITHUB_TOKEN:x-oauth-basic@github.com/YunoHost/doc.git doc_repo - - cp helpers.md doc_repo/pages/06.contribute/10.packaging_apps/80.resources/11.helpers/packaging_apps_helpers.md - - cp resources.md doc_repo/pages/06.contribute/10.packaging_apps/80.resources/15.appresources/packaging_apps_resources.md - - cp forms doc_repo/pages/06.contribute/15.dev/03.forms/forms.md - - cd doc_repo - # replace ${CI_COMMIT_REF_NAME} with ${CI_COMMIT_TAG} ? - - hub checkout -b "${CI_COMMIT_REF_NAME}" - - hub commit -am "[CI] Update app helpers/resources for ${CI_COMMIT_REF_NAME}" - - hub pull-request -m "[CI] Update app helpers/resources for ${CI_COMMIT_REF_NAME}" -p # GITHUB_USER and GITHUB_TOKEN registered here https://gitlab.com/yunohost/yunohost/-/settings/ci_cd - artifacts: - paths: - - doc/helpers.md - - doc/resources.md - only: - - tags diff --git a/.gitlab/ci/lint.gitlab-ci.yml b/.gitlab/ci/lint.gitlab-ci.yml index 1eeb71eab..3696567b8 100644 --- a/.gitlab/ci/lint.gitlab-ci.yml +++ b/.gitlab/ci/lint.gitlab-ci.yml @@ -25,22 +25,8 @@ mypy: script: - tox -e py311-mypy -black: +i18n-keys: stage: lint - image: "before-install" needs: [] - before_script: - - git config --global user.email "yunohost@yunohost.org" - - git config --global user.name "$GITHUB_USER" - - hub clone --branch ${CI_COMMIT_REF_NAME} "https://$GITHUB_TOKEN:x-oauth-basic@github.com/YunoHost/yunohost.git" github_repo - - cd github_repo script: - # create a local branch that will overwrite distant one - - git checkout -b "ci-format-${CI_COMMIT_REF_NAME}" --no-track - - tox -e py311-black-run - - '[ $(git diff | wc -l) != 0 ] || exit 0' # stop if there is nothing to commit - - git commit -am "[CI] Format code with Black" || true - - git push -f origin "ci-format-${CI_COMMIT_REF_NAME}":"ci-format-${CI_COMMIT_REF_NAME}" - - hub pull-request -m "[CI] Format code with Black" -b Yunohost:dev -p || true # GITHUB_USER and GITHUB_TOKEN registered here https://gitlab.com/yunohost/yunohost/-/settings/ci_cd - only: - - tags + - python3 maintenance/missing_i18n_keys.py --check diff --git a/.gitlab/ci/translation.gitlab-ci.yml b/.gitlab/ci/translation.gitlab-ci.yml deleted file mode 100644 index 387860e40..000000000 --- a/.gitlab/ci/translation.gitlab-ci.yml +++ /dev/null @@ -1,36 +0,0 @@ -######################################## -# TRANSLATION -######################################## -test-i18n-keys: - stage: translation - script: - - python3 maintenance/missing_i18n_keys.py --check - only: - changes: - - locales/en.json - - src/*.py - - src/diagnosers/*.py - -autofix-translated-strings: - stage: translation - image: "before-install" - needs: [] - before_script: - - git config --global user.email "yunohost@yunohost.org" - - git config --global user.name "$GITHUB_USER" - - hub clone --branch ${CI_COMMIT_REF_NAME} "https://$GITHUB_TOKEN:x-oauth-basic@github.com/YunoHost/yunohost.git" github_repo - - cd github_repo - script: - # create a local branch that will overwrite distant one - - git checkout -b "ci-autofix-translated-strings-${CI_COMMIT_REF_NAME}" --no-track - - python3 maintenance/missing_i18n_keys.py --fix - - python3 maintenance/autofix_locale_format.py - - '[ $(git diff --ignore-blank-lines --ignore-all-space --ignore-space-at-eol --ignore-cr-at-eol | wc -l) != 0 ] || exit 0' # stop if there is nothing to commit - - git commit -am "[CI] Reformat / remove stale translated strings" || true - - git push -f origin "ci-autofix-translated-strings-${CI_COMMIT_REF_NAME}":"ci-remove-stale-translated-strings-${CI_COMMIT_REF_NAME}" - - hub pull-request -m "[CI] Reformat / remove stale translated strings" -b Yunohost:$CI_COMMIT_REF_NAME -p || true # GITHUB_USER and GITHUB_TOKEN registered here https://gitlab.com/yunohost/yunohost/-/settings/ci_cd - only: - variables: - - $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH - changes: - - locales/*