-
Notifications
You must be signed in to change notification settings - Fork 12
fix: BOMS-235 Create script to set up remotes for devstack #184
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
Merged
Akanshu-2u
merged 9 commits into
master
from
BOMS-235-create-script-to-set-up-remotes-for-devstack
Oct 17, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3656bc6
fix: BOMS-235 Create script to set up remotes for devstack
Akanshu-2u e6d904c
fix: corrected the github urls for repos
Akanshu-2u abe0374
Merge remote-tracking branch 'origin/master' into BOMS-235-create-scr…
Akanshu-2u c9adf61
fix: added variables to top and removed dupliation of code
Akanshu-2u 4f28bff
fix: removed unwanted comments
Akanshu-2u 24e3337
fix: fixed repo.sh using shellcheck and added test in CI check
Akanshu-2u 8567fa8
fix: removed test_repo as its already in tests
Akanshu-2u 5935957
fix: modified test file according to CI configurations
Akanshu-2u ddb34da
fix: made test file executable in git
Akanshu-2u File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,3 +70,6 @@ jobs: | |
|
|
||
| - name: CLI tests | ||
| run: pytest -s ./tests/*.py | ||
|
|
||
| - name: Repo setup-remotes tests | ||
| run: ./tests/test_repo.sh | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,15 +26,14 @@ repos=( | |
| "https://github.com/openedx/cs_comments_service.git" | ||
| "https://github.com/edx/ecommerce.git" | ||
| "https://github.com/openedx/edx-notes-api.git" | ||
| "https://github.com/openedx/edx-platform.git" | ||
| "https://github.com/edx/edx-platform.git" | ||
| "https://github.com/openedx/xqueue.git" | ||
| "https://github.com/edx/edx-analytics-dashboard.git" | ||
Akanshu-2u marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "https://github.com/openedx/frontend-app-gradebook.git" | ||
| "https://github.com/openedx/frontend-app-learner-dashboard.git" | ||
| "https://github.com/openedx/frontend-app-learner-record.git" | ||
| "https://github.com/edx/frontend-app-gradebook.git" | ||
| "https://github.com/edx/frontend-app-learner-dashboard.git" | ||
| "https://github.com/edx/frontend-app-learner-record.git" | ||
| "https://github.com/edx/frontend-app-payment.git" | ||
| "https://github.com/openedx/frontend-app-publisher.git" | ||
| "https://github.com/edx/edx-analytics-dashboard.git" | ||
| "https://github.com/edx/frontend-app-publisher.git" | ||
| "https://github.com/edx/edx-analytics-data-api.git" | ||
| "https://github.com/openedx/enterprise-catalog.git" | ||
| "https://github.com/edx/portal-designer.git" | ||
|
|
@@ -46,17 +45,29 @@ repos=( | |
| non_release_repos=( | ||
| "https://github.com/openedx/frontend-app-authn.git" | ||
| "https://github.com/openedx/frontend-app-course-authoring.git" | ||
| "https://github.com/openedx/frontend-app-learning.git" | ||
| "https://github.com/edx/frontend-app-learning.git" | ||
| "https://github.com/edx/registrar.git" | ||
| "https://github.com/edx/frontend-app-program-console.git" | ||
| "https://github.com/openedx/frontend-app-account.git" | ||
| "https://github.com/openedx/frontend-app-profile.git" | ||
| "https://github.com/openedx/frontend-app-ora-grading.git" | ||
| "https://github.com/edx/frontend-app-profile.git" | ||
| "https://github.com/edx/frontend-app-ora-grading.git" | ||
| "https://github.com/openedx/enterprise-subsidy.git" | ||
| "https://github.com/openedx/frontend-app-admin-portal.git" | ||
| "https://github.com/openedx/frontend-app-learner-portal-enterprise.git" | ||
| "https://github.com/edx/frontend-app-admin-portal.git" | ||
| "https://github.com/edx/frontend-app-learner-portal-enterprise.git" | ||
| "https://github.com/edx/frontend-app-enterprise-checkout.git" | ||
| "https://github.com/edx/edx-exams.git" | ||
| "https://github.com/edx/frontend-app-skills.git" | ||
| "https://github.com/edx/frontend-app-ora.git" | ||
| "https://github.com/edx/frontend-app-exams-dashboard.git" | ||
| "https://github.com/edx/frontend-app-learner-portal-programs.git" | ||
| "https://github.com/edx/frontend-app-communications.git" | ||
| "https://github.com/edx/frontend-app-discussions.git" | ||
| "https://github.com/edx/frontend-app-enterprise-public-catalog.git" | ||
| "https://github.com/edx/frontend-app-support-tools.git" | ||
| "https://github.com/edx/frontend-app-authoring.git" | ||
| "https://github.com/edx/frontend-app-instruct.git" | ||
| "https://github.com/edx/frontend-app-catalog.git" | ||
| "https://github.com/edx/openedx-translations.git" | ||
| ) | ||
|
|
||
| ssh_repos=( | ||
|
|
@@ -66,15 +77,14 @@ ssh_repos=( | |
| "[email protected]:edx/ecommerce.git" | ||
| "[email protected]:openedx/edx-notes-api.git" | ||
| "[email protected]:openedx/enterprise-catalog.git" | ||
| "[email protected]:openedx/edx-platform.git" | ||
| "[email protected]:edx/edx-platform.git" | ||
| "[email protected]:openedx/xqueue.git" | ||
| "[email protected]:edx/edx-analytics-dashboard.git" | ||
Akanshu-2u marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "[email protected]:openedx/frontend-app-gradebook.git" | ||
| "[email protected]:openedx/frontend-app-learner-dashboard.git" | ||
| "[email protected]:openedx/frontend-app-learner-record.git" | ||
| "[email protected]:edx/frontend-app-gradebook.git" | ||
| "[email protected]:edx/frontend-app-learner-dashboard.git" | ||
| "[email protected]:edx/frontend-app-learner-record.git" | ||
| "[email protected]:edx/frontend-app-payment.git" | ||
| "[email protected]:openedx/frontend-app-publisher.git" | ||
| "[email protected]:edx/edx-analytics-dashboard.git" | ||
| "[email protected]:edx/frontend-app-publisher.git" | ||
| "[email protected]:edx/edx-analytics-data-api.git" | ||
| "[email protected]:edx/portal-designer.git" | ||
| "[email protected]:openedx/license-manager.git" | ||
|
|
@@ -85,17 +95,29 @@ ssh_repos=( | |
| non_release_ssh_repos=( | ||
| "[email protected]:openedx/frontend-app-authn.git" | ||
| "[email protected]:openedx/frontend-app-course-authoring.git" | ||
| "[email protected]:openedx/frontend-app-learning.git" | ||
| "[email protected]:edx/frontend-app-learning.git" | ||
| "[email protected]:edx/registrar.git" | ||
| "[email protected]:edx/frontend-app-program-console.git" | ||
| "[email protected]:openedx/frontend-app-account.git" | ||
| "[email protected]:openedx/frontend-app-profile.git" | ||
| "[email protected]:openedx/frontend-app-ora-grading.git" | ||
| "[email protected]:edx/frontend-app-profile.git" | ||
| "[email protected]:edx/frontend-app-ora-grading.git" | ||
| "[email protected]:openedx/enterprise-subsidy.git" | ||
| "[email protected]:openedx/frontend-app-admin-portal.git" | ||
| "[email protected]:openedx/frontend-app-learner-portal-enterprise.git" | ||
| "[email protected]:edx/frontend-app-admin-portal.git" | ||
| "[email protected]:edx/frontend-app-learner-portal-enterprise.git" | ||
| "[email protected]:edx/frontend-app-enterprise-checkout.git" | ||
| "[email protected]:edx/edx-exams.git" | ||
| "[email protected]:edx/frontend-app-skills.git" | ||
| "[email protected]:edx/frontend-app-ora.git" | ||
| "[email protected]:edx/frontend-app-exams-dashboard.git" | ||
| "[email protected]:edx/frontend-app-learner-portal-programs.git" | ||
| "[email protected]:edx/frontend-app-communications.git" | ||
| "[email protected]:edx/frontend-app-discussions.git" | ||
| "[email protected]:edx/frontend-app-enterprise-public-catalog.git" | ||
| "[email protected]:edx/frontend-app-support-tools.git" | ||
| "[email protected]:edx/frontend-app-authoring.git" | ||
| "[email protected]:edx/frontend-app-instruct.git" | ||
| "[email protected]:edx/frontend-app-catalog.git" | ||
| "[email protected]:edx/openedx-translations.git" | ||
| ) | ||
|
|
||
| if [ -n "${OPENEDX_RELEASE}" ]; then | ||
|
|
@@ -287,6 +309,244 @@ status () | |
| cd - &> /dev/null | ||
| } | ||
|
|
||
| # Define repositories that exist in both edx and openedx organizations | ||
| # These are the ones that need remote setup for forked repositories | ||
| FORKED_REPOS=( | ||
| "course-discovery" | ||
| "credentials" | ||
| "cs_comments_service" | ||
| "ecommerce" | ||
| "edx-notes-api" | ||
| "edx-platform" | ||
| "xqueue" | ||
| "edx-analytics-dashboard" | ||
| "frontend-app-gradebook" | ||
| "frontend-app-learner-dashboard" | ||
| "frontend-app-learner-record" | ||
| "frontend-app-skills" | ||
| "frontend-app-learning" | ||
| "frontend-app-ora" | ||
| "frontend-app-ora-grading" | ||
| "frontend-app-exams-dashboard" | ||
| "frontend-app-learner-portal-programs" | ||
| "frontend-app-program-console" | ||
| "frontend-app-communications" | ||
| "frontend-app-discussions" | ||
| "frontend-app-profile" | ||
| "frontend-app-enterprise-public-catalog" | ||
| "frontend-app-publisher" | ||
| "frontend-app-support-tools" | ||
| "frontend-app-admin-portal" | ||
| "frontend-app-learner-portal-enterprise" | ||
| "frontend-app-enterprise-checkout" | ||
| "frontend-app-authoring" | ||
| "frontend-app-instruct" | ||
| "frontend-app-catalog" | ||
| "openedx-translations" | ||
| "frontend-app-payment" | ||
| "edx-analytics-data-api" | ||
| "enterprise-catalog" | ||
| "portal-designer" | ||
| "license-manager" | ||
| "codejail-service" | ||
| "enterprise-access" | ||
| "frontend-app-authn" | ||
| "frontend-app-course-authoring" | ||
| "registrar" | ||
| "frontend-app-account" | ||
| "enterprise-subsidy" | ||
| "edx-exams" | ||
| ) | ||
Akanshu-2u marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| setup_forked_repo_remotes () | ||
| { | ||
| local repo_name=$1 | ||
| local edx_remote_exists | ||
| local openedx_remote_exists | ||
| local origin_exists | ||
| local existing_url="" | ||
| local existing_org="" | ||
| local other_org | ||
| local other_remote_exists | ||
| local other_url | ||
|
|
||
| # Check if we're in a git repository | ||
| if [ ! -d ".git" ]; then | ||
| echo "ERROR: $repo_name is not a git repository" | ||
| return 1 | ||
| fi | ||
|
|
||
| # Check if both remotes already exist (idempotency check) | ||
ttak-apphelix marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| edx_remote_exists=$(git remote | grep "^edx$" || true) | ||
| openedx_remote_exists=$(git remote | grep "^openedx$" || true) | ||
| origin_exists=$(git remote | grep "^origin$" || true) | ||
|
|
||
| if [ -n "$edx_remote_exists" ] && [ -n "$openedx_remote_exists" ] && [ -z "$origin_exists" ]; then | ||
| echo "Both edx and openedx remotes already exist in $repo_name. No changes needed." | ||
| return 0 | ||
| fi | ||
|
|
||
| echo "Setting up remotes for forked repository: $repo_name" | ||
|
|
||
| # First, try to find an existing remote and its URL | ||
| if [ -n "$origin_exists" ]; then | ||
| # We have an 'origin' remote - determine its organization | ||
| existing_url=$(git remote get-url origin 2>/dev/null || true) | ||
|
|
||
| if [[ $existing_url =~ github\.com[:/]edx/ ]]; then | ||
| existing_org="edx" | ||
| elif [[ $existing_url =~ github\.com[:/]openedx/ ]]; then | ||
| existing_org="openedx" | ||
| else | ||
| echo "ERROR: Unexpected origin URL in $repo_name: $existing_url" | ||
| echo "Expected URL to be from either edx or openedx organization" | ||
| return 1 | ||
| fi | ||
|
|
||
| # Rename origin to the correct organization name if not already done | ||
| if ! git remote | grep -q "^${existing_org}$"; then | ||
| echo "Renaming origin to '$existing_org' in $repo_name" | ||
| if ! git remote rename origin "$existing_org"; then | ||
| echo "ERROR: Failed to rename origin to $existing_org in $repo_name" | ||
| return 1 | ||
| fi | ||
| else | ||
| echo "Remote '$existing_org' already exists, removing origin" | ||
| git remote remove origin 2>/dev/null || true | ||
| fi | ||
Akanshu-2u marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| elif [ -n "$edx_remote_exists" ]; then | ||
| # No origin, but we have an 'edx' remote - use it as reference | ||
| existing_url=$(git remote get-url edx) | ||
| existing_org="edx" | ||
| elif [ -n "$openedx_remote_exists" ]; then | ||
| # No origin or edx, but we have an 'openedx' remote - use it as reference | ||
| existing_url=$(git remote get-url openedx) | ||
| existing_org="openedx" | ||
| else | ||
| echo "ERROR: No remotes found in $repo_name" | ||
| return 1 | ||
| fi | ||
|
|
||
| # Determine the other organization and add its remote if missing | ||
| if [ "$existing_org" = "edx" ]; then | ||
| other_org="openedx" | ||
| else | ||
| other_org="edx" | ||
| fi | ||
|
|
||
| # Check if the other remote exists | ||
| other_remote_exists=$(git remote | grep "^${other_org}$" || true) | ||
|
|
||
| if [ -z "$other_remote_exists" ]; then | ||
| # Construct the URL for the other organization | ||
| if [[ $existing_url =~ ^git@ ]]; then | ||
| # SSH URL format | ||
| other_url="[email protected]:${other_org}/${repo_name}.git" | ||
| else | ||
| # HTTPS URL format | ||
| other_url="https://github.com/${other_org}/${repo_name}.git" | ||
| fi | ||
|
|
||
| echo "Adding $other_org remote: $other_url" | ||
| if ! git remote add "$other_org" "$other_url"; then | ||
| echo "ERROR: Failed to add $other_org remote in $repo_name" | ||
| return 1 | ||
| fi | ||
| else | ||
| echo "Remote '$other_org' already exists in $repo_name" | ||
| fi | ||
|
|
||
| echo "Successfully configured remotes for $repo_name" | ||
| return 0 | ||
| } | ||
|
|
||
| setup_all_forked_repo_remotes () | ||
| { | ||
| local successful_repos=() | ||
| local failed_repos=() | ||
| local skipped_repos=() | ||
| local repo | ||
| local name | ||
| local is_forked | ||
| local forked_repo | ||
|
|
||
| echo "Setting up remotes for all forked repositories..." | ||
| echo "========================================" | ||
|
|
||
| for repo in "${repos[@]}" "${non_release_repos[@]}" | ||
| do | ||
Akanshu-2u marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Extract repo name from URL | ||
| if [[ ! $repo =~ $name_pattern ]]; then | ||
Akanshu-2u marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| echo "Cannot setup remotes for repo; URL did not match expected pattern: $repo" | ||
| continue | ||
| fi | ||
| name="${BASH_REMATCH[1]}" | ||
|
|
||
| # Check if directory exists | ||
| if [ ! -d "$name" ]; then | ||
| echo "Repository $name is not cloned. Skipping." | ||
| skipped_repos+=("$name") | ||
| continue | ||
| fi | ||
|
|
||
| # Check if this repo is configured as a forked repo | ||
| is_forked=false | ||
| for forked_repo in "${FORKED_REPOS[@]}"; do | ||
| if [[ "$forked_repo" == "$name" ]]; then | ||
| is_forked=true | ||
| break | ||
| fi | ||
| done | ||
|
|
||
Akanshu-2u marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if [[ "$is_forked" == false ]]; then | ||
| echo "Repository $name is not configured as a forked repo. Skipping." | ||
| skipped_repos+=("$name") | ||
| continue | ||
| fi | ||
|
|
||
| # Change to repo directory and setup remotes | ||
| cd "$name" | ||
| if setup_forked_repo_remotes "$name"; then | ||
| successful_repos+=("$name") | ||
| else | ||
| failed_repos+=("$name") | ||
| fi | ||
| cd "$DEVSTACK_WORKSPACE" | ||
| echo "" | ||
Akanshu-2u marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| done | ||
|
|
||
| # Print summary report | ||
| echo "========================================" | ||
| echo "Remote Setup Summary:" | ||
| echo "========================================" | ||
|
|
||
| if [ ${#successful_repos[@]} -gt 0 ]; then | ||
| echo "✓ Successfully configured remotes for ${#successful_repos[@]} repositories:" | ||
| printf " - %s\n" "${successful_repos[@]}" | ||
| echo "" | ||
| fi | ||
|
|
||
| if [ ${#failed_repos[@]} -gt 0 ]; then | ||
| echo "✗ Failed to configure remotes for ${#failed_repos[@]} repositories:" | ||
| printf " - %s\n" "${failed_repos[@]}" | ||
| echo "" | ||
| fi | ||
|
|
||
| if [ ${#skipped_repos[@]} -gt 0 ]; then | ||
| echo "◦ Skipped ${#skipped_repos[@]} repositories (not cloned or not forked):" | ||
| printf " - %s\n" "${skipped_repos[@]}" | ||
| echo "" | ||
| fi | ||
|
|
||
| echo "Total repositories processed: $((${#successful_repos[@]} + ${#failed_repos[@]} + ${#skipped_repos[@]}))" | ||
Akanshu-2u marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if [ ${#failed_repos[@]} -gt 0 ]; then | ||
| return 1 | ||
| else | ||
| return 0 | ||
| fi | ||
| } | ||
|
|
||
| if [ "$1" == "checkout" ]; then | ||
| checkout | ||
| elif [ "$1" == "clone" ]; then | ||
|
|
@@ -297,4 +557,6 @@ elif [ "$1" == "reset" ]; then | |
| reset | ||
| elif [ "$1" == "status" ]; then | ||
| status | ||
| elif [ "$1" == "setup-remotes" ]; then | ||
| setup_all_forked_repo_remotes | ||
| fi | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.