Skip to content

Commit

Permalink
Merge pull request #5 from richdynamix/feature/default-tests-in-stage
Browse files Browse the repository at this point in the history
Feature/default tests in stage
  • Loading branch information
Steven Richardson committed Nov 12, 2015
2 parents 9eb54c6 + a3e8f41 commit 51dcffc
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ By default the `rollback` feature is enabled, you can disabled this for all stag
set :rollback, false
```

## Google Analytics Tracking

The Google Analytics property must be inserted into the `ga_property` in order to log deployments and errors. Simply update your YAML to include this `ga_property: "UA-XXXXXXXX-1"`. To disable the Google Analytics tracking just leave the `ga_property` as empty string i.e. `ga_property: ""` in your YAML.

Since version `0.3.0`, Google Analytics now uses Custom Dimensions as outlined in the [Google Measurement Protocol](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters?hl=en#cd_ "Google Measurement Protocol") documentation. When you define a new custom dimension in Google Analytics you are given a new dimension index. Default accounts have 20 available indexes where as premium accounts have 200. The `ga_custom_1` property is used to define the custom dimension for the testname and `ga_custom_2` is used to define the Jira tickets*. If you do not set the `ga_custom_1` or `ga_custom_2` properties then the default index of `1` & `2` will be used.
Expand Down Expand Up @@ -108,6 +110,19 @@ Run a multiple suites when deploying to staging -

$ cap staging deploy -s gisuite=aboutpage,suite2

#### Run Default Tests

Since version `0.4.0`you can now set your default tests/suites to run in each stage. e.g. you might want to run a certain test suite in `production` only but have other tests running in `staging`. You can now set this in your `stage.rb` file using two new flags.

i.e `production.rb` might look like this -
```ruby
set :gi_default_suite, "home"
```
and your `staging.rb` file might have the following -
```ruby
set :gi_default_test, "blog,checkout"
```
As you can see the two new variables `gi_default_suite` and `gi_default_test` can also take a comma separated list to run.

## Contributing

Expand Down
8 changes: 6 additions & 2 deletions lib/capistrano/ghostinspector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ def self.load_into(config)
set :gitest, fetch(:gitest, nil)
set :gisuite, fetch(:gisuite, nil)

# Get any default tests that have been set on the stage
set :gi_default_test, fetch(:gi_default_test, nil)
set :gi_default_suite, fetch(:gi_default_suite, nil)

# Check if GI is enabled for this deployment (Default: true)
set :gi_enabled, fetch(:gi_enabled, gi_config['gi_enabled'])

Expand All @@ -61,7 +65,7 @@ def self.load_into(config)

@collection = Array.new
# run each test
Capistrano::Ghostinspector.getTests(fetch(:gitest), gi_config["tests"]).each do |test|
Capistrano::Ghostinspector.getTests(fetch(:gitest), gi_config["tests"], fetch(:gi_default_test)).each do |test|
puts "* * * Running Ghost Inspector Test * * *"
set :data, giApi.executeApi("tests", test)

Expand All @@ -70,7 +74,7 @@ def self.load_into(config)
end

# run each suite
Capistrano::Ghostinspector.getTests(fetch(:gisuite), gi_config["suites"]).each do |suite|
Capistrano::Ghostinspector.getTests(fetch(:gisuite), gi_config["suites"], fetch(:gi_default_suite)).each do |suite|
puts "* * * Running Ghost Inspector Suite * * *"
set :data, giApi.executeApi("suites", suite)

Expand Down
15 changes: 14 additions & 1 deletion lib/capistrano/ghostinspector/arrays.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Capistrano
module Ghostinspector
def self.getTests(test, giconfig)
def self.getTests(test, giconfig, default)

# Return an array of tests/suites to
# run in ghost inspector
Expand All @@ -13,6 +13,19 @@ def self.getTests(test, giconfig)
end
end

# add any default tests or suites set by the stage
if (default != nil)
default.split(',').each do |key|
if (giconfig.has_key?(key))
if(array.include?(giconfig[key]))
# do nothing, it already exists
else
array << giconfig[key]
end
end
end
end

return array

end
Expand Down
2 changes: 1 addition & 1 deletion lib/capistrano/ghostinspector/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Capistrano
module Ghostinspector
VERSION = "0.3.0"
VERSION = "0.4.0"
end
end

0 comments on commit 51dcffc

Please sign in to comment.