-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Standardize scripts #3371
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
Standardize scripts #3371
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9594252
Initial plan
Copilot d1d682f
Standardize synchronization script metadata and README updates
Copilot deb8f83
Use shared repository variable in istio README update pattern
Copilot 1b3c82c
Compact synchronization scripts and align step ordering
Copilot 4cbf9ae
Remove all internal empty lines from scripts for dense formatting
Copilot 667f5d0
Restore executable permissions on synchronization scripts
Copilot e124b41
Refine kubeflow helper naming after compact cleanup
Copilot 47c571b
Standardize create_branch usage and commit_changes calls
Copilot c6041b3
Fix template commit path and remove spark repo variable
Copilot 1ae55b9
Restore README update debug message in library function
Copilot d2c359f
Revert "Restore README update debug message in library function"
Copilot d72e900
Restore all shell scripts to master-equivalent content
Copilot 6a6016f
Revert accidental restore-to-master script overwrite
Copilot 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 |
|---|---|---|
| @@ -1,101 +1,76 @@ | ||
| #!/usr/bin/env bash | ||
| # Common functions for Kubeflow manifest synchronization scripts | ||
|
|
||
| setup_error_handling() { | ||
| set -euxo pipefail | ||
| IFS=$'\n\t' | ||
| } | ||
|
|
||
| # Check if the git repository has uncommitted changes | ||
| check_uncommitted_changes() { | ||
| if [ -n "$(git status --porcelain)" ]; then | ||
| echo "WARNING: You have uncommitted changes" | ||
| fi | ||
| } | ||
|
|
||
| # Create a new git branch if it doesn't exist | ||
| create_branch() { | ||
| local branch="$1" | ||
|
|
||
| check_uncommitted_changes | ||
|
|
||
| if [ $(git branch --list "$branch") ]; then | ||
| echo "WARNING: Branch $branch already exists." | ||
| fi | ||
|
|
||
| if ! git show-ref --verify --quiet refs/heads/$branch; then | ||
| git checkout -b "$branch" | ||
| else | ||
| echo "Branch $branch already exists." | ||
| fi | ||
| } | ||
|
|
||
| clone_and_checkout() { | ||
| local source_directory="$1" | ||
| local repository_url="$2" | ||
| local repository_directory="$3" | ||
| local commit="$4" | ||
|
|
||
| echo "Checking out in $source_directory to $commit..." | ||
|
|
||
| mkdir -p "$source_directory" | ||
| cd "$source_directory" | ||
|
|
||
| # Clone repository if it doesn't exist | ||
| if [ ! -d "$repository_directory/.git" ]; then | ||
| git clone "$repository_url" "$repository_directory" | ||
| fi | ||
|
|
||
| # Checkout to specific commit | ||
| cd "$source_directory/$repository_directory" | ||
| if ! git rev-parse --verify --quiet "$commit"; then | ||
| git checkout -b "$commit" | ||
| else | ||
| git checkout "$commit" | ||
| fi | ||
|
|
||
| check_uncommitted_changes | ||
| } | ||
|
|
||
| # Copy manifests from source to destination | ||
| copy_manifests() { | ||
| local source="$1" | ||
| local destination="$2" | ||
|
|
||
| echo "Copying manifests..." | ||
|
|
||
| if [ -d "$destination" ]; then | ||
| rm -r "$destination" | ||
| fi | ||
|
|
||
| cp "$source" "$destination" -r | ||
| echo "Successfully copied all manifests." | ||
| } | ||
|
|
||
| # Update README with new commit reference | ||
| update_readme() { | ||
| local manifests_directory="$1" | ||
| local source_text="$2" | ||
| local destination_text="$3" | ||
|
|
||
| if [[ "$OSTYPE" == "darwin"* ]]; then | ||
| sed -i "" "s|$source_text|$destination_text|g" "${manifests_directory}/README.md" # BSD sed of Mac OSX | ||
| else | ||
| sed -i "s|$source_text|$destination_text|g" "${manifests_directory}/README.md" # GNU sed of Linux | ||
| fi | ||
| } | ||
|
|
||
| # Commit changes to git repository | ||
| commit_changes() { | ||
| local manifests_directory="$1" | ||
| local commit_message="$2" | ||
| local paths_to_add=("${@:3}") | ||
|
|
||
| cd "$manifests_directory" | ||
|
|
||
| for path in "${paths_to_add[@]}"; do | ||
| git add "$path" | ||
| done | ||
|
|
||
| git commit -s -m "$commit_message" | ||
|
juliusvonkohout marked this conversation as resolved.
|
||
| } | ||
| } | ||
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 |
|---|---|---|
| @@ -1,37 +1,20 @@ | ||
| #!/usr/bin/env bash | ||
| # This script helps to create a PR to update cert-manager manifests. | ||
|
|
||
| SCRIPT_DIRECTORY=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
| source "${SCRIPT_DIRECTORY}/library.sh" | ||
|
|
||
| setup_error_handling | ||
|
|
||
| COMPONENT_NAME="cert-manager" | ||
| CERT_MANAGER_RELEASE="v1.19.4" # Must be a release tag in cert-manager/cert-manager | ||
| BRANCH_NAME=${BRANCH_NAME:=synchronize-${COMPONENT_NAME}-manifests-${CERT_MANAGER_RELEASE?}} | ||
|
|
||
| REPOSITORY_NAME="cert-manager/cert-manager" | ||
| COMMIT="v1.19.4" | ||
| BRANCH_NAME=${BRANCH_NAME:=synchronize-${COMPONENT_NAME}-manifests-${COMMIT?}} | ||
| MANIFESTS_DIRECTORY=$(dirname $SCRIPT_DIRECTORY) | ||
| DESTINATION_DIRECTORY=$MANIFESTS_DIRECTORY/common/${COMPONENT_NAME} | ||
| DESTINATION_FILE="$DESTINATION_DIRECTORY/base/upstream/cert-manager.yaml" | ||
|
|
||
| create_branch "$BRANCH_NAME" | ||
| check_uncommitted_changes | ||
|
|
||
| echo "Downloading cert-manager manifest ${CERT_MANAGER_RELEASE}..." | ||
| wget -O "$DESTINATION_FILE" \ | ||
| "https://github.com/cert-manager/cert-manager/releases/download/${CERT_MANAGER_RELEASE}/cert-manager.yaml" | ||
|
|
||
| # Update top-level component version table. | ||
| if [[ "$OSTYPE" == "darwin"* ]]; then | ||
| sed -i "" '/| Cert Manager | common\/cert-manager |/s|\[.*\](https://github.com/cert-manager/cert-manager/releases/tag/v.*)|['"${CERT_MANAGER_RELEASE#v}"'](https://github.com/cert-manager/cert-manager/releases/tag/'"${CERT_MANAGER_RELEASE}"')|' \ | ||
| "${MANIFESTS_DIRECTORY}/README.md" | ||
| else | ||
| sed -i '/| Cert Manager | common\/cert-manager |/s|\[.*\](https://github.com/cert-manager/cert-manager/releases/tag/v.*)|['"${CERT_MANAGER_RELEASE#v}"'](https://github.com/cert-manager/cert-manager/releases/tag/'"${CERT_MANAGER_RELEASE}"')|' \ | ||
| "${MANIFESTS_DIRECTORY}/README.md" | ||
| fi | ||
|
|
||
| commit_changes "$MANIFESTS_DIRECTORY" "Update common/cert-manager manifests to ${CERT_MANAGER_RELEASE}" \ | ||
| "$DESTINATION_DIRECTORY" \ | ||
| "README.md" | ||
|
|
||
| "https://github.com/${REPOSITORY_NAME}/releases/download/${COMMIT}/cert-manager.yaml" | ||
| SOURCE_TEXT="\[.*\](https://github.com/${REPOSITORY_NAME}/releases/tag/v.*)" | ||
| DESTINATION_TEXT="\[${COMMIT#v}\](https://github.com/${REPOSITORY_NAME}/releases/tag/${COMMIT})" | ||
| update_readme "$MANIFESTS_DIRECTORY" "$SOURCE_TEXT" "$DESTINATION_TEXT" | ||
| commit_changes "$MANIFESTS_DIRECTORY" "Update ${REPOSITORY_NAME} manifests from ${COMMIT}" "$MANIFESTS_DIRECTORY" | ||
| echo "Synchronization completed successfully." |
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 |
|---|---|---|
| @@ -1,42 +1,24 @@ | ||
| #!/usr/bin/env bash | ||
| # This script helps to create a PR to update the Dex manifests | ||
|
|
||
| SCRIPT_DIRECTORY=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
| source "${SCRIPT_DIRECTORY}/library.sh" | ||
|
|
||
| setup_error_handling | ||
|
|
||
| COMPONENT_NAME="dex" | ||
| DEX_RELEASE="v2.43.1" # Must be a release | ||
| BRANCH_NAME=${BRANCH_NAME:=synchronize-${COMPONENT_NAME}-manifests-${DEX_RELEASE?}} | ||
|
|
||
| REPOSITORY_NAME="dexidp/dex" | ||
| COMMIT="v2.43.1" | ||
| BRANCH_NAME=${BRANCH_NAME:=synchronize-${COMPONENT_NAME}-manifests-${COMMIT?}} | ||
| MANIFESTS_DIRECTORY=$(dirname $SCRIPT_DIRECTORY) | ||
| DESTINATION_DIRECTORY=$MANIFESTS_DIRECTORY/common/${COMPONENT_NAME} | ||
|
|
||
| create_branch "$BRANCH_NAME" | ||
|
|
||
| check_uncommitted_changes | ||
|
|
||
| echo "Updating Dex image tag to ${DEX_RELEASE}..." | ||
|
|
||
| if [[ "$OSTYPE" == "darwin"* ]]; then | ||
| sed -i "" "s|ghcr.io/dexidp/dex:v[0-9.]*|ghcr.io/dexidp/dex:${DEX_RELEASE}|g" \ | ||
| sed -i "" "s|ghcr.io/dexidp/dex:v[0-9.]*|ghcr.io/dexidp/dex:${COMMIT}|g" \ | ||
| $DESTINATION_DIRECTORY/base/deployment.yaml | ||
| else | ||
| sed -i "s|ghcr.io/dexidp/dex:v[0-9.]*|ghcr.io/dexidp/dex:${DEX_RELEASE}|g" \ | ||
| sed -i "s|ghcr.io/dexidp/dex:v[0-9.]*|ghcr.io/dexidp/dex:${COMMIT}|g" \ | ||
| $DESTINATION_DIRECTORY/base/deployment.yaml | ||
| fi | ||
|
|
||
| if [[ "$OSTYPE" == "darwin"* ]]; then | ||
| sed -i "" '/| Dex | common\/dex |/s|\[.*\](https://github.com/dexidp/dex/releases/tag/v.*)|['"${DEX_RELEASE#v}"'](https://github.com/dexidp/dex/releases/tag/'"${DEX_RELEASE}"')|' \ | ||
| ${MANIFESTS_DIRECTORY}/README.md | ||
| else | ||
| sed -i '/| Dex | common\/dex |/s|\[.*\](https://github.com/dexidp/dex/releases/tag/v.*)|['"${DEX_RELEASE#v}"'](https://github.com/dexidp/dex/releases/tag/'"${DEX_RELEASE}"')|' \ | ||
| ${MANIFESTS_DIRECTORY}/README.md | ||
| fi | ||
|
|
||
| commit_changes "$MANIFESTS_DIRECTORY" "Update common/dex manifests to ${DEX_RELEASE}" \ | ||
| "$DESTINATION_DIRECTORY" \ | ||
| "README.md" | ||
|
|
||
| echo "Synchronization completed successfully." | ||
| SOURCE_TEXT="\[.*\](https://github.com/${REPOSITORY_NAME}/releases/tag/v.*)" | ||
| DESTINATION_TEXT="\[${COMMIT#v}\](https://github.com/${REPOSITORY_NAME}/releases/tag/${COMMIT})" | ||
| update_readme "$MANIFESTS_DIRECTORY" "$SOURCE_TEXT" "$DESTINATION_TEXT" | ||
| commit_changes "$MANIFESTS_DIRECTORY" "Update ${REPOSITORY_NAME} manifests from ${COMMIT}" "$MANIFESTS_DIRECTORY" | ||
| echo "Synchronization completed successfully." |
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 |
|---|---|---|
| @@ -1,38 +1,23 @@ | ||
| #!/usr/bin/env bash | ||
| # This script helps to create a PR to update the Katib manifests | ||
|
|
||
| SCRIPT_DIRECTORY=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
| source "${SCRIPT_DIRECTORY}/library.sh" | ||
|
|
||
| setup_error_handling | ||
|
|
||
| COMPONENT_NAME="katib" | ||
| REPOSITORY_NAME="kubeflow/katib" | ||
| REPOSITORY_URL="https://github.com/kubeflow/katib.git" | ||
| COMMIT="v0.19.0" | ||
| REPOSITORY_DIRECTORY="katib" | ||
| SOURCE_DIRECTORY=${SOURCE_DIRECTORY:=/tmp/kubeflow-${COMPONENT_NAME}} | ||
| BRANCH_NAME=${BRANCH_NAME:=synchronize-${COMPONENT_NAME}-manifests-${COMMIT?}} | ||
|
|
||
| # Path configurations | ||
| MANIFESTS_DIRECTORY=$(dirname $SCRIPT_DIRECTORY) | ||
| SOURCE_MANIFESTS_PATH="manifests/v1beta1" | ||
| DESTINATION_MANIFESTS_PATH="applications/${COMPONENT_NAME}/upstream" | ||
|
|
||
| # README update patterns | ||
| SOURCE_TEXT="\[.*\](https://github.com/${REPOSITORY_NAME}/tree/.*/manifests/v1beta1)" | ||
| DESTINATION_TEXT="\[${COMMIT}\](https://github.com/${REPOSITORY_NAME}/tree/${COMMIT}/manifests/v1beta1)" | ||
|
|
||
| create_branch "$BRANCH_NAME" | ||
|
|
||
| clone_and_checkout "$SOURCE_DIRECTORY" "$REPOSITORY_URL" "$REPOSITORY_DIRECTORY" "$COMMIT" | ||
|
|
||
| copy_manifests "${SOURCE_DIRECTORY}/${REPOSITORY_DIRECTORY}/${SOURCE_MANIFESTS_PATH}" "${MANIFESTS_DIRECTORY}/${DESTINATION_MANIFESTS_PATH}" | ||
|
|
||
| update_readme "$MANIFESTS_DIRECTORY" "$SOURCE_TEXT" "$DESTINATION_TEXT" | ||
|
|
||
| commit_changes "$MANIFESTS_DIRECTORY" "Update ${REPOSITORY_NAME} manifests from ${COMMIT}" \ | ||
| "applications" \ | ||
| "README.md" | ||
|
|
||
| commit_changes "$MANIFESTS_DIRECTORY" "Update ${REPOSITORY_NAME} manifests from ${COMMIT}" "$MANIFESTS_DIRECTORY" | ||
| echo "Synchronization completed successfully." |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_branchusesif [ $(git branch --list "$branch") ]; then ..., which can emit a test error when the branch does not exist because the command substitution expands to an empty string (resulting in[ ]). Use a string test with proper quoting (e.g.,if [[ -n $(git branch --list "$branch") ]]; then) or a command that directly checks existence (git show-ref --verify --quiet "refs/heads/$branch").