-
Notifications
You must be signed in to change notification settings - Fork 455
[CI] Add dev/codeowners and .go-version file to be synced in backport branches #13994
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
Changes from all commits
ddf11c1
498c3ed
b61687c
08d8f49
4b7faba
abab7fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,10 +96,15 @@ createLocalBackportBranch() { | |
|
||
removeOtherPackages() { | ||
local sourceFolder=$1 | ||
local currentPackage="" | ||
for dir in "$sourceFolder"/*; do | ||
if [[ -d "$dir" ]] && [[ "$(basename "$dir")" != "$PACKAGE_NAME" ]]; then | ||
echo "Removing directory: $dir" | ||
rm -rf "$dir" | ||
|
||
currentPackage=$(basename "${dir}") | ||
echo "Removing ${currentPackage} from .github/CODEOWNERS" | ||
sed -i "/^\/packages\/${currentPackage}\//d" .github/CODEOWNERS | ||
fi | ||
done | ||
} | ||
|
@@ -116,70 +121,90 @@ updateBackportBranchContents() { | |
local BUILDKITE_FOLDER_PATH=".buildkite" | ||
local JENKINS_FOLDER_PATH=".ci" | ||
local files_cached_num="" | ||
|
||
git checkout "$BACKPORT_BRANCH_NAME" | ||
echo "Copying $BUILDKITE_FOLDER_PATH from $SOURCE_BRANCH..." | ||
git checkout $SOURCE_BRANCH -- $BUILDKITE_FOLDER_PATH | ||
git add $BUILDKITE_FOLDER_PATH | ||
|
||
if git ls-tree -d --name-only main:.ci >/dev/null 2>&1; then | ||
git checkout $BACKPORT_BRANCH_NAME | ||
echo "Copying $BUILDKITE_FOLDER_PATH from $SOURCE_BRANCH..." | ||
git checkout $SOURCE_BRANCH -- $BUILDKITE_FOLDER_PATH | ||
echo "Copying $JENKINS_FOLDER_PATH from $SOURCE_BRANCH..." | ||
git checkout $SOURCE_BRANCH -- $JENKINS_FOLDER_PATH | ||
git add $JENKINS_FOLDER_PATH | ||
else | ||
git checkout $BACKPORT_BRANCH_NAME | ||
echo "Copying $BUILDKITE_FOLDER_PATH from $SOURCE_BRANCH..." | ||
git checkout $SOURCE_BRANCH -- $BUILDKITE_FOLDER_PATH | ||
echo "Removing $JENKINS_FOLDER_PATH from $BACKPORT_BRANCH_NAME..." | ||
rm -rf "$JENKINS_FOLDER_PATH" | ||
if [ -d "${JENKINS_FOLDER_PATH}" ]; then | ||
echo "Removing $JENKINS_FOLDER_PATH from $BACKPORT_BRANCH_NAME..." | ||
rm -rf "$JENKINS_FOLDER_PATH" | ||
git add "$JENKINS_FOLDER_PATH" | ||
fi | ||
fi | ||
|
||
# Update scripts used by mage | ||
local MAGEFILE_SCRIPTS_FOLDER="dev/citools" | ||
local TESTSREPORTER_SCRIPTS_FOLDER="dev/testsreporter" | ||
local COVERAGE_SCRIPTS_FOLDER="dev/coverage" | ||
local CODEOWNERS_SCRIPTS_FOLDER="dev/codeowners" | ||
|
||
if git ls-tree -d --name-only main:${MAGEFILE_SCRIPTS_FOLDER} > /dev/null 2>&1 ; then | ||
echo "Copying $MAGEFILE_SCRIPTS_FOLDER from $SOURCE_BRANCH..." | ||
git checkout "$SOURCE_BRANCH" -- "${MAGEFILE_SCRIPTS_FOLDER}" | ||
git add ${MAGEFILE_SCRIPTS_FOLDER} | ||
|
||
echo "Copying $TESTSREPORTER_SCRIPTS_FOLDER from $SOURCE_BRANCH..." | ||
git checkout "$SOURCE_BRANCH" -- "${TESTSREPORTER_SCRIPTS_FOLDER}" | ||
git add ${TESTSREPORTER_SCRIPTS_FOLDER} | ||
|
||
echo "Copying $COVERAGE_SCRIPTS_FOLDER from $SOURCE_BRANCH..." | ||
git checkout "$SOURCE_BRANCH" -- "${COVERAGE_SCRIPTS_FOLDER}" | ||
git add ${COVERAGE_SCRIPTS_FOLDER} | ||
|
||
echo "Copying $CODEOWNERS_SCRIPTS_FOLDER from $SOURCE_BRANCH..." | ||
git checkout "$SOURCE_BRANCH" -- "${CODEOWNERS_SCRIPTS_FOLDER}" | ||
git add ${CODEOWNERS_SCRIPTS_FOLDER} | ||
Comment on lines
+161
to
+163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New folder added |
||
|
||
echo "Copying magefile.go from $SOURCE_BRANCH..." | ||
git checkout "$SOURCE_BRANCH" -- "magefile.go" | ||
git add magefile.go | ||
|
||
# As this script runs in the context of the main branch (mainly go mod tidy), we need to copy | ||
# the .go-version file from the main branch to the backport branch. This avoids failures | ||
# installing dependencies in the backport Pull Request. | ||
echo "Copying .go-version from $SOURCE_BRANCH..." | ||
git checkout "$SOURCE_BRANCH" -- ".go-version" | ||
git add .go-version | ||
Comment on lines
+172
to
+174
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New file added: As this script is run with the contents of This ensures that backport branch is run with the same Golang version. Tested that |
||
|
||
# Run go mod tidy to update just the dependencies related to magefile and dev scripts | ||
go mod tidy | ||
|
||
git add go.mod go.sum | ||
fi | ||
|
||
if [ "${REMOVE_OTHER_PACKAGES}" == "true" ]; then | ||
echo "Removing all packages from $PACKAGES_FOLDER_PATH folder" | ||
removeOtherPackages "${PACKAGES_FOLDER_PATH}" | ||
ls -la $PACKAGES_FOLDER_PATH | ||
ls -la "${PACKAGES_FOLDER_PATH}" | ||
|
||
git add "${PACKAGES_FOLDER_PATH}/" | ||
git add .github/CODEOWNERS | ||
fi | ||
|
||
git status | ||
|
||
echo "Setting up git environment..." | ||
update_git_config | ||
|
||
echo "Commiting" | ||
git add $BUILDKITE_FOLDER_PATH | ||
if [ -d "${JENKINS_FOLDER_PATH}" ]; then | ||
git add "${JENKINS_FOLDER_PATH}" | ||
fi | ||
if [ -d "${MAGEFILE_SCRIPTS_FOLDER}" ] ; then | ||
git add ${MAGEFILE_SCRIPTS_FOLDER} | ||
git add ${TESTSREPORTER_SCRIPTS_FOLDER} | ||
git add go.mod go.sum | ||
fi | ||
git add $PACKAGES_FOLDER_PATH/ | ||
git status | ||
|
||
files_cached_num=$(git diff --name-only --cached | wc -l) | ||
if [ "${files_cached_num}" -gt 0 ]; then | ||
echo "Committing changes..." | ||
git commit -m "Add $BUILDKITE_FOLDER_PATH and $JENKINS_FOLDER_PATH to backport branch: $BACKPORT_BRANCH_NAME from the $SOURCE_BRANCH branch" | ||
else | ||
echo "Nothing to commit, skip." | ||
fi | ||
|
||
if [ "$DRY_RUN" == "true" ];then | ||
echo "DRY_RUN mode, nothing will be pushed." | ||
# Show just the relevant files diff (go.mod, go.sum, .buildkite, dev and package to be backported) | ||
git --no-pager diff $SOURCE_BRANCH...$BACKPORT_BRANCH_NAME go.mod go.sum .buildkite/ dev/ "packages/${PACKAGE_NAME}" | ||
# Show just the relevant files diff (go.mod, go.sum, .buildkite, dev, .go-version, .github/CODEOWNERS and package to be backported) | ||
git --no-pager diff $SOURCE_BRANCH...$BACKPORT_BRANCH_NAME .buildkite/ dev/ go.sum go.mod .go-version .github/CODEOWNERS "packages/${PACKAGE_NAME}" | ||
else | ||
echo "Pushing..." | ||
git push origin $BACKPORT_BRANCH_NAME | ||
|
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.
Leave just in
.github/CODEOWNERS
the entries related to${PACKAGE_NAME}
package.