Properly display matrix keys when build does not have all keys
When additional items are included into matrix via 'matrix.include' key in .travis.yml they may contain config keys, which are not available on build. For example build can contain only 'rvm' key, but we may add the following include: matrix: include: - rvm: '2.0.0' env: 'FOO=bar' In such case, we need to take into account also keys from additional job, not only from the build. (closes #172)
This commit is contained in:
parent
8a69df0126
commit
c7561ee13e
|
@ -91,3 +91,6 @@ require 'config/emoij'
|
|||
_escape: (text) ->
|
||||
text.replace(/&/g, '&').replace(/</g, '<').replace />/g, '>'
|
||||
|
||||
configKeys: (config) ->
|
||||
return [] unless config
|
||||
$.intersect($.keys(config), Travis.CONFIG_KEYS)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'travis/model'
|
||||
|
||||
@Travis.Branch = Travis.Model.extend Travis.Helpers,
|
||||
@Travis.Branch = Travis.Model.extend
|
||||
repoId: DS.attr('number', key: 'repository_id')
|
||||
commitId: DS.attr('number')
|
||||
state: DS.attr('string')
|
||||
|
|
|
@ -45,12 +45,21 @@ require 'travis/model'
|
|||
@get('jobs').filter (data) -> data.get('allowFailure')
|
||||
).property('jobs.@each.allowFailure')
|
||||
|
||||
rawConfigKeys: (->
|
||||
keys = Travis.Helpers.configKeys(@get('config'))
|
||||
|
||||
@get('jobs').forEach (job) ->
|
||||
Travis.Helpers.configKeys(job.get('config')).forEach (key) ->
|
||||
keys.pushObject key unless keys.contains key
|
||||
|
||||
keys
|
||||
).property('config', 'jobs.@each.config')
|
||||
|
||||
configKeys: (->
|
||||
return [] unless config = @get('config')
|
||||
keys = $.intersect($.keys(config), Travis.CONFIG_KEYS)
|
||||
keys = @get('rawConfigKeys')
|
||||
headers = (I18n.t(key) for key in ['build.job', 'build.duration', 'build.finished_at'])
|
||||
$.map(headers.concat(keys), (key) -> return $.camelize(key))
|
||||
).property('config')
|
||||
).property('rawConfigKeys.length')
|
||||
|
||||
canCancel: (->
|
||||
@get('state') == 'created' # TODO
|
||||
|
|
|
@ -61,14 +61,14 @@ require 'travis/model'
|
|||
).property('log.workerName')
|
||||
|
||||
configValues: (->
|
||||
config = @get('config')
|
||||
buildConfig = @get('build.config')
|
||||
if config && buildConfig
|
||||
keys = $.intersect($.keys(buildConfig), Travis.CONFIG_KEYS)
|
||||
config = @get('config')
|
||||
keys = @get('build.rawConfigKeys')
|
||||
|
||||
if config && keys
|
||||
keys.map (key) -> config[key]
|
||||
else
|
||||
[]
|
||||
).property('config')
|
||||
).property('config', 'build.rawConfigKeys.length')
|
||||
|
||||
canCancel: (->
|
||||
@get('state') == 'created' || @get('state') == 'queued' # TODO
|
||||
|
|
|
@ -30,3 +30,17 @@ describe 'Travis.Build', ->
|
|||
waits 50
|
||||
runs ->
|
||||
expect( record.get('incomplete') ).toBeFalsy()
|
||||
|
||||
describe 'configKeys', ->
|
||||
it 'takes into account all the jobs when getting config keys', ->
|
||||
buildConfig = { rvm: ['1.9.3', '2.0.0'] }
|
||||
store.load Travis.Build, { id: '1', job_ids: ['1', '2', '3'], config: buildConfig }, { id: '1' }
|
||||
|
||||
store.load Travis.Job, { id: '1', config: { rvm: '1.9.3', env: 'FOO=foo' } }, { id: '1' }
|
||||
store.load Travis.Job, { id: '2', config: { rvm: '2.0.0', gemfile: 'Gemfile.1' } }, { id: '2' }
|
||||
store.load Travis.Job, { id: '3', config: { rvm: '1.9.3', jdk: 'OpenJDK' } }, { id: '3' }
|
||||
|
||||
build = store.find(Travis.Build, '1')
|
||||
|
||||
expect( build.get('rawConfigKeys') ).toEqual( ['rvm', 'env', 'gemfile', 'jdk' ] )
|
||||
expect( build.get('configKeys') ).toEqual( [ 'Job', 'Duration', 'Finished', 'Rvm', 'Env', 'Gemfile', 'Jdk' ] )
|
||||
|
|
|
@ -8,6 +8,23 @@ describe 'Travis.Job', ->
|
|||
afterEach ->
|
||||
store.destroy()
|
||||
|
||||
describe 'configKeys', ->
|
||||
it 'takes into account the keys of other jobs', ->
|
||||
buildConfig = { rvm: ['1.9.3', '2.0.0'] }
|
||||
store.load Travis.Build, { id: '1', job_ids: ['1', '2', '3'], config: buildConfig }, { id: '1' }
|
||||
|
||||
store.load Travis.Job, { id: '1', config: { rvm: '1.9.3', env: 'FOO=foo' }, build_id: '1' }, { id: '1' }
|
||||
store.load Travis.Job, { id: '2', config: { rvm: '2.0.0', gemfile: 'Gemfile.1' }, build_id: '1' }, { id: '2' }
|
||||
store.load Travis.Job, { id: '3', config: { rvm: '1.9.3', jdk: 'OpenJDK' }, build_id: '1' }, { id: '3' }
|
||||
|
||||
job1 = store.find(Travis.Job, '1')
|
||||
job2 = store.find(Travis.Job, '2')
|
||||
job3 = store.find(Travis.Job, '3')
|
||||
|
||||
expect( job1.get('configValues') ).toEqual( [ '1.9.3', 'FOO=foo', undefined, undefined ] )
|
||||
expect( job2.get('configValues') ).toEqual( [ '2.0.0', undefined, 'Gemfile.1', undefined ] )
|
||||
expect( job3.get('configValues') ).toEqual( [ '1.9.3', undefined, undefined, 'OpenJDK' ] )
|
||||
|
||||
describe 'incomplete attributes', ->
|
||||
beforeEach ->
|
||||
store.loadIncomplete Travis.Job, { id: 1, state: 'started' }
|
||||
|
|
Loading…
Reference in New Issue
Block a user