Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5afaf80
Revert "Merge pull request #82 from AntJanus/67-move-events-after-dep…
ericclemmons Dec 26, 2013
64cc1db
Generated test site correctly uses local & mounted library
ericclemmons Dec 27, 2013
3148625
Install bower components before symlink creation
ericclemmons Dec 27, 2013
8f057c2
Fix permissions after finalize_update
ericclemmons Dec 27, 2013
3229860
Restructure testing
ericclemmons Dec 27, 2013
a887508
Revert "Fix permissions after finalize_update"
ericclemmons Dec 27, 2013
4183b13
Add test for genesis:deploy
ericclemmons Dec 27, 2013
0fd090f
Clean up test namespacing
ericclemmons Dec 27, 2013
5a3640f
Update .travis.yml to match test Vagrantfile
ericclemmons Dec 27, 2013
839060b
generate -> mock
ericclemmons Dec 27, 2013
2dc74b3
Fix paths
ericclemmons Dec 27, 2013
e9b7ac7
Install capistrano on travis
ericclemmons Dec 27, 2013
21015a4
"ERROR: Can't use --version w/ multiple gems. Use name:ver instead."
ericclemmons Dec 27, 2013
adc0303
Attempt to fix detached symlink
ericclemmons Dec 27, 2013
87ce338
Back to 7b969d204067d1163695ba68005b56fc3cea2d9a
ericclemmons Dec 27, 2013
932559f
No more docs
ericclemmons Dec 27, 2013
b08b95e
Fix sftp tmp path
ericclemmons Dec 27, 2013
fa66143
sudo gem install
ericclemmons Dec 27, 2013
637f11f
Revert "sudo gem install"
ericclemmons Dec 27, 2013
9dd707c
Attempt to copy files, not symlink them for travis
ericclemmons Feb 5, 2014
82a4934
Copy current project into bower by default
ericclemmons Feb 5, 2014
7c05a1d
Add Gemfile
ericclemmons Feb 11, 2014
d9a0210
Replace gems with bundler
ericclemmons Feb 11, 2014
7275941
Sudo make me a sandwhich?
ericclemmons Feb 11, 2014
0daf75f
Let's try bundle install without the sudo
ericclemmons Feb 11, 2014
04f8f8a
Echo PATH
ericclemmons Feb 11, 2014
54093a5
bundler !== bundle
ericclemmons Feb 11, 2014
84e7ea2
Remove PATH echo
ericclemmons Feb 11, 2014
d6c98ca
Switch to before_install & rvm
ericclemmons Feb 11, 2014
c8f6a4c
rvm 1.9.3
ericclemmons Feb 11, 2014
5951f28
Copy, not move test project
ericclemmons Feb 11, 2014
7bd30db
Merge branch 'master' into 93-deploy-events
ericclemmons Jun 16, 2014
4b22441
Remove duplicate Gemfile copying
ericclemmons Jun 16, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ node_js:
addons:
hosts:
- local.generatortest.com
install:
before_install:
- rvm use 1.9.3
- gem install bundler
- npm install -g bower
before_script:
- echo "Running from ${PWD}"
- echo "Install NPM dependencies"
- npm install
- ./test/bin/generate
- sudo mv "${PWD}/test/temp" /vagrant
- sudo /vagrant/bin/provision
- echo "Mock test project"
- "${PWD}/test/bin/mock"
- echo "Provision server"
- sudo "${PWD}/test/temp/bin/provision"
- echo "Copy mock project to /vagrant for end-user tests"
- sudo cp -R "${PWD}/test/temp" /vagrant
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ If you get EMFILE issues, try running: `$ ulimit -n 4096`.

### Deployment

Install [Capistrano v2.15.*][5] & [Ansible][7]:
Install [Capistrano v2.15.*][5] via [Bundler][1] & [Ansible][7]:

$ sudo gem install capistrano:2.15 capistrano-ext colored
$ sudo bundle install
$ sudo easy_install pip
$ sudo pip install ansible

Expand Down Expand Up @@ -92,7 +92,7 @@ access the project's *Settings -> Deploy Keys* in Github and add `provisioning/f

Next, assuming the server has been provisioned, deploy your code on Github:

$ cap production deploy
$ bundle exec cap production deploy

The latest code is now live:

