diff --git a/modules/simplytest_tugboat/assets/simplytest_tugboat_status.js b/modules/simplytest_tugboat/assets/simplytest_tugboat_status.js index aaade81..7163704 100644 --- a/modules/simplytest_tugboat/assets/simplytest_tugboat_status.js +++ b/modules/simplytest_tugboat/assets/simplytest_tugboat_status.js @@ -31,6 +31,7 @@ }, 1000); $('.percentage', progressbar).html(data.percent + '%'); $('.message', progressbar).html(data.message); + $('.log', progressbar).html(data.instanceLog); if (data.percent == 100) { // Putting in an intentional delay to let the tugboat API return the URL and STM to process it. diff --git a/modules/simplytest_tugboat/simplytest_tugboat.instance_status.inc b/modules/simplytest_tugboat/simplytest_tugboat.instance_status.inc index a264472..a86fc92 100644 --- a/modules/simplytest_tugboat/simplytest_tugboat.instance_status.inc +++ b/modules/simplytest_tugboat/simplytest_tugboat.instance_status.inc @@ -249,6 +249,11 @@ function simplytest_tugboat_status_progress_page($id) { '#percent' => $state['percent'], '#message' => $state['message'], ), + 'log' => array( + '#prefix' => '
', + '#suffix' => '
', + '#markup' => $state['instanceLog'], + ), ); } } @@ -332,6 +337,7 @@ function simplytest_tugboat_status_state($instance_id) { $status_code = FALSE; $percent = 0; $message = t('No instance status found...'); + $log = ''; if (!empty($statuses)) { $instance_status = array_pop($statuses); @@ -341,6 +347,7 @@ function simplytest_tugboat_status_state($instance_id) { $status_code = $status['code']; $percent = simplytest_tugboat_status_running_percentage($status['code']); $message = $status['message']; + $log = _simplytest_tugboat_get_log($instance_id); } } @@ -348,6 +355,7 @@ function simplytest_tugboat_status_state($instance_id) { 'code' => $status_code, 'percent' => $percent, 'message' => $message, + 'instanceLog' => $log, ]; } diff --git a/modules/simplytest_tugboat/simplytest_tugboat.module b/modules/simplytest_tugboat/simplytest_tugboat.module index b6d7a65..6c68bcd 100644 --- a/modules/simplytest_tugboat/simplytest_tugboat.module +++ b/modules/simplytest_tugboat/simplytest_tugboat.module @@ -222,6 +222,42 @@ function _simplytest_tugboat_launch_instance($submission) { simplytest_tugboat_status_goto($ref); } +/** + * Get instance log. + * + * @param $instance_id + */ +function _simplytest_tugboat_get_log($instance_id) { + + $tugboat_repo = variable_get('tugboat_repository_id'); + + $return_data = array(); + $error_string = ''; + + watchdog('message', 'we are in the log function for ' . $instance_id); + + + // Load the ID of the correct base preview ID. + $preview_id = simplytest_tugboat_load_preview_id($instance_id, FALSE); + + //return 'Preview ' . $preview_id . ' ' . time(); + + // Run the tugboat command. + $command = "log $preview_id"; + watchdog('message', $command); + $return_status = _tugboat_execute($command, $return_data, $error_string); + $log = array(); + foreach ($return_data as $log_entry) { + $color = 'white'; + if ($log_entry['level'] == 'stderr') { + $color = 'red'; + } + $message = '

' . $log_entry['message'] . '

'; + $log[] = $message; + } + return implode('', $log); +} + /** * Call tugboat and start spawning the new instance. * @@ -254,7 +290,7 @@ function _simplytest_tugboat_execute_tugboat($instance_id) { simplytest_tugboat_status_update($instance_id, SIMPLYTEST_STATUS_PREPARE); // Load the ID of the correct base preview ID. - $base_preview_id = simplytest_tugboat_load_preview_id($context); + $base_preview_id = simplytest_tugboat_load_preview_id($context, TRUE); watchdog('message', 'Trying to load base preview ' . $base_preview_id); @@ -294,8 +330,13 @@ function _simplytest_tugboat_execute_tugboat($instance_id) { * @param $context * @return string */ -function simplytest_tugboat_load_preview_id($context) { - $branch_name = 'base-' . $context; +function simplytest_tugboat_load_preview_id($context, $base = TRUE) { + if ($base) { + $branch_name = 'base-' . $context; + } else { + $branch_name = $context; + } + watchdog('message', 'Loading preview ID for ' . $branch_name); $previews = array(); $error_string = ''; $return_status = _tugboat_execute("ls previews", $previews, $error_string); @@ -306,20 +347,31 @@ function simplytest_tugboat_load_preview_id($context) { $max_id = NULL; // Find the most recent preview ID for the base. - $acceptable_states = array( - 'ready', - 'suspended', - 'refreshing', - ); + if ($base) { + $acceptable_states = array( + 'ready', + 'suspended', + 'refreshing', + ); + } else { + $acceptable_states = array( + 'building', + 'pending', + 'new', + 'ready', + 'suspended', + 'refreshing', + ); + } $repo = variable_get('simplytest_tugboat_github_repo'); $ns = variable_get('simplytest_tugboat_github_ns'); $repo_filter = 'https://github.com/' . $ns . '/' . $repo; watchdog('simplytest_tugboat', 'Previews: ' . var_export($previews, TRUE)); foreach ($previews as $num => $preview) { $ts = strtotime($preview['createdAt']); - if ($preview['provider_ref']['name'] == $branch_name - and $max_timestamp < $ts - and in_array($preview['state'], $acceptable_states) + if ($preview['provider_label'] == $branch_name + //and $max_timestamp < $ts + //and in_array($preview['state'], $acceptable_states) and strpos($preview['provider_link'], $repo_filter) !== FALSE ) { $max_id = $preview['id']; @@ -329,9 +381,15 @@ function simplytest_tugboat_load_preview_id($context) { // Throw error if ID not found if (empty($max_id)) { - watchdog('simplytest_tugboat', 'No base preview for: %sid', array( - '%sid' => $context, - ), WATCHDOG_ERROR); + if ($base) { + watchdog('simplytest_tugboat', 'No base preview for: %sid', array( + '%sid' => $context, + ), WATCHDOG_ERROR); + } else { + watchdog('simplytest_tugboat', 'No preview for: %sid', array( + '%sid' => $context, + ), WATCHDOG_ERROR); + } } return $max_id; } diff --git a/themes/simplytesty/simplytesty.info b/themes/simplytesty/simplytesty.info index 1ff7898..9a943bf 100644 --- a/themes/simplytesty/simplytesty.info +++ b/themes/simplytesty/simplytesty.info @@ -4,6 +4,7 @@ core = 7.x engine = phptemplate stylesheets[all][] = style.css +stylesheets[all][] = terminal.css stylesheets[screen and (max-width: 1030px)][] = style-small.css stylesheets[screen and (max-width: 575px)][] = style-narrow.css diff --git a/themes/simplytesty/terminal.css b/themes/simplytesty/terminal.css index e69de29..fa67ab6 100644 --- a/themes/simplytesty/terminal.css +++ b/themes/simplytesty/terminal.css @@ -0,0 +1,217 @@ +.fakeButtons { + height: 10px; + width: 10px; + border-radius: 50%; + border: 1px solid #000; + position: relative; + top: 6px; + left: 6px; + background-color: #ff3b47; + border-color: #9d252b; + display: inline-block; +} + +.fakeMinimize { + left: 11px; + background-color: #ffc100; + border-color: #9d802c; +} + +.fakeZoom { + left: 16px; + background-color: #00d742; + border-color: #049931; +} + +.fakeMenu { + width: 550px; + box-sizing: border-box; + height: 25px; + background-color: #bbb; + margin: 0 auto; + border-top-right-radius: 5px; + border-top-left-radius: 5px; +} + +.fakeScreen { + background-color: #151515; + box-sizing: border-box; + width: 550px; + margin: 0 auto; + padding: 20px; + border-bottom-left-radius: 5px; + border-bottom-right-radius: 5px; +} + +p { + position: relative; + left: 50%; + margin-left: -8.5em; + text-align: left; + font-size: 1.25em; + font-family: monospace; + white-space: normal; + overflow: hidden; + width: 0; +} + +span { + color: #fff; + font-weight: bold; +} + +.line1 { + color: #9CD9F0; + -webkit-animation: type .5s 1s steps(20, end) forwards; + -moz-animation: type .5s 1s steps(20, end) forwards; + -o-animation: type .5s 1s steps(20, end) forwards; + animation: type .5s 1s steps(20, end) forwards; +} + +.cursor1 { + -webkit-animation: blink 1s 2s 2 forwards; + -moz-animation: blink 1s 2s 2 forwards; + -o-animation: blink 1s 2s 2 forwards; + animation: blink 1s 2s 2 forwards; +} + +.line2 { + color: #CDEE69; + -webkit-animation: type .5s 4.25s steps(20, end) forwards; + -moz-animation: type .5s 4.25s steps(20, end) forwards; + -o-animation: type .5s 4.25s steps(20, end) forwards; + animation: type .5s 4.25s steps(20, end) forwards; +} + +.cursor2 { + -webkit-animation: blink 1s 5.25s 2 forwards; + -moz-animation: blink 1s 5.25s 2 forwards; + -o-animation: blink 1s 5.25s 2 forwards; + animation: blink 1s 5.25s 2 forwards; +} + +.line3 { + color: #E09690; + -webkit-animation: type .5s 7.5s steps(20, end) forwards; + -moz-animation: type .5s 7.5s steps(20, end) forwards; + -o-animation: type .5s 7.5s steps(20, end) forwards; + animation: type .5s 7.5s steps(20, end) forwards; +} + +.cursor3 { + -webkit-animation: blink 1s 8.5s 2 forwards; + -moz-animation: blink 1s 8.5s 2 forwards; + -o-animation: blink 1s 8.5s 2 forwards; + animation: blink 1s 8.5s 2 forwards; +} + +.line4 { + color: #fff; + -webkit-animation: type .5s 10.75s steps(20, end) forwards; + -moz-animation: type .5s 10.75s steps(20, end) forwards; + -o-animation: type .5s 10.75s steps(20, end) forwards; + animation: type .5s 10.75s steps(20, end) forwards; +} + +.cursor4 { + -webkit-animation: blink 1s 11.5s infinite; + -moz-animation: blink 1s 8.5s infinite; + -o-animation: blink 1s 8.5s infinite; + animation: blink 1s 8.5s infinite; +} + +@-webkit-keyframes blink { + 0% { + opacity: 0; + } + 40% { + opacity: 0; + } + 50% { + opacity: 1; + } + 90% { + opacity: 1; + } + 100% { + opacity: 0; + } +} + +@-moz-keyframes blink { + 0% { + opacity: 0; + } + 40% { + opacity: 0; + } + 50% { + opacity: 1; + } + 90% { + opacity: 1; + } + 100% { + opacity: 0; + } +} + +@-o-keyframes blink { + 0% { + opacity: 0; + } + 40% { + opacity: 0; + } + 50% { + opacity: 1; + } + 90% { + opacity: 1; + } + 100% { + opacity: 0; + } +} + +@keyframes blink { + 0% { + opacity: 0; + } + 40% { + opacity: 0; + } + 50% { + opacity: 1; + } + 90% { + opacity: 1; + } + 100% { + opacity: 0; + } +} + +@-webkit-keyframes type { + to { + width: 17em; + } +} + +@-moz-keyframes type { + to { + width: 17em; + } +} + +@-o-keyframes type { + to { + width: 17em; + } +} + +@keyframes type { + to { + width: 17em; + } +} \ No newline at end of file