Skip to content

Commit

Permalink
feat: retry merging Transifex PRs by only actions rerun (#4128)
Browse files Browse the repository at this point in the history
closing and re-opening the PRs was too intrusive and doesn't always fix
the issue.

rerunning failed PRs workflows has been more reliable.
  • Loading branch information
OmarIthawi authored Feb 27, 2024
1 parent e7ffe5f commit 200fc2b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 38 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ sync_translations: ## Syncs from the old projects to the new openedx-translatio
sync_translations_github_workflow: ## Run with parameters from .github/workflows/sync-translations.yml
make SYNC_ARGS="--simulate-github-workflow $(SYNC_ARGS)" sync_translations

MAX_PULL_REQUESTS_TO_RESTART := 1000
rerun_tests_for_transifex_bot_pull_requests: ## Re-trigger GitHub Actions all the transifex bot pull requests
bash scripts/rerun_tests_for_transifex_bot_pull_requests.sh
export MAX_PULL_REQUESTS_TO_RESTART := 1000
retry_merge_transifex_bot_pull_requests: ## Fix Transifex bot stuck and unmerged pull requests.
bash scripts/retry_merge_transifex_bot_pull_requests.sh
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pull requests, run the following command:

.. code-block:: bash
make rerun_tests_for_transifex_bot_pull_requests
make retry_merge_transifex_bot_pull_requests
Translations sync from old Transifex projects
Expand Down
34 changes: 0 additions & 34 deletions scripts/rerun_tests_for_transifex_bot_pull_requests.sh

This file was deleted.

38 changes: 38 additions & 0 deletions scripts/retry_merge_transifex_bot_pull_requests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# Retry auto-merging the stuck 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_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}" \
--search "is:open Updates for file translations/ Transifex Event" \
--json=number,headRefName,headRefOid --jq='.[].headRefOid'
}


retry_commit_workflow() {
# Re-run the tests for all workflow runs in a given commit
# Using the `--event=pull_request` option because we're intested only in Auto-merge related workflow runs
echo "========================================"
echo "Re-running tests for failed pull request commit: https://github.com/openedx/openedx-translations/commit/$1";
gh run list --commit="$1" --event=pull_request --json=databaseId --jq='.[].databaseId' | xargs -I{} gh run rerun {}
}


for pull_request_number in $(list_transifex_commits_with_failed_checks); do
retry_commit_workflow $pull_request_number;
done

0 comments on commit 200fc2b

Please sign in to comment.