Expand All @@ -104,7 +104,7 @@ If you deploy to `staging`, the name of the current branch (e.g. `my-feature`) i

In the rare event the changes weren't supposed to go live, you can rollback to the previous release:

$ cap production deploy:rollback
$ bundle exec cap production deploy:rollback

**Note that deployments use the project's *Github repository* as the source, not your local machine!**

Expand All @@ -118,15 +118,15 @@ a database or uploaded images.

You can **overwrite the remote database** with your local VM's:

$ cap production genesis:up:db
$ bundle exec cap production genesis:up:db

You can sync your local files to the remote filesystem:

$ cap production genesis:up:files
$ bundle exec cap production genesis:up:files

Or, you can perform both actions together:

$ cap production genesis:up
$ bundle exec cap production genesis:up

Once a site is live, you *rarely* need to sync anything up to the remote server. If anything,
you usually sync changes *down*.
Expand All @@ -137,9 +137,9 @@ you usually sync changes *down*.
Suppose you have a live site that you need to work on locally. Like the previous section,
you can sync down the database, the files (e.g. uploaded images), or both:

$ cap production genesis:down:db
$ cap production genesis:down:files
$ cap production genesis:down
$ bundle exec cap production genesis:down:db
$ bundle exec cap production genesis:down:files
$ bundle exec cap production genesis:down


## Provisioning
Expand All @@ -152,11 +152,11 @@ The following environments are expected to exist and resolve via DNS to simplify

If you're deploying to a new machine (e.g. production.mysite.com), you first need to provision it:

$ cap production genesis:provision
$ bundle exec cap production genesis:provision

If there is an error, you may be prompted to re-run the command with an explicit username/password:

$ cap production genesis:provision -S user=myuser -S password=mypassword
$ bundle exec cap production genesis:provision -S user=myuser -S password=mypassword

*From that point on, tasks will use a private key (`provisioning/files/ssh/id_rsa`).*

Expand All @@ -167,14 +167,14 @@ migrate the old server to a new server:
$ vagrant up

# Provision the new server
$ cap production provision
$ cap production deploy
$ bundle exec cap production provision
$ bundle exec cap production deploy

# Download the old site to local
$ cap old genesis:down
$ bundle exec cap old genesis:down

# Upload the old site to production
$ cap production genesis:up
$ bundle exec cap production genesis:up

Now you can switch DNS for http://www.mysite.com/ to point to http://production.mysite.com/'s IP!

Expand All @@ -183,7 +183,7 @@ Now you can switch DNS for http://www.mysite.com/ to point to http://production.
Most of the functionality regarding remote servers are handled by custom [Capistrano][5] tasks,
which you can see by running:

$ cap -T genesis
$ bundle exec cap -T genesis
cap genesis:down # Downloads both remote database & syncs remote files into Vagrant
cap genesis:down:db # Downloads remote database into Vagrant
cap genesis:down:files # Downloads remote files to Vagrant
Expand All @@ -201,15 +201,15 @@ which you can see by running:

Now run any one of those commands against an environemnt:

$ cap local genesis:restart
$ bundle exec cap local genesis:restart

## Troubleshooting

### SSH - Prompting for a password

If you're seeing this:

$ cap staging genesis:ssh
$ bundle exec cap staging genesis:ssh
deploy@staging.example.com's password:

Then the `deploy` user's ssh keys on your remote server *do not match* the keys in your local repository.
Expand All @@ -218,17 +218,17 @@ You should first ensure that your local repository is up to date, thereby ensuri

$ git checkout master
$ git pull origin master
$ cap staging genesis:ssh
$ bundle exec cap staging genesis:ssh

If the problem persists, this means that the keys on your remote server are out of date or otherwise incorrect, and you must re-provision by specifying a username and password:

$ cap staging genesis:provision -S user=userWithRootOrSudoAccess -S password=usersHopefullyStrongPassword
$ bundle exec cap staging genesis:provision -S user=userWithRootOrSudoAccess -S password=usersHopefullyStrongPassword

### SSH - Host key mismatch

If you're seeing this:

$ cap staging genesis:ssh
$ bundle exec cap staging genesis:ssh
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Expand Down Expand Up @@ -402,7 +402,7 @@ sudo /Library/StartupItems/VirtualBox/VirtualBox restart
[7]: http://www.ansibleworks.com/
[8]: https://www.virtualbox.org/
[9]: http://nodejs.org/

