Move remaining files from lib/travis to utils
This commit is contained in:
parent
316b43144d
commit
949431b7df
|
@ -1,4 +1,4 @@
|
||||||
require 'travis/validations'
|
require 'utils/validations'
|
||||||
|
|
||||||
Validations = Travis.Validations
|
Validations = Travis.Validations
|
||||||
EnvVar = Travis.EnvVar
|
EnvVar = Travis.EnvVar
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require 'travis/validations'
|
require 'utils/validations'
|
||||||
|
|
||||||
Validations = Travis.Validations
|
Validations = Travis.Validations
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require 'travis/validations'
|
require 'utils/validations'
|
||||||
|
|
||||||
Validations = Travis.Validations
|
Validations = Travis.Validations
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require 'travis/log-chunks'
|
require 'utils/log-chunks'
|
||||||
|
|
||||||
Ajax = Travis.ajax
|
Ajax = Travis.ajax
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require 'travis/location'
|
require 'utils/location'
|
||||||
require 'routes/application'
|
require 'routes/application'
|
||||||
|
|
||||||
config = ENV.config
|
config = ENV.config
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'log'
|
require 'log'
|
||||||
require 'travis/lines-selector'
|
require 'utils/lines-selector'
|
||||||
require 'travis/log-folder'
|
require 'utils/log-folder'
|
||||||
|
|
||||||
Log.DEBUG = false
|
Log.DEBUG = false
|
||||||
Log.LIMIT = 10000
|
Log.LIMIT = 10000
|
||||||
|
|
|
@ -1,96 +0,0 @@
|
||||||
get = Ember.get
|
|
||||||
|
|
||||||
Travis.ChunkBuffer = Em.ArrayProxy.extend
|
|
||||||
timeout: 5000
|
|
||||||
checkTimeoutFrequency: 5000
|
|
||||||
start: 1
|
|
||||||
next: 1
|
|
||||||
|
|
||||||
init: ->
|
|
||||||
@_super.apply this, arguments
|
|
||||||
|
|
||||||
@lastInsert = 0
|
|
||||||
|
|
||||||
@set('next', @get('start'))
|
|
||||||
|
|
||||||
@checkTimeout()
|
|
||||||
|
|
||||||
if @get('content.length')
|
|
||||||
@get('queue.content').pushObjects @get('content').toArray()
|
|
||||||
|
|
||||||
arrangedContent: (->
|
|
||||||
[]
|
|
||||||
).property('content')
|
|
||||||
|
|
||||||
addObject: (obj) ->
|
|
||||||
@get('content').pushObject(obj)
|
|
||||||
|
|
||||||
removeObject: (obj) ->
|
|
||||||
@get('content').removeObject(obj)
|
|
||||||
|
|
||||||
replaceContent: (idx, amt, objects) ->
|
|
||||||
@get('content').replace(idx, amt, objects)
|
|
||||||
|
|
||||||
queue: (->
|
|
||||||
Em.ArrayProxy.extend(Em.SortableMixin, {
|
|
||||||
content: []
|
|
||||||
sortProperties: ['number']
|
|
||||||
sortAscending: true
|
|
||||||
}).create()
|
|
||||||
).property()
|
|
||||||
|
|
||||||
contentArrayDidChange: (array, index, removedCount, addedCount) ->
|
|
||||||
@_super.apply this, arguments
|
|
||||||
|
|
||||||
if addedCount
|
|
||||||
queue = @get('queue')
|
|
||||||
addedObjects = array.slice(index, index + addedCount)
|
|
||||||
console.log 'Added log parts with numbers:', addedObjects.map( (element) -> get(element, 'number') )+'', 'current', @get('next')
|
|
||||||
queue.pushObjects addedObjects
|
|
||||||
@check()
|
|
||||||
|
|
||||||
check: ->
|
|
||||||
queue = @get('queue')
|
|
||||||
next = @get('next')
|
|
||||||
|
|
||||||
arrangedContent = @get('arrangedContent')
|
|
||||||
toPush = []
|
|
||||||
|
|
||||||
while queue.get('firstObject.number') <= next
|
|
||||||
element = queue.shiftObject()
|
|
||||||
if get(element, 'number') == next
|
|
||||||
@finalize() if get(element, 'final')
|
|
||||||
toPush.pushObject get(element, 'content')
|
|
||||||
next += 1
|
|
||||||
|
|
||||||
if toPush.length
|
|
||||||
arrangedContent.pushObjects toPush
|
|
||||||
@inserted()
|
|
||||||
|
|
||||||
@set('next', next)
|
|
||||||
|
|
||||||
inserted: ->
|
|
||||||
now = @now()
|
|
||||||
@lastInsert = now
|
|
||||||
|
|
||||||
finalize: ->
|
|
||||||
clearTimeout @get('runLaterId')
|
|
||||||
|
|
||||||
checkTimeout: ->
|
|
||||||
now = @now()
|
|
||||||
if now - @lastInsert > @get('timeout')
|
|
||||||
@giveUpOnMissingParts()
|
|
||||||
@set 'runLaterId', setTimeout((=> @checkTimeout()), @get('checkTimeoutFrequency'))
|
|
||||||
|
|
||||||
willDestroy: ->
|
|
||||||
@finalize()
|
|
||||||
@_super.apply this, arguments
|
|
||||||
|
|
||||||
now: ->
|
|
||||||
(new Date()).getTime()
|
|
||||||
|
|
||||||
giveUpOnMissingParts: ->
|
|
||||||
if number = @get('queue.firstObject.number')
|
|
||||||
console.log 'Giving up on missing parts in the buffer, switching to:', number
|
|
||||||
@set('next', number)
|
|
||||||
@check()
|
|
|
@ -1,8 +0,0 @@
|
||||||
Travis.Instrumentation = {
|
|
||||||
subscribe: (event) ->
|
|
||||||
Em.subscribe event,
|
|
||||||
before:(name, timestamp, payload) ->
|
|
||||||
timestamp
|
|
||||||
after: (name, timestamp, payload, start_timestamp) ->
|
|
||||||
console.log(name, payload, timestamp - start_timestamp)
|
|
||||||
}
|
|
|
@ -1,153 +0,0 @@
|
||||||
# TODO: revisit those patterns
|
|
||||||
FOLDS = [
|
|
||||||
Em.Object.create(name: 'schema', startPattern: /^\$ (?:bundle exec )?rake( db:create)? db:schema:load/, endPattern: /^(<\/span>)?\$/)
|
|
||||||
Em.Object.create(name: 'migrate', startPattern: /^\$ (?:bundle exec )?rake( db:create)? db:migrate/, endPattern: /^(<\/span>)?\$/)
|
|
||||||
Em.Object.create(name: 'bundle', startPattern: /^\$ bundle install/, endPattern: /^(<\/span>)?\$/)
|
|
||||||
]
|
|
||||||
|
|
||||||
@Travis.OrderedLog = Em.Object.extend
|
|
||||||
linesLimit: 5000
|
|
||||||
init: ->
|
|
||||||
@set 'folds', []
|
|
||||||
@set 'line', 1
|
|
||||||
@set 'lineNumber', 1
|
|
||||||
@initial = true
|
|
||||||
|
|
||||||
for fold in FOLDS
|
|
||||||
@addFold fold
|
|
||||||
|
|
||||||
append: (lines) ->
|
|
||||||
return unless lines
|
|
||||||
return if @get('lineNumber') > @get('linesLimit')
|
|
||||||
|
|
||||||
log = @join lines
|
|
||||||
log = @escape log
|
|
||||||
log = @deansi log
|
|
||||||
lines = @split log
|
|
||||||
|
|
||||||
target = @get 'target'
|
|
||||||
index = 0
|
|
||||||
currentFold = @currentFold
|
|
||||||
|
|
||||||
result = []
|
|
||||||
|
|
||||||
for line in lines
|
|
||||||
if line == '\r'
|
|
||||||
@set 'replace', true
|
|
||||||
else if line == '\n'
|
|
||||||
@set 'newline', true
|
|
||||||
index += 1
|
|
||||||
else
|
|
||||||
if currentFold && ( @isFoldEnding(currentFold, line) )
|
|
||||||
# end of the fold, send fold to target
|
|
||||||
if result.length > 0
|
|
||||||
result.slice(-1)[0].foldEnd = true
|
|
||||||
target.appendLog result
|
|
||||||
|
|
||||||
@currentFold = currentFold = null
|
|
||||||
@set 'foldContinuation', false
|
|
||||||
result = []
|
|
||||||
|
|
||||||
if !currentFold && ( currentFold = @foldByStart(line) )
|
|
||||||
# beginning new fold, send current lines to target
|
|
||||||
if result.length > 0
|
|
||||||
target.appendLog result
|
|
||||||
|
|
||||||
result = []
|
|
||||||
start = index
|
|
||||||
|
|
||||||
payload = { content: line }
|
|
||||||
|
|
||||||
if currentFold
|
|
||||||
payload.fold = currentFold.get('name')
|
|
||||||
|
|
||||||
if @get 'foldContinuation'
|
|
||||||
payload.foldContinuation = true
|
|
||||||
|
|
||||||
payload.number = @get('lineNumber') + index
|
|
||||||
|
|
||||||
if @get 'replace'
|
|
||||||
@set 'replace', false
|
|
||||||
payload.replace = true
|
|
||||||
else if @get 'newline'
|
|
||||||
@set 'newline', false
|
|
||||||
else if !@initial
|
|
||||||
payload.append = true
|
|
||||||
|
|
||||||
@initial = false
|
|
||||||
|
|
||||||
if payload.foldContinuation && payload.content.match(/Done. Build script exited|Your build has been stopped/)
|
|
||||||
# script ended, but fold is still closed, which most probably means
|
|
||||||
# error, end the fold and open it.
|
|
||||||
# TODO: we need log marks to make it easier
|
|
||||||
payload.foldContinuation = null
|
|
||||||
payload.openFold = payload.fold
|
|
||||||
payload.fold = null
|
|
||||||
|
|
||||||
result.pushObject payload
|
|
||||||
|
|
||||||
if currentFold
|
|
||||||
@set 'foldContinuation', true
|
|
||||||
|
|
||||||
if @get('lineNumber') + index >= @get('linesLimit')
|
|
||||||
result.pushObject logWasCut: true
|
|
||||||
break
|
|
||||||
|
|
||||||
if result.length > 0
|
|
||||||
if currentFold
|
|
||||||
@currentFold = currentFold
|
|
||||||
|
|
||||||
target.appendLog result
|
|
||||||
|
|
||||||
nextLineNumber = @get('lineNumber') + index
|
|
||||||
@set 'lineNumber', nextLineNumber
|
|
||||||
|
|
||||||
join: (lines) ->
|
|
||||||
if typeof lines == 'string'
|
|
||||||
lines
|
|
||||||
else
|
|
||||||
lines.toArray().join ''
|
|
||||||
|
|
||||||
split: (log) ->
|
|
||||||
log = log.replace /\r\n/g, '\n'
|
|
||||||
lines = log.split(/(\n)/)
|
|
||||||
|
|
||||||
if lines.slice(-1)[0] == ''
|
|
||||||
lines.popObject()
|
|
||||||
|
|
||||||
result = []
|
|
||||||
for line in lines
|
|
||||||
result.pushObjects line.split(/(\r)/)
|
|
||||||
|
|
||||||
result
|
|
||||||
|
|
||||||
escape: (log) ->
|
|
||||||
Handlebars.Utils.escapeExpression log
|
|
||||||
|
|
||||||
deansi: (log) ->
|
|
||||||
log = log.replace(/\r\r/g, '\r')
|
|
||||||
.replace(/\033\[K\r/g, '\r')
|
|
||||||
.replace(/\[2K/g, '')
|
|
||||||
.replace(/\033\(B/g, '')
|
|
||||||
.replace(/\033\[\d+G/g, '')
|
|
||||||
|
|
||||||
ansi = ansiparse(log)
|
|
||||||
|
|
||||||
text = ''
|
|
||||||
ansi.forEach (part) ->
|
|
||||||
classes = []
|
|
||||||
part.foreground and classes.push(part.foreground)
|
|
||||||
part.background and classes.push('bg-' + part.background)
|
|
||||||
part.bold and classes.push('bold')
|
|
||||||
part.italic and classes.push('italic')
|
|
||||||
text += (if classes.length then ('<span class=\'' + classes.join(' ') + '\'>' + part.text + '</span>') else part.text)
|
|
||||||
text.replace /\033/g, ''
|
|
||||||
|
|
||||||
addFold: (fold) ->
|
|
||||||
@get('folds').pushObject fold
|
|
||||||
|
|
||||||
foldByStart: (line) ->
|
|
||||||
@get('folds').find (fold) -> line.match(fold.get('startPattern'))
|
|
||||||
|
|
||||||
isFoldEnding: (fold, line) ->
|
|
||||||
line.match(fold.get('endPattern'))
|
|
Loading…
Reference in New Issue
Block a user