-
Notifications
You must be signed in to change notification settings - Fork 3
Test harness. #21
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
Merged
Test harness. #21
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ff47712
Test harness: mock git/mirror infrastructure for destructive ops.
AuraMindNest 1ffa22c
Add pre-commit logic.
AuraMindNest 4b6d4b4
Fix CI fail.
AuraMindNest e2572cc
Rerun the coderabbitai review.
AuraMindNest 2ccf92f
Fix due to the coderabbitai review.
AuraMindNest 1bfb25d
Fix due to the first reviewer.
AuraMindNest 59556f0
Fix due to the second coderabbitai review.
AuraMindNest 3b1aca0
Fix CI fail.
AuraMindNest 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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| exec "$(git rev-parse --show-toplevel)/scripts/pre-commit.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 |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| # shellcheck shell=bash | ||
| # start-translation orchestration helpers. | ||
| # Source after env.sh and lib.sh. Requires globals: | ||
| # MODULE_ORG, MASTER_BRANCH, BOOST_ORG, BOOST_WORK, ORG_WORK, libs_ref, | ||
| # lang_codes_arr, add_or_update (associative), ORG_REPO_MISSING, META_MISSING, | ||
| # NO_DOC_PATHS, GITHUB_WORKSPACE. | ||
| # shellcheck disable=SC2034,SC2154 | ||
|
|
||
| # Wipe dest_repo (except .git), copy pruned source, commit, push master only. | ||
| sync_repo_master() { | ||
| local dest_repo="$1" sub_clone="$2" libs_ref="$3" | ||
| find "$dest_repo" -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} + || return 2 | ||
| cp -r "$sub_clone/." "$dest_repo/" || return 2 | ||
| set_git_bot_config "$dest_repo" | ||
| git -C "$dest_repo" add -A || return 2 | ||
| if ! git -C "$dest_repo" diff --cached --quiet; then | ||
| git -C "$dest_repo" commit -m "Update the original documentation of $libs_ref" || return 2 | ||
| fi | ||
| git -C "$dest_repo" push origin "$MASTER_BRANCH" || return 2 | ||
| } | ||
|
|
||
| # Merge master into local-{lang_code} and push. | ||
| update_local_merge_from_master() { | ||
| local repo_dir="$1" lang_code="$2" | ||
| local local_br="local-${lang_code}" | ||
| git -C "$repo_dir" fetch origin "$MASTER_BRANCH" || return 2 | ||
| git -C "$repo_dir" fetch origin "$local_br" || return 2 | ||
| git -C "$repo_dir" checkout -B "$local_br" "origin/$local_br" || return 2 | ||
| git -C "$repo_dir" merge "origin/$MASTER_BRANCH" || return 2 | ||
| git -C "$repo_dir" push origin "${local_br}:${local_br}" || return 2 | ||
| } | ||
|
|
||
| # Create local-{lang_code} in a library mirror repo from master, with create-tag.yml. | ||
| ensure_local_branch_in_repo() { | ||
| local dest_repo="$1" sub_name="$2" lang_code="$3" | ||
| local local_br="local-${lang_code}" | ||
| if git -C "$dest_repo" ls-remote --exit-code --heads origin "$local_br" &>/dev/null; then | ||
| echo " Branch $local_br already exists in $sub_name." >&2 | ||
| return 0 | ||
| fi | ||
| echo " Creating branch $local_br in $sub_name from $MASTER_BRANCH..." >&2 | ||
| git -C "$dest_repo" fetch origin "$MASTER_BRANCH" || return 2 | ||
| git -C "$dest_repo" checkout -B "$local_br" "origin/$MASTER_BRANCH" || return 2 | ||
| add_create_tag_workflow "$dest_repo" || return 2 | ||
| git -C "$dest_repo" push -u origin "$local_br" || return 2 | ||
| echo " Created branch $local_br." >&2 | ||
| } | ||
|
|
||
| # Handle local-{lang_code} branch in a library mirror repo after master is synced. | ||
| # Returns 0 if submodule should be added to add_or_update[lang_code]; 1 if skipped (open PR); 2 on git failure. | ||
| process_local_branch() { | ||
| local dest_repo="$1" sub_name="$2" lang_code="$3" | ||
| local local_br="local-${lang_code}" | ||
| if git -C "$dest_repo" ls-remote --exit-code --heads origin "$local_br" &>/dev/null; then | ||
| has_open_translation_pr "$MODULE_ORG" "$sub_name" "$lang_code" | ||
| case $? in | ||
| 0) echo " Open translation PR found for $sub_name ($local_br), skipping." >&2; return 1 ;; | ||
| 2) return 2 ;; | ||
| esac | ||
| update_local_merge_from_master "$dest_repo" "$lang_code" || return 2 | ||
| else | ||
| ensure_local_branch_in_repo "$dest_repo" "$sub_name" "$lang_code" || return 2 | ||
| fi | ||
| return 0 | ||
| } | ||
|
|
||
| process_one_submodule() { | ||
| local sub_name="$1" doc_paths | ||
|
|
||
| if ! repo_exists "$MODULE_ORG" "$sub_name"; then | ||
| ORG_REPO_MISSING+=("$sub_name") | ||
| echo " Error: $MODULE_ORG/$sub_name does not exist. Run add-submodules first." >&2 | ||
| return 2 | ||
| fi | ||
|
|
||
| doc_paths=$(get_doc_paths "$sub_name" "$libs_ref") || { | ||
| META_MISSING+=("$sub_name") | ||
| echo " No libraries.json." >&2; return 2 | ||
| } | ||
| [[ -z "$doc_paths" ]] && { | ||
| NO_DOC_PATHS+=("$sub_name") | ||
| echo " No doc paths in metadata, skipping." >&2; return 1 | ||
| } | ||
|
|
||
| local sub_clone="$BOOST_WORK/$sub_name" | ||
| clone_repo "https://github.com/${BOOST_ORG}/${sub_name}.git" \ | ||
| "$libs_ref" "$sub_clone" || { echo " Clone failed." >&2; return 2; } | ||
|
|
||
| local -a paths_arr | ||
| mapfile -t paths_arr <<< "$doc_paths" | ||
| prune_to_doc_only "$sub_clone" "${paths_arr[@]}" | ||
|
|
||
| local org_repo_url="https://github.com/${MODULE_ORG}/${sub_name}.git" | ||
| local dest_repo="$ORG_WORK/$sub_name" | ||
| clone_repo "$org_repo_url" "$MASTER_BRANCH" "$dest_repo" keep || { | ||
| echo " clone_repo failed." >&2; return 2 | ||
| } | ||
|
|
||
| sync_repo_master "$dest_repo" "$sub_clone" "$libs_ref" || return 2 | ||
|
|
||
| local any_added=0 rc | ||
| for lang_code in "${lang_codes_arr[@]}"; do | ||
| if process_local_branch "$dest_repo" "$sub_name" "$lang_code"; then | ||
| if [[ -n "${add_or_update[$lang_code]:-}" ]]; then | ||
| add_or_update["$lang_code"]+=" $sub_name" | ||
| else | ||
| add_or_update["$lang_code"]="$sub_name" | ||
| fi | ||
| any_added=1 | ||
| else | ||
| rc=$? | ||
| [[ $rc -eq 2 ]] && return 2 | ||
| fi | ||
| done | ||
| [[ $any_added -eq 1 ]] | ||
| } |
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
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 |
|---|---|---|
|
|
@@ -8,4 +8,7 @@ | |
| data/ | ||
|
|
||
| # Local test scripts | ||
| test/ | ||
| test/ | ||
|
|
||
| # Tool caches (actionlint binary downloaded by scripts/lint.sh) | ||
| .cache/ | ||
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 |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| .PHONY: lint test check | ||
| lint: | ||
| scripts/lint.sh | ||
|
|
||
| test: | ||
| scripts/test.sh | ||
|
|
||
| check: lint test |
Oops, something went wrong.
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.