Skip to content

Commit

Permalink
Changing deploy to use rsync. (#162)
Browse files Browse the repository at this point in the history
* Changing deploy to use rsync.

* Adding excludes file for rsync.

* Ignoring more files in deploy.

* Protecting .git during rsync.

* Adding more tests for deploy artifact.
  • Loading branch information
grasmash authored Jun 15, 2016
1 parent 052d325 commit 11018f3
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 56 deletions.
88 changes: 85 additions & 3 deletions template/build/core/files/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,88 @@
# This file will be copied into the docroot of the build artifact.
# @see docroot/example.gitignore
local.*
*.local

# Ignore paths that contain user-generated content.
sites/*/files
sites/*/private
docroot/sites/*/files
docroot/sites/*/private

# Front end libraries.
node_modules
bower_components

# OS X
.DS_Store
.AppleDouble
.LSOverride
Icon

# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Eclipse
*.pydevproject
.project
.metadata
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# PDT-specific
.buildpathk

# Emacs
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*

# User-specific stuff:
.idea/

#XHProf
xhprof_*

#Sass
.sass-cache
*.css.map

#Netbeans IDE
nbproject
nbproject/*

#DrupalVM
.vagrant/
27 changes: 27 additions & 0 deletions template/build/core/files/deploy-exclude.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# These files and their children will not be copied to the deployment artifact.
# If these files already exist in the upstream artifact, they will be removed.
.drush-use
.idea
.git
.gitignore
.travis.yml
.vagrant
blt.sh
bower_components
build
deploy
docroot/core
docroot/libraries/contrib
docroot/modules/contrib
docroot/themes/contrib
drush/contrib
drush.wrapper
local.*
node_modules
project.yml
readme
sites/*/files
sites/*/private
tests
Vagrantfile
vendor
1 change: 1 addition & 0 deletions template/build/core/phing/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ composer:

deploy:
dir: ${repo.root}/deploy
exclude_file: ${repo.root}/build/core/files/deploy-exclude.txt

# File and Directory locations.
docroot.relative: ${repo.root.relative}/docroot
Expand Down
58 changes: 5 additions & 53 deletions template/build/core/phing/tasks/deploy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
<not><isset property="deploy.branch"/></not>
</or>
<then>
<fail message="You must pass deploy.commitMsg and deploy.branch as runtime parameters."/>
<echo message="You must pass deploy.commitMsg and deploy.branch as runtime parameters."/>
<echo message="Command should match syntax:"/>
<echo message="./blt.sh deploy:artifact -Ddeploy.commitMsg='BLT-123: The commit message.' -Ddeploy.branch='master-build'"/>
<fail message="Missing required parameters."/>
</then>
</if>

Expand Down Expand Up @@ -62,7 +63,7 @@
</target>

<target name="deploy:artifact:build" description="Generates a deploy-ready build in deploy.dir."
depends="deploy:artifact:clean, deploy:artifact:copy, deploy:artifact:composer:install, deploy:artifact:profile:make, frontend:build, deploy:artifact:sanitize">
depends="frontend:build, deploy:artifact:copy, deploy:artifact:composer:install, deploy:artifact:profile:make, deploy:artifact:sanitize">
<!-- If we are using ACSF, run the ACSF Deploy command. -->
<if>
<equals arg1="${hosting}" arg2="acsf"/>
Expand All @@ -72,15 +73,6 @@
</if>
</target>

<target name="deploy:artifact:clean" description="Deletes the contents of the deploy dir.">
<delete dir="${deploy.dir}/config" failonerror="false" quiet="true" />
<delete dir="${deploy.dir}/docroot" failonerror="false" quiet="true" />
<delete dir="${deploy.dir}/hooks" failonerror="false" quiet="true" />
<delete dir="${deploy.dir}/factory-hooks" failonerror="false" quiet="true" />
<delete dir="${deploy.dir}/patches" failonerror="false" quiet="true" />
<delete dir="${deploy.dir}/vendor" failonerror="false" quiet="true" />
</target>

<target name="deploy:artifact:commit">
<!-- We make these commands quiet because they can cause the output to be so long that Travis CI stops logging. -->
<exec command="git add -A" dir="${deploy.dir}" logoutput="true" passthru="true" checkreturn="true"/>
Expand Down Expand Up @@ -118,50 +110,10 @@
<!-- @todo Support multisite. -->
<chmod file="${docroot}/sites/default" mode="0777" />

<!-- Copy required files from docroot. -->
<copy todir="${deploy.dir}/docroot" overwrite="true">
<fileset dir="${docroot}" defaultexcludes="false">
<!-- This should be similar to .gitigore. -->
<!-- We remove default excludes because they include .gitignore files we need, like the ACSF one. -->
<include name="**" />
<exclude name="**/local.*" />
<exclude name=".gitkeep" />
<exclude name=".DS_STORE" />
<exclude name="core/**" />
<exclude name="drush/contrib/**" />
<exclude name="example.gitignore" />
<exclude name="vendor/**" />
<exclude name="sites/**/files/**" />
<exclude name="sites/**/private/**" />
<exclude name="themes/contrib/**" />
<exclude name="profiles/contrib/**" />
<exclude name="modules/contrib/**" />
<exclude name="**/node_modules/**" />
<exclude name="**/bower_components/**" />
</fileset>
</copy>

<!-- Copy Acquia Cloud hooks. -->
<copy todir="${deploy.dir}/hooks" overwrite="true">
<fileset dir="${repo.root}/hooks"/>
</copy>

<copy todir="${deploy.dir}/factory-hooks" overwrite="true" haltonerror="false">
<fileset dir="${repo.root}/factory-hooks"/>
</copy>

<!-- Copy configuration. -->
<copy todir="${deploy.dir}/config" overwrite="true">
<fileset dir="${repo.root}/config"/>
</copy>

<!-- Copy local patches. -->
<copy todir="${deploy.dir}/patches" overwrite="true">
<fileset dir="${repo.root}/patches"/>
</copy>
<exec dir="${repo.root}" command="rsync -a --no-g --no-p --delete --delete-excluded --exclude-from=${deploy.exclude_file} ${repo.root}/ ${deploy.dir}/ --filter 'protect /.git/'" logoutput="true" checkreturn="true"/>

<!-- Use our own .gitignore -->
<copy file="${repo.root}/build/core/files/.gitignore" tofile="${deploy.dir}/docroot/.gitignore" overwrite="true"/>
<copy file="${repo.root}/build/core/files/.gitignore" tofile="${deploy.dir}/.gitignore" overwrite="true"/>

<!-- Set sites/default back to 755 permissions. -->
<!-- @todo Support multisite. -->
Expand Down
6 changes: 6 additions & 0 deletions tests/phpunit/DeployTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public function testBltDeployBuild() {

// Ensure deploy directory was sanitized.
$this->assertFileNotExists($this->deploy_dir . '/docroot/LICENSE.txt');

// Ensure non-required files are not in deploy dir.
$this->assertFileNotExists($this->deploy_dir . '/blt.sh');
$this->assertFileNotExists($this->deploy_dir . '/build');
$this->assertFileNotExists($this->deploy_dir . '/project.yml');
$this->assertFileNotExists($this->deploy_dir . '/tests');
}

/**
Expand Down

0 comments on commit 11018f3

Please sign in to comment.