[10]: http://bundler.io/

[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/genesis/wordpress/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

22 changes: 22 additions & 0 deletions generator/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,26 @@ WordpressGenerator.prototype.setupDeployment = function() {
this.template('deployment/stages/production.rb', 'deployment/stages/production.rb');
};

WordpressGenerator.prototype.installGems = function() {
var done = this.async();
var installer = 'bundle';

this.log.info(chalk.green('Installing Gems...'));

this.emit(installer + 'Install');

this
.spawnCommand(installer, ['install'], done)
.on('error', done)
.on('exit', this.emit.bind(this, installer + 'Install:end'))
.on('exit', function (err) {
if (err === 127) {
this.log.error('Could not run bundler. Please install with `sudo ' + installer + ' install`.');
}

done(err);
}.bind(this))
;
};

module.exports = WordpressGenerator;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"zombie": "~2.0.0-alpha24"
},
"scripts": {
"test": "mocha --reporter spec"
"test": "./test/bin/test"
},
"repository": {
"type": "git",
Expand Down
16 changes: 12 additions & 4 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $ npm install
Generate test project scaffolding:

```shell
$ ./test/bin/generate
$ ./test/bin/mock
```

### Testing Provisioning
Expand All @@ -24,12 +24,20 @@ Start test project server:
$ (cd test/temp && vagrant up)
```

Tests will be ran against:
### End-User Testing

> http://local.generatortest.com
Install Gems:

### End-User Testing
```shell
$ (cd test/temp && sudo bundle install)
```

Run tests:

```shell
$ npm test
```

Tests will be ran against:

> http://local.generatortest.com
2 changes: 1 addition & 1 deletion test/bin/generate → test/bin/mock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

var Generator = require('../support/generator');
var Generator = require('../support/mock-generator');
var generator = new Generator();

generator.run();
22 changes: 22 additions & 0 deletions test/bin/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env node

var fs = require('fs');
var Mocha = require('mocha');
var mocha = new Mocha();
var testDir = __dirname + '/../';

// Setup environment first
mocha.addFile(testDir + '/support/bootstrap.js');

// Add all other tests
fs.readdirSync(testDir).filter(function(file) {
return '.js' === file.substr(-3);
}).forEach(function(file) {
mocha.addFile(testDir + file);
});

mocha
.reporter('spec')
.ui('bdd')
.run(process.exit)
;
17 changes: 17 additions & 0 deletions test/cap.genesis.deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

var assert = require('assert');
var exec = require('child_process').exec;

describe('bundle exec cap local deploy', function(done) {
this.timeout(0);

it('should not fail', function(done) {
exec('bundle exec cap local deploy', {
cwd: __dirname + '/temp'
}, function(err, stdout, stderr) {
assert.ifError(err);
done();
});
});
});
40 changes: 19 additions & 21 deletions test/generator.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
'use strict';

var assert = require('assert');
var Browser = require('zombie');
var fs = require('fs');
var path = require('path');

describe('Genesis WordPress', function () {
describe('generator', function() {
it('should create required files', function(done) {
[
'bin/provision',
'deployment/deploy.rb',
'provisioning/provision.yml',
'provisioning/files/ssh/id_rsa',
'provisioning/files/ssh/id_rsa.pub',
'web/wp-config.php',
'bower.json',
'Capfile',
'README.md',
'Vagrantfile',
].forEach(function(file) {
var filePath = path.join(__dirname, 'temp', file);
describe('Generator', function() {
it('should create required files', function(done) {
[
'bin/provision',
'deployment/deploy.rb',
'provisioning/provision.yml',
'provisioning/files/ssh/id_rsa',
'provisioning/files/ssh/id_rsa.pub',
'web/wp-config.php',
'bower.json',
'Capfile',
'Gemfile',
'README.md',
'Vagrantfile',
].forEach(function(file) {
var filePath = path.join(__dirname, 'temp', file);

assert.ok(fs.existsSync(filePath), 'File not created: ' + filePath);
});

done();
assert.ok(fs.existsSync(filePath), 'File not created: ' + filePath);
});

done();
});
});
47 changes: 0 additions & 47 deletions test/site.install.js

This file was deleted.

Loading