Module: Travis::Yml

Extended by:
Memoize
Defined in:
lib/travis/yml.rb,
lib/travis/yml/doc.rb,
lib/travis/yml/web.rb,
lib/travis/yml/docs.rb,
lib/travis/yml/parts.rb,
lib/travis/yml/config.rb,
lib/travis/yml/errors.rb,
lib/travis/yml/matrix.rb,
lib/travis/yml/schema.rb,
lib/travis/yml/configs.rb,
lib/travis/yml/version.rb,
lib/travis/yml/web/auth.rb,
lib/travis/yml/web/docs.rb,
lib/travis/yml/doc/value.rb,
lib/travis/yml/docs/page.rb,
lib/travis/yml/web/parse.rb,
lib/travis/yml/doc/change.rb,
lib/travis/yml/doc/schema.rb,
lib/travis/yml/helper/obj.rb,
lib/travis/yml/matrix/env.rb,
lib/travis/yml/parts/part.rb,
lib/travis/yml/web/expand.rb,
lib/travis/yml/web/sentry.rb,
lib/travis/yml/web/static.rb,
lib/travis/yml/configs/ctx.rb,
lib/travis/yml/configs/ref.rb,
lib/travis/yml/helper/lock.rb,
lib/travis/yml/parts/merge.rb,
lib/travis/yml/parts/parse.rb,
lib/travis/yml/web/configs.rb,
lib/travis/yml/web/helpers.rb,
lib/travis/yml/web/metrics.rb,
lib/travis/yml/configs/msgs.rb,
lib/travis/yml/doc/validate.rb,
lib/travis/yml/configs/fetch.rb,
lib/travis/yml/doc/value/map.rb,
lib/travis/yml/doc/value/num.rb,
lib/travis/yml/doc/value/seq.rb,
lib/travis/yml/doc/value/str.rb,
lib/travis/yml/docs/page/any.rb,
lib/travis/yml/docs/page/map.rb,
lib/travis/yml/docs/page/seq.rb,
lib/travis/yml/matrix/expand.rb,
lib/travis/yml/schema/def/os.rb,
lib/travis/yml/support/merge.rb,
lib/travis/yml/configs/errors.rb,
lib/travis/yml/configs/filter.rb,
lib/travis/yml/configs/stages.rb,
lib/travis/yml/doc/change/key.rb,
lib/travis/yml/doc/schema/any.rb,
lib/travis/yml/doc/schema/map.rb,
lib/travis/yml/doc/schema/num.rb,
lib/travis/yml/doc/schema/seq.rb,
lib/travis/yml/doc/schema/str.rb,
lib/travis/yml/doc/value/bool.rb,
lib/travis/yml/doc/value/node.rb,
lib/travis/yml/doc/value/none.rb,
lib/travis/yml/docs/page/base.rb,
lib/travis/yml/docs/page/lang.rb,
lib/travis/yml/docs/page/menu.rb,
lib/travis/yml/docs/page/tree.rb,
lib/travis/yml/helper/metrics.rb,
lib/travis/yml/matrix/exclude.rb,
lib/travis/yml/matrix/support.rb,
lib/travis/yml/schema/def/env.rb,
lib/travis/yml/schema/def/git.rb,
lib/travis/yml/schema/def/job.rb,
lib/travis/yml/configs/configs.rb,
lib/travis/yml/configs/reorder.rb,
lib/travis/yml/doc/change/base.rb,
lib/travis/yml/doc/change/cast.rb,
lib/travis/yml/doc/change/keys.rb,
lib/travis/yml/doc/change/pick.rb,
lib/travis/yml/doc/change/wrap.rb,
lib/travis/yml/doc/helper/cast.rb,
lib/travis/yml/doc/helper/dict.rb,
lib/travis/yml/doc/schema/bool.rb,
lib/travis/yml/doc/schema/node.rb,
lib/travis/yml/doc/schema/none.rb,
lib/travis/yml/docs/page/index.rb,
lib/travis/yml/docs/schema/any.rb,
lib/travis/yml/docs/schema/map.rb,
lib/travis/yml/docs/schema/seq.rb,
lib/travis/yml/schema/def/arch.rb,
lib/travis/yml/schema/def/dist.rb,
lib/travis/yml/schema/def/jobs.rb,
lib/travis/yml/schema/def/root.rb,
lib/travis/yml/schema/def/sudo.rb,
lib/travis/yml/schema/def/virt.rb,
lib/travis/yml/schema/json/map.rb,
lib/travis/yml/schema/json/ref.rb,
lib/travis/yml/schema/json/seq.rb,
lib/travis/yml/schema/type/map.rb,
lib/travis/yml/schema/type/ref.rb,
lib/travis/yml/doc/change/cache.rb,
lib/travis/yml/doc/change/value.rb,
lib/travis/yml/doc/helper/match.rb,
lib/travis/yml/doc/value/scalar.rb,
lib/travis/yml/doc/value/secure.rb,
lib/travis/yml/docs/page/deploy.rb,
lib/travis/yml/docs/page/render.rb,
lib/travis/yml/docs/page/scalar.rb,
lib/travis/yml/docs/page/static.rb,
lib/travis/yml/docs/schema/node.rb,
lib/travis/yml/helper/condition.rb,
lib/travis/yml/schema/def/cache.rb,
lib/travis/yml/schema/def/group.rb,
lib/travis/yml/schema/def/stack.rb,
lib/travis/yml/schema/json/node.rb,
lib/travis/yml/schema/type/dump.rb,
lib/travis/yml/schema/type/form.rb,
lib/travis/yml/schema/type/lang.rb,
lib/travis/yml/schema/type/node.rb,
lib/travis/yml/schema/type/opts.rb,
lib/travis/yml/web/parse/config.rb,
lib/travis/yml/configs/model/job.rb,
lib/travis/yml/configs/model/key.rb,
lib/travis/yml/doc/change/enable.rb,
lib/travis/yml/doc/change/prefix.rb,
lib/travis/yml/doc/schema/scalar.rb,
lib/travis/yml/doc/schema/secure.rb,
lib/travis/yml/doc/schema/select.rb,
lib/travis/yml/doc/schema/values.rb,
lib/travis/yml/doc/validate/base.rb,
lib/travis/yml/doc/value/factory.rb,
lib/travis/yml/doc/value/support.rb,
lib/travis/yml/docs/examples/map.rb,
lib/travis/yml/docs/examples/ref.rb,
lib/travis/yml/helper/instrument.rb,
lib/travis/yml/schema/def/addons.rb,
lib/travis/yml/schema/def/deploy.rb,
lib/travis/yml/schema/def/lang/c.rb,
lib/travis/yml/schema/def/lang/d.rb,
lib/travis/yml/schema/def/lang/r.rb,
lib/travis/yml/schema/def/stages.rb,
lib/travis/yml/schema/json/group.rb,
lib/travis/yml/schema/type/group.rb,
lib/travis/yml/configs/config/api.rb,
lib/travis/yml/configs/model/repo.rb,
lib/travis/yml/doc/change/flatten.rb,
lib/travis/yml/doc/change/inherit.rb,
lib/travis/yml/doc/schema/factory.rb,
lib/travis/yml/doc/validate/alert.rb,
lib/travis/yml/doc/validate/empty.rb,
lib/travis/yml/doc/validate/flags.rb,
lib/travis/yml/docs/examples/node.rb,
lib/travis/yml/docs/schema/scalar.rb,
lib/travis/yml/docs/schema/secure.rb,
lib/travis/yml/schema/def/imports.rb,
lib/travis/yml/schema/def/lang/go.rb,
lib/travis/yml/schema/def/version.rb,
lib/travis/yml/schema/json/scalar.rb,
lib/travis/yml/schema/json/schema.rb,
lib/travis/yml/schema/type/export.rb,
lib/travis/yml/schema/type/scalar.rb,
lib/travis/yml/configs/config/base.rb,
lib/travis/yml/configs/config/file.rb,
lib/travis/yml/configs/filter/jobs.rb,
lib/travis/yml/configs/model/repos.rb,
lib/travis/yml/configs/model/stage.rb,
lib/travis/yml/configs/travis/repo.rb,
lib/travis/yml/doc/change/downcase.rb,
lib/travis/yml/doc/change/env_vars.rb,
lib/travis/yml/doc/validate/format.rb,
lib/travis/yml/doc/validate/unique.rb,
lib/travis/yml/docs/examples/group.rb,
lib/travis/yml/docs/schema/factory.rb,
lib/travis/yml/schema/def/branches.rb,
lib/travis/yml/schema/def/lang/cpp.rb,
lib/travis/yml/schema/def/lang/elm.rb,
lib/travis/yml/schema/def/lang/nix.rb,
lib/travis/yml/schema/def/lang/php.rb,
lib/travis/yml/schema/def/language.rb,
lib/travis/yml/schema/def/services.rb,
lib/travis/yml/configs/github/error.rb,
lib/travis/yml/configs/model/config.rb,
lib/travis/yml/configs/travis/error.rb,
lib/travis/yml/doc/validate/compact.rb,
lib/travis/yml/doc/validate/default.rb,
lib/travis/yml/doc/validate/version.rb,
lib/travis/yml/docs/examples/scalar.rb,
lib/travis/yml/schema/def/addon/apt.rb,
lib/travis/yml/schema/def/addon/pkg.rb,
lib/travis/yml/schema/def/compilers.rb,
lib/travis/yml/schema/def/deploy/s3.rb,
lib/travis/yml/schema/def/lang/dart.rb,
lib/travis/yml/schema/def/lang/hack.rb,
lib/travis/yml/schema/def/lang/haxe.rb,
lib/travis/yml/schema/def/lang/java.rb,
lib/travis/yml/schema/def/lang/jdks.rb,
lib/travis/yml/schema/def/lang/perl.rb,
lib/travis/yml/schema/def/lang/ruby.rb,
lib/travis/yml/schema/def/lang/rust.rb,
lib/travis/yml/schema/def/osx_image.rb,
lib/travis/yml/configs/github/client.rb,
lib/travis/yml/configs/travis/client.rb,
lib/travis/yml/doc/validate/required.rb,
lib/travis/yml/doc/validate/template.rb,
lib/travis/yml/schema/def/addon/jwts.rb,
lib/travis/yml/schema/def/conditions.rb,
lib/travis/yml/schema/def/deploy/gae.rb,
lib/travis/yml/schema/def/deploy/gcs.rb,
lib/travis/yml/schema/def/deploy/npm.rb,
lib/travis/yml/schema/def/lang/julia.rb,
lib/travis/yml/schema/def/lang/perl6.rb,
lib/travis/yml/schema/def/lang/scala.rb,
lib/travis/yml/schema/def/lang/shell.rb,
lib/travis/yml/configs/allow_failures.rb,
lib/travis/yml/configs/github/content.rb,
lib/travis/yml/doc/validate/condition.rb,
lib/travis/yml/schema/def/addon/snaps.rb,
lib/travis/yml/schema/def/deploy/pypi.rb,
lib/travis/yml/schema/def/deploy/snap.rb,
lib/travis/yml/schema/def/lang/csharp.rb,
lib/travis/yml/schema/def/lang/elixir.rb,
lib/travis/yml/schema/def/lang/erlang.rb,
lib/travis/yml/schema/def/lang/groovy.rb,
lib/travis/yml/schema/def/lang/matlab.rb,
lib/travis/yml/schema/def/lang/python.rb,
lib/travis/yml/schema/def/lang/stacks.rb,
lib/travis/yml/schema/def/deploy/cargo.rb,
lib/travis/yml/schema/def/deploy/flynn.rb,
lib/travis/yml/schema/def/deploy/gleis.rb,
lib/travis/yml/schema/def/deploy/hephy.rb,
lib/travis/yml/schema/def/deploy/pages.rb,
lib/travis/yml/schema/def/deploy/surge.rb,
lib/travis/yml/schema/def/lang/android.rb,
lib/travis/yml/schema/def/lang/clojure.rb,
lib/travis/yml/schema/def/lang/crystal.rb,
lib/travis/yml/schema/def/lang/generic.rb,
lib/travis/yml/schema/def/lang/haskell.rb,
lib/travis/yml/schema/def/lang/node_js.rb,
lib/travis/yml/schema/def/notification.rb,
lib/travis/yml/schema/def/deploy/convox.rb,
lib/travis/yml/schema/def/deploy/datica.rb,
lib/travis/yml/schema/def/deploy/heroku.rb,
lib/travis/yml/schema/def/deploy/lambda.rb,
lib/travis/yml/schema/def/deploy/script.rb,
lib/travis/yml/configs/config/travis_yml.rb,
lib/travis/yml/doc/validate/invalid_type.rb,
lib/travis/yml/doc/validate/unknown_keys.rb,
lib/travis/yml/schema/def/addon/homebrew.rb,
lib/travis/yml/schema/def/deploy/bintray.rb,
lib/travis/yml/schema/def/deploy/boxfuse.rb,
lib/travis/yml/schema/def/deploy/cloud66.rb,
lib/travis/yml/schema/def/deploy/hackage.rb,
lib/travis/yml/schema/def/deploy/netlify.rb,
lib/travis/yml/schema/def/lang/smalltalk.rb,
lib/travis/yml/doc/validate/unknown_value.rb,
lib/travis/yml/schema/def/addon/artifacts.rb,
lib/travis/yml/schema/def/deploy/anynines.rb,
lib/travis/yml/schema/def/deploy/catalyze.rb,
lib/travis/yml/schema/def/deploy/firebase.rb,
lib/travis/yml/schema/def/deploy/git_push.rb,
lib/travis/yml/schema/def/deploy/opsworks.rb,
lib/travis/yml/schema/def/deploy/releases.rb,
lib/travis/yml/schema/def/deploy/rubygems.rb,
lib/travis/yml/schema/def/deploy/scalingo.rb,
lib/travis/yml/schema/def/addon/sonarcloud.rb,
lib/travis/yml/schema/def/deploy/launchpad.rb,
lib/travis/yml/schema/def/deploy/openshift.rb,
lib/travis/yml/schema/def/deploy/testfairy.rb,
lib/travis/yml/schema/def/deploy/transifex.rb,
lib/travis/yml/schema/def/lang/objective_c.rb,
lib/travis/yml/schema/def/notification/irc.rb,
lib/travis/yml/configs/filter/notifications.rb,
lib/travis/yml/schema/def/deploy/cloudfiles.rb,
lib/travis/yml/schema/def/deploy/codedeploy.rb,
lib/travis/yml/schema/def/deploy/engineyard.rb,
lib/travis/yml/doc/validate/unsupported_keys.rb,
lib/travis/yml/schema/def/addon/browserstack.rb,
lib/travis/yml/schema/def/addon/code_climate.rb,
lib/travis/yml/schema/def/deploy/puppetforge.rb,
lib/travis/yml/schema/def/notification/email.rb,
lib/travis/yml/schema/def/notification/slack.rb,
lib/travis/yml/doc/validate/unsupported_value.rb,
lib/travis/yml/schema/def/addon/coverity_scan.rb,
lib/travis/yml/schema/def/addon/sauce_connect.rb,
lib/travis/yml/schema/def/deploy/cloudfoundry.rb,
lib/travis/yml/schema/def/deploy/packagecloud.rb,
lib/travis/yml/schema/def/notification/hipchat.rb,
lib/travis/yml/schema/def/deploy/azure_web_apps.rb,
lib/travis/yml/schema/def/deploy/cloudformation.rb,
lib/travis/yml/schema/def/notification/campfire.rb,
lib/travis/yml/schema/def/notification/flowdock.rb,
lib/travis/yml/schema/def/notification/pushover.rb,
lib/travis/yml/schema/def/notification/webhooks.rb,
lib/travis/yml/schema/def/deploy/chef_supermarket.rb,
lib/travis/yml/schema/def/deploy/elasticbeanstalk.rb,
lib/travis/yml/schema/def/deploy/bluemix_cloudfoundry.rb

