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

Replace tar+scp with rsync (#22) #35

Merged
merged 6 commits into from
Dec 28, 2016

Conversation

steventannz
Copy link
Contributor

Replaces tar and scp with rsync as part of #22

@@ -13,16 +13,6 @@ PROJECT_DIR_NAME="$( basename "$PROJECT_DIR")"

# Read config variables from local.properties.
REMOTE_BUILD_MACHINE=$(awk -F "=" '/remote_build.machine/ {print $2}' "$PROJECT_DIR/local.properties")
LOCAL_GZIP_LEVEL=$(awk -F "=" '/remote_build.local_gzip_level/ {print $2}' "$PROJECT_DIR/local.properties")
Copy link
Contributor

Choose a reason for hiding this comment

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

rsync actually supports compression (from 1 to 9) via --compress-level=

--exclude='artifacts' \
--exclude='captures' \
--exclude='build' \
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not exclude local build files?

Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand correctly it is excluded a little bit below.


# Build project on a remote machine and then archive it.
# Build project on a remote machine
Copy link
Contributor

Choose a reason for hiding this comment

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

Dot at the end please :)


# Copy build results from remote machine to local.
scp "$REMOTE_BUILD_MACHINE":~/"$PROJECT_DIR_NAME"/remotely_built_project.tar "$PROJECT_DIR/build/"
cd ~/mainframer/ && \
Copy link
Contributor

Choose a reason for hiding this comment

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

$PROJECT_DIR_NAME?

@steventannz
Copy link
Contributor Author

Updated with requested changes

@@ -162,8 +162,8 @@ You can tune compression levels as you wish. Default compression levels are `1`.
Configurable via `local.properties`:

```
remote_build.local_gzip_level=1
Copy link
Contributor

Choose a reason for hiding this comment

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

This is breaking change, let's leave properties name as they are for now :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually rsync itself is kind of breaking, but we can plan this for 1.1.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see why, it is presented in Mac OS and most Linux distros, should work for most of users of out the box

Copy link
Contributor

Choose a reason for hiding this comment

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

It is still a behaviour change. I’m running it locally at this point without any issues, but who knows.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, it is, but at this point of time it should be very compatible for most users, so I would prefer to update only minor version

LOCAL_ARCHIVE_COMMAND="tar \
-c \
--exclude='build/project_for_remote_build.tar' \
--exclude='local.properties' \
Copy link
Contributor

Choose a reason for hiding this comment

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

You must exclude local.properties, otherwise remote build may fail if it'll see your local.properties with path to android sdk that does not make sense for remote build machine!

Copy link
Contributor

Choose a reason for hiding this comment

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

Even worse, it can rewrite or remove the local one on back sync.

Copy link
Contributor

Choose a reason for hiding this comment

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

Omg, totally needs to be fixed then

Copy link
Contributor

@arturdryomov arturdryomov left a comment

Choose a reason for hiding this comment

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

Looks and works great, some nits + @artem-zinnatullin comments.

pushd "$PROJECT_DIR"
eval "$LOCAL_UNARCHIVE_COMMAND"
# Sync project back to local machine.
rsync -a --delete --compress-level=$REMOTE_COMPRESS_LEVEL \
Copy link
Contributor

Choose a reason for hiding this comment

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

Don’t know about @artem-zinnatullin, but I would prefer full parameter names, i. e. --archive instead of -a.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

eval $LOCAL_ARCHIVE_COMMAND
popd
--exclude='**/build' \
-e "ssh" ./ "$REMOTE_BUILD_MACHINE:~/$PROJECT_DIR_NAME"
Copy link
Contributor

Choose a reason for hiding this comment

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

--rsh instead of -e

@@ -162,8 +162,8 @@ You can tune compression levels as you wish. Default compression levels are `1`.
Configurable via `local.properties`:

```
remote_build.local_gzip_level=1
Copy link
Contributor

Choose a reason for hiding this comment

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

Well, it is, but at this point of time it should be very compatible for most users, so I would prefer to update only minor version

@steventannz
Copy link
Contributor Author

Cheers for the feedback, updated with requested changes

Copy link
Contributor

@artem-zinnatullin artem-zinnatullin left a comment

Choose a reason for hiding this comment

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

Awesome!

@artem-zinnatullin
Copy link
Contributor

Was able to save about 30 seconds (working from remote location today), thank you @steventannz!

@artem-zinnatullin
Copy link
Contributor

@steventannz thank you for PR!

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.

3 participants