Skip to content
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

Merged
merged 5 commits into from Jan 17, 2019

Conversation

PetrHeinz
Copy link
Contributor

@PetrHeinz PetrHeinz commented Jan 11, 2019

  • basically copy-pasted from our Jenkins configuration so we can change it with the codebase (eg. add a package inside a PR as a modification of get_all_packages() in monorepo_functions.sh and let it be split automatically after the PR is merged)
  • 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
  • related to [shopsys] manageable continuous integration via .ci folders #698 and describe parallel splitting on our CI in monorepo-tools' docs #408
  • allows us to simplify our Jenkins configuration for monorepo maintenance to something like:
    image
Q A
Description, reason for the PR adding a package requires changes to Jenkins configuration for it to be split (or stop being split for package removal)
New feature Yes
BC breaks No
Fixes issues ...
Standards and tests pass Yes
Have you read and signed our License Agreement for contributions? Yes

- 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
NC="\e[0m"

SPLIT_BRANCH=$1
WORKSPACE=${WORKSPACE:-.}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 .

Copy link
Contributor

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.

Copy link
Contributor Author

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

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"
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

@PetrHeinz PetrHeinz merged commit 3fc7afc into master Jan 17, 2019
@PetrHeinz PetrHeinz deleted the ph-monorepo-ci-scripts branch January 17, 2019 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants