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
[shopsys] added scripts for monorepo maintenance into /.ci directory #729
Conversation
- basically copy-pasted from our Jenkins configuration so we can change it with the codebase (eg. add a package inside a PR and let it be split automatically) - `monorepo_split.sh` splits master into all subrepositories - should be executed automatically after `master` is successfully built - `monorepo_force_split_branch.sh` splits and force pushes selected branch into all subrepositories - should be executed manually as a parameterized build - `monorepo_remove_branch.sh` removes selected branch from all subrepositories - should be executed manually as a parameterized build - cleans up after `monorepo_force_split_branch.sh` - `monorepo_functions.sh` contains reusable functions
.ci/monorepo_force_split_branch.sh
Outdated
NC="\e[0m" | ||
|
||
SPLIT_BRANCH=$1 | ||
WORKSPACE=${WORKSPACE:-.} |
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.
WORKSPACE=${WORKSPACE:-.} | |
WORKSPACE=${WORKSPACE:-$PWD} |
if default value for $workspace is relative path and we will execute
cd $WORKSPACE
git clone --bare .git $WORKSPACE/split/$PACKAGE
cd $WORKSPACE/split/$PACKAGE
in the next iteration we will not be in the original $WORKSPACE but in $WORKSPACE/split/$PACKAGE
$PWD will contain absolute path of current path instead of .
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.
just hint that monorepo_force_split_branch.sh
and monorepo_split.sh
differ in just a few places.
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.
Thanks for noticing, I've fixed that in 11a620a
.ci/monorepo_split.sh
Outdated
printf "\n${BLUE}$(date +%T) > Splitting of all packages finished. Checking the ability to push the split repositories...${NC}\n\n" | ||
for PACKAGE in $(get_all_packages); do | ||
cd $WORKSPACE/split/$PACKAGE | ||
REMOTE="git@github.com:shopsys/$PACKAGE.git" |
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.
REMOTE variable is used here for dry-run but it is not used in real push below
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.
It's in a for-cycle so it cannot be reused below. The value should be the same though ("git@github.com:shopsys/$PACKAGE.git"
).
It could be re-assigned and used the same way (REMOTE="git@github.com:shopsys/$PACKAGE.git"
) so it's obvious that they are the same, or it could be moved to monorepo_functions.sh
in a new function get_package_remote
so it's actually located in one place.
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.
I have done the extraction in b83fd6b
get_all_packages()
inmonorepo_functions.sh
and let it be split automatically after the PR is merged)monorepo_split.sh
splits master into all subrepositoriesmaster
is successfully builtmonorepo_force_split_branch.sh
splits and force pushes selected branch into all subrepositoriesmonorepo_remove_branch.sh
removes selected branch from all subrepositoriesmonorepo_force_split_branch.sh
monorepo_functions.sh
contains reusable functions