mrdavidlaing / pressupbox-development-boilerplate

Patterns and practices for teams to collaborating on WordPress projects
Other
1 stars 5 forks source link

#16 Rewrite build script in Rake #24

Closed daithi-coombes closed 11 years ago

daithi-coombes commented 11 years ago

16 (Rewrite build script in Rake) pr

daithi-coombes commented 11 years ago

@mrdavidlaing this should be ready for review/merge.

The task call is:

  task :default => [:copy, :refresh_buildpack, :compile_buildpack, "dev_server:all", :release, :verify_hosting_dependencies] do
mrdavidlaing commented 11 years ago

I've updated the build server default to running the Rakefile if its available as a way to test this.

#!/usr/bin/env bash
PULL_REQUEST="$(echo $sha1 | sed -r 's/(origin|merge|\/)//g')"
DEPLOY_NAME="$PULL_REQUEST-remote-development-boilerplate"

if  [-f Rakefile ]
then
  rake 
  rake release:$DEPLOY_NAME:$STACKATO_USERNAME:$STACKATO_PASSWORD
else
  npm install
  grunt
  grunt release:$DEPLOY_NAME:$STACKATO_USERNAME:$STACKATO_PASSWORD
fi

Frustratingly, the ubuntu build agents is offline again. @sopel - Please could you increase the spot price bid up to the on-demand rate to reduce the amount of build agent downtime. thx

mrdavidlaing commented 11 years ago

@daithi-coombes Took a couple of updates to the buildpack to get this working on the buildserver (cause of spaces in the build server working folder), but we now have everything except for the watcher implemented.

The "Rake way" to implement this functionality seems to be with guard/guard.

Would you like to tackle that, or should I?

daithi-coombes commented 11 years ago

Don't mind if I do, I'll get on it now

mrdavidlaing commented 11 years ago

@daithi-coombes ETA on completing the watcher functionality?

daithi-coombes commented 11 years ago

@mrdavidlaing I should have it for you in next hour or so, I've just comited what I have so far

daithi-coombes commented 11 years ago

also both the past two builds failed:

cannot load such file -- guard

the vagrant and rake files are testing ok on my machine. Are these build fails down to the setup with jenkins?

mrdavidlaing commented 11 years ago

@daithi-coombes - The commits below should have addressed these two issues.

(a) I have switched to using bundler and a Gemfile to explicitly record and manage gem dependancies. I've updated the Jenkins server to run bundle install before building to ensure all dependancies are installed (b) Rake now runs the guard watcher via a separate process (c) I've made the dist/ folder part of the repo, and the clean task delete everything below dist/ (but not dist/itself), so it will always be present

I'm going to merge into master unless you tell me otherwise by tomorrow AM.

mrdavidlaing commented 11 years ago

retest this please

daithi-coombes commented 11 years ago

hmmm, issue still persists. I have created the task :test, which runs :copy, :watcher but still getting the same

vagrant@precise64:~$ rake test

##########################
#       Copy
##########################
        copying src/foo to dist/foo
        copying src/public to dist/public
        ...
        copying src/test.txt to dist/test.txt

17:08:51 - INFO - Using Guardfile at Guardfile.
17:08:51 - INFO - Run all
17:08:52 - ERROR - Guard::Copy - cannot copy, no valid :to directories
17:08:52 - ERROR - Guard::Copy - cannot copy, no valid :to directories
vagrant@precise64:~$
mrdavidlaing commented 11 years ago

Hmm. I can't replicate that (from a fresh dev server - vagrant destroy && vagrant up)

vagrant@precise64:~$ rake test

##########################
#   Copy
##########################
    copying src/public to dist/public
...snip...
    copying src/stackato.yml to dist/stackato.yml

==== Type: exit to quit ====
bundle exec guard
17:20:04 - INFO - Guard uses TerminalTitle to send notifications.
17:20:04 - INFO - Guard::Copy - files in:
17:20:04 - INFO - src
17:20:04 - INFO - will be copied to:
17:20:04 - INFO - dist
17:20:04 - INFO - Guard is now watching at '/home/vagrant'
[1] guard(main)>
daithi-coombes commented 11 years ago

I've tried absolute paths and even with sudo but the problem still persits. Will try with vagrant destroy to properly reset lock files etc

mrdavidlaing commented 11 years ago

@daithi-coombes I see you have a response to your stack overflow question. Looks like a simple fix - does it work?

daithi-coombes commented 11 years ago

its not throwing the error anymore and rake is passing successfully to hiphop, but the folders aren't being watched, maybe 'copy' is the wrong method but the answer to my stack question seems right ;)

daithi-coombes commented 11 years ago

... forgot to watch the folder...

guard :copy, :from => 'source', :to => 'target' do
  watch('source')
end
mrdavidlaing commented 11 years ago

Or, its just going a single copy run, and then exiting.

Another idea if you can't get this working. Looks like the watcher functionality is actually handled by the separate listen gem - you could perhaps use that to trigger your own copy functionality?

daithi-coombes commented 11 years ago

calling guard runs the guardfile and works https://github.com/mrdavidlaing/pressupbox-development-boilerplate/commit/6cd16bbc6f136b24c9d4afc0958fa5c6c040ccb8

when I call it from rake, it copies from src to dist successfully but then fails to watch the folder. Running from the rakefile produces:

##########################                                                                   
#       Watch Files                                                     
##########################                                                                                        
09:12:22 - INFO - Guard::Copy is changing watcher pattern:                                              
09:12:22 - INFO - src                                                  
09:12:22 - INFO - to:                                                                                
09:12:22 - INFO - ^src/                                                 
09:12:22 - INFO - Guard::Copy - files in:                                                              
09:12:22 - INFO - src                                                   
09:12:22 - INFO - will be copied to:                                                                          
09:12:22 - INFO - dist                                                  
09:12:22 - INFO - copying to dist/tmp.txt                               
....
09:12:23 - INFO - copying to dist/stackato.yml                          

##########################                                              
#       Setting up MySql 

but any changes I make to src do not get coppied, seems the rake task is missing something

mrdavidlaing commented 11 years ago

retest this please

mrdavidlaing commented 11 years ago

@daithi-coombes Switching to using the listen gem seems to have resolved the "watcher" issues.

I'm merging this PR now since all future work should be against Rake (i.e. #28 should be written using Rake rather than Grunt)