Defined Under Namespace

Modules: Configs, Doc, Docs, Helper, Instrument, Parts, Schema, Support, Web Classes: Condition, Config, Error, InputError, InternalError, InvalidCondition, InvalidConfigFormat, Lock, Match, Matrix, MemoizedArgs, Msgs, ParseError, StackTooHigh, UnexpectedParentType, UnexpectedValue, UnknownMessage

Constant Summary collapse

DEFAULTS =
{
  language: 'ruby',
  os:       'linux'
}
OPTS =

These exist so we can parametrize things a little for testing (e.g. so tests don't break elsewhere just because a default has changed here).

{
  alert:    true,   # alert on secures that accept a string
  defaults: true,   # add defaults to required keys
  empty:    false,  # warn on empty keys
  fix:      true,   # try fixing unknown keys and values
  line:     true,   # add line numbers to messages
  support:  false,  # warn about features unsupported on the given language, os etc
  drop:     false,  # drop unknown keys and values, invalid conditions, and values missing required keys
  merge_normalized: false # whether to normalize configs before merging
}
MSGS =

These are meant as examples. Clients will want to determine their own representations.

{
  alias_key:          'the key %{alias} is an alias for %{key}, using %{key}',
  alias_value:        'the value %{alias} is an alias for %{value}, using %{value}',
  overwrite:          'both %{key} and %{other} given. %{key} overwrites %{other}',
  default:            'missing %{key}, using the default %<default>p',
  deprecated:         'deprecated: %{info}',
  deprecated_key:     'deprecated key: %<key>p (%{info})',
  deprecated_value:   'deprecated value: %<value>p (%{info})',
  downcase:           'using lower case of %{value}',
  duplicate:          'duplicate values: %{values}',
  duplicate_key:      'duplicate key: %{key}',
  edge:               'this key is experimental and might change or be removed',
  flagged:            'please email [email protected] to enable %<key>p',
  required:           'missing required key: %{key}',
  secure:             'expected an encrypted string',
  empty:              'dropping empty key: %{key}',
  find_key:           'key %{original} is not known, but %{key} is, using %{key}',
  find_value:         'value %{original} is not known, but %{value} is, using %{value}',
  clean_key:          'key %{original} contains unsupported characters, using %{key}',
  clean_value:        'value %{original} is not known, but %{value} is, using %{value}',
  strip_key:          'key %{original} contains whitespace, using %{key}',
  underscore_key:     'key %{original} is not underscored, using %{key}',
  unexpected_seq:     'unexpected sequence, using the first value (%{value})',
  unknown_key:        'unknown key %<key>p (%{value})',
  unknown_value:      'dropping unknown value: %{value}',
  unknown_var:        'unknown template variable %<var>p',
  unsupported:        '%{key} (%{value}) is not supported on %{on_key} %{on_value}',
  invalid_type:       'dropping unexpected %{actual}, expected %{expected} (%{value})',
  invalid_secure:     'invalid value on secure string: %{value}',
  invalid_format:     'dropping invalid format %{value}',
  invalid_condition:  'invalid condition: %{condition} (%{message})',
  invalid_env_var:    'invalid env var: %{var}',
  invalid_ref:        'invalid import reference: %s',
  skip_allow_failure: 'skipping jobs allow failure rule #%{number} because its condition does not match: %{condition}',
  skip_exclude:       'skipping jobs exclude rule #%{number} because its condition does not match: %{condition}',
  skip_import:        'skipping import %{source} because its condition does not match: %{condition}',
  skip_job:           'skipping job #%{number} because its condition does not match: %{condition}',
  skip_notification:  'skipping notification %{type} #%{number}, condition does not match: %{condition}',
  skip_stage:         'skipping stage #%{number} because its condition does not match: %{condition}',
  invalid_ownership:  'Cannot import a private config file from another owner (%s)',
  invalid_visibility: 'Private repo %s referenced from a public repo',
  import_not_allowed: 'importing from private repo %{repo} is not allowed as per its settings',
  too_many_imports:   'Too many imports, max: %{max}',
  unknown_import:     'import not found: %{source}'
}
VERSION =

version of this gem

'1.0.0'
SPEC_VERSION =

version of the specification (what is specified)

'1.0.0'
SCHEMA_VERSION =

version of the JSON Schema format (how it is specified)

'0.0.1'

Class Method Summary collapse

Class Method Details

.apply(value, opts = {}) ⇒ Object


125
126
127
128
129
130
# File 'lib/travis/yml.rb', line 125

def apply(value, opts = {})
  invalid_format unless value.is_a?(Hash)
  opts = OPTS.merge(opts) unless ENV['ENV'] == 'test'
  node = Doc.apply(expand, value, opts)
  node
end

.bench(key = nil) ⇒ Object


194
195
196
197
198
199
# File 'lib/travis/yml.rb', line 194

def bench(key = nil)
  now = Time.now
  yield.tap do
    puts "Schema.#{(key || caller[2][/`(.*)'/] && $1).to_s.ljust(6)} took #{Time.now - now} sec"
  end
end

.configObject


99
100
101
# File 'lib/travis/yml.rb', line 99

def config
  @config ||= Config.load
end

.configs(*args) ⇒ Object


137
138
139
# File 'lib/travis/yml.rb', line 137

def configs(*args)
  Configs.new(*args)
end

.expandObject


111
112
113
# File 'lib/travis/yml.rb', line 111

def expand
  bench { Doc::Schema.build(schema) }
end

.expand_keysObject


186
187
188
# File 'lib/travis/yml.rb', line 186

def expand_keys
  expand.expand_keys - [:jobs] # TODO
end

.invalid_formatObject


190
191
192
# File 'lib/travis/yml.rb', line 190

def invalid_format
  raise InvalidConfigFormat, 'Input must parse into a hash'
end

.keysObject


154
155
156
# File 'lib/travis/yml.rb', line 154

def keys
  @keys ||= expand.all_keys - r_keys
end

.load(parts, opts = {}) ⇒ Object


107
108
109
# File 'lib/travis/yml.rb', line 107

def load(parts, opts = {})
  apply(Parts.load(parts), opts)
end

.loggerObject


103
104
105
# File 'lib/travis/yml.rb', line 103

def logger
  @logger ||= Logger.new($stdout)
end

.matrix(config) ⇒ Object


132
133
134
135
# File 'lib/travis/yml.rb', line 132

def matrix(config)
  config, data = config.values_at(:config, :data) if config[:config]
  Matrix.new(config, data)
end

.metricsObject


95
96
97
# File 'lib/travis/yml.rb', line 95

def metrics
  @metrics ||= Travis::Metrics.setup(config.metrics.to_h, logger)
end

.msg(msg) ⇒ Object


141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/travis/yml.rb', line 141

def msg(msg)
  level, key, code, args = msg
  msg = MSGS[code] || raise(UnknownMessage, 'Unknown message %p' % code)
  msg = msg % args if args
  msg = '[%s] on %s: %s' % [level, key, msg]
  msg = msg.sub('()', '')
  msg
rescue KeyError => e
  msg = "unable to generate message (level: %s, key: %s, code: %s, args: %s)" % [level, key, code, args]
  Raven.capture_message(msg) if defined?(Raven)
  msg
end

.r_keysObject

R's known keys on root should definitely be reduced


159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/travis/yml.rb', line 159

def r_keys
  %w(
    r_packages
    r_binary_packages
    r_github_packages
    apt_packages
    bioc_packages
    brew_packages
    bioc
    bioc_check
    bioc_required
    bioc_use_devel
    cran
    disable_homebrew
    latex
    pandoc
    pandoc_version
    r_build_args
    r_check_args
    r_check_revdep
    warnings_are_errors
    remotes
    repos
  )
end

.schemaObject


116
117
118
# File 'lib/travis/yml.rb', line 116

def schema
  Schema.json
end

.writeObject


121
122
123
# File 'lib/travis/yml.rb', line 121

def write
  File.write('schema.json', JSON.pretty_generate(schema))
end