Skip to content

Commit 428fd24

Browse files
committed
add addons, fixes #4
1 parent 1195f06 commit 428fd24

File tree

6 files changed

+129
-2
lines changed

6 files changed

+129
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ end
4343

4444
## What is missing?
4545

46-
* Full definition of current .travis.yml format
46+
* High level API for dealing with secure values
4747
* Serialization
4848

4949
## Defining Structure

SPEC.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,63 @@ Here is a list of all the options understood by travis-yaml.
44
Note that stricitly speaking Travis CI might not have the same understanding of these as travis-yaml has at the moment, since travis-yaml is not yet being used.
55

66
### Available Options
7+
#### `addons`
8+
**Expected format:** Key value mapping.
9+
10+
#### `addons.code_climate`
11+
**Expected format:** Key value mapping.
12+
13+
#### `addons.code_climate.repo_token`
14+
**Expected format:** String or encrypted string.
15+
16+
#### `addons.coverty_scan`
17+
**Expected format:** Key value mapping.
18+
19+
#### `addons.coverty_scan.branch_pattern`
20+
**Expected format:** String or encrypted string.
21+
22+
#### `addons.coverty_scan.build_command`
23+
**Expected format:** String or encrypted string.
24+
25+
#### `addons.coverty_scan.build_command_prepend`
26+
**Expected format:** String or encrypted string.
27+
28+
#### `addons.coverty_scan.build_script_url`
29+
**Expected format:** String or encrypted string.
30+
31+
#### `addons.coverty_scan.notification_email`
32+
**Expected format:** String or encrypted string.
33+
34+
#### `addons.coverty_scan.project`
35+
**Expected format:** Key value mapping.
36+
37+
#### `addons.coverty_scan.project.name`
38+
**This setting is required!**
39+
40+
**Expected format:** String or encrypted string.
41+
42+
#### `addons.firefox`
43+
`firefox` version to use.
44+
45+
**Expected format:** String.
46+
47+
#### `addons.hosts`
48+
**Expected format:** List of strings; or a single string.
49+
50+
#### `addons.postgresql`
51+
`postgresql` version to use.
52+
53+
**Expected format:** String.
54+
55+
#### `addons.sauce_connect`
56+
**Expected format:** Key value mapping.
57+
58+
#### `addons.sauce_connect.access_key`
59+
**Expected format:** String or encrypted string.
60+
61+
#### `addons.sauce_connect.username`
62+
**Expected format:** String or encrypted string.
63+
764
#### `after_deploy`
865
Commands that will be run on the VM.
966

lib/travis/yaml/nodes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def self.[](key)
3535
require 'travis/yaml/nodes/notifications'
3636
require 'travis/yaml/nodes/branches'
3737
require 'travis/yaml/nodes/cache'
38+
require 'travis/yaml/nodes/addons'
3839
require 'travis/yaml/nodes/root'
3940
end
4041
end

lib/travis/yaml/nodes/addons.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module Travis::Yaml
2+
module Nodes
3+
class Addons < Mapping
4+
class Addon < Mapping
5+
def self.[](*keys)
6+
Class.new(self) { map(*keys, to: Scalar[:str, :secure])}
7+
end
8+
9+
def visit_scalar(visitor, type, value, implicit = true)
10+
return super unless type == :bool
11+
end
12+
end
13+
14+
class CovertyScan < Addon
15+
class Project < Mapping
16+
map :name, to: Scalar[:str, :secure], required: true
17+
end
18+
19+
map :project, to: Project
20+
map :build_script_url, :branch_pattern, :notification_email, :build_command,
21+
:build_command_prepend, to: Scalar[:str, :secure]
22+
end
23+
24+
map :code_climate, to: Addon[:repo_token], drop_empty: false
25+
map :coverty_scan, to: CovertyScan
26+
map :firefox, to: Version
27+
map :hosts, to: Sequence
28+
map :postgresql, to: Version
29+
map :sauce_connect, to: Addon[:username, :access_key], drop_empty: false
30+
end
31+
end
32+
end

lib/travis/yaml/nodes/root.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Root < Mapping
55

66
map :language, required: true
77
map :bundler_args, to: BundlerArgs
8-
map :deploy, :ruby, :os, :compiler, :git, :jdk, :virtualenv, :matrix, :env, :notifications, :branches, :cache
8+
map :deploy, :ruby, :os, :compiler, :git, :jdk, :virtualenv, :matrix, :env, :notifications, :branches, :cache, :addons
99
map :lein, :otp_release, :go, :ghc, :node_js, :xcode_sdk, :xcode_scheme, :perl, :php, :python, :services, :gemfile, to: VersionList
1010
map :rvm, to: :ruby
1111
map :otp, to: :otp_release

spec/nodes/addons_spec.rb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
describe Travis::Yaml::Nodes::Addons do
2+
context 'from Ruby' do
3+
def addons(input)
4+
Travis::Yaml.parse!(language: 'ruby', addons: input).addons
5+
end
6+
7+
context 'code_climate' do
8+
example { expect(addons(code_climate: true).code_climate).to be == {} }
9+
example { expect(addons(code_climate: { repo_token: "foo" }).code_climate.repo_token).to be == "foo" }
10+
end
11+
12+
context 'coverty_scan' do
13+
example do
14+
config = addons(coverty_scan: { project: { name: :foo } })
15+
expect(config.coverty_scan.project.name).to be == "foo"
16+
end
17+
end
18+
19+
context 'firefox' do
20+
example { expect(addons(firefox: '15').firefox).to be == '15' }
21+
end
22+
23+
context 'hosts' do
24+
example { expect(addons(hosts: 'foo.dev').hosts).to be == ['foo.dev'] }
25+
example { expect(addons(hosts: ['foo.dev', 'bar.dev']).hosts).to be == ['foo.dev', 'bar.dev'] }
26+
end
27+
28+
context 'postgresql' do
29+
example { expect(addons(postgresql: '9.1').postgresql).to be == '9.1' }
30+
end
31+
32+
context 'sauce_connect' do
33+
example { expect(addons(sauce_connect: true).sauce_connect).to be == {} }
34+
example { expect(addons(sauce_connect: { username: "foo" }).sauce_connect.username).to be == "foo" }
35+
end
36+
end
37+
end

0 commit comments

Comments
 (0)