Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update for retry scripts #9542

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ retry_merge_transifex_bot_pull_requests
# Default project to work on. Override to release project e.g. `openedx-translations-redwood` when cutting a release.
export TRANSIFEX_PROJECT_SLUG := openedx-translations

# Max pull requests
export MAX_PULL_REQUESTS := 1000


piptools:
pip install -q -r requirements/pip_tools.txt

Expand Down Expand Up @@ -37,6 +41,8 @@ test: ## Run scripts tests
validate_translation_files: ## Run basic validation to ensure files are compilable
python scripts/validate_translation_files.py

export MAX_PULL_REQUESTS_TO_RESTART := 1000
retry_merge_transifex_bot_pull_requests: ## Fix Transifex bot stuck and unmerged pull requests.
retry_merge_transifex_bot_pull_requests: ## Fix Transifex bot stuck and unmerged pull requests via restarting tests.
bash scripts/retry_merge_transifex_bot_pull_requests.sh

retry_merge_valid_transifex_bot_pull_requests: ## Fix Transifex bot stuck and unmerged pull requests via `gh pr merge --auto`.
bash scripts/retry_merge_valid_transifex_bot_pull_requests.sh
7 changes: 6 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ for the Redwood release (June 2024), the branches were:
`Tutor Redwood v18`_, `edx-platform "open-release/redwood.master" branch`_
and others.

To update translations for a named release, find the corresponding named release project in the `Open edX Transifex project <https://app.transifex.com/open-edx/>`_ by searching for the release name (for example, Redwood) in the search box.
To update translations for a named release, find the corresponding named release project in the `Open edX Transifex project <https://app.transifex.com/open-edx/>`_ by searching for the release name (for example, Redwood) in the search box.

Tools for repository maintainers
********************************
Expand Down Expand Up @@ -87,6 +87,11 @@ pull requests, run the following command:

make retry_merge_transifex_bot_pull_requests

.. code-block:: bash

make retry_merge_valid_transifex_bot_pull_requests


.. _OEP-58: https://github.com/openedx/open-edx-proposals/pull/367
.. _openedx-atlas: https://github.com/openedx/openedx-atlas

Expand Down
6 changes: 3 additions & 3 deletions scripts/retry_merge_transifex_bot_pull_requests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fi
list_transifex_commits_with_failed_checks() {
# List the Transifex bot pull requests which have failed the tests
# Print their head-commit hashes
gh pr list -L"${MAX_PULL_REQUESTS_TO_RESTART:-1000}" \
gh pr list -L"${MAX_PULL_REQUESTS:-1000}" \
--search "is:open Updates for file translations/ Transifex Event" \
--json=number,headRefName,headRefOid --jq='.[].headRefOid'
}
Expand All @@ -33,6 +33,6 @@ retry_commit_workflow() {
}


for pull_request_number in $(list_transifex_commits_with_failed_checks); do
retry_commit_workflow $pull_request_number;
for pull_request_commit_sha in $(list_transifex_commits_with_failed_checks); do
retry_commit_workflow $pull_request_commit_sha;
done
38 changes: 38 additions & 0 deletions scripts/retry_merge_valid_transifex_bot_pull_requests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# Retry merging the stuck valid Transifex bot pull requests


set -e

if ! test -d .git; then
echo "Error: This script must be run from the root of the openedx-translations repo"
exit 1
fi

if ! which gh; then
echo "Error: This script requires the 'gh' command line tool."
echo " See https://cli.github.com/ for installation instructions."
exit 1
fi

list_transifex_prs_with_valid_checks() {
# List the Transifex bot pull requests which have failed the tests
# Print their head-commit hashes
gh pr list -L"${MAX_PULL_REQUESTS:-1000}" \
--search "is:open Updates for file translations/ Transifex Event 'All translation files are valid.'" \
--json=number,headRefName,headRefOid --jq='.[].number'
}


retry_merge() {
# Try to merge successful commit.
echo "========================================"
echo "Re-trying merge for valid pull request: https://github.com/openedx/openedx-translations/pull/$1";
gh pr merge --rebase --auto "$1"
}


for pull_request_number in $(list_transifex_prs_with_valid_checks); do
retry_merge $pull_request_number;
sleep 0.5;
done