% extends 'base.html'
{% block title %}{{job}} #{{build}} Results{% endblock %}
% block head
{{super()}}
% if not finished
<link rel="icon" type="image/png" href="{{'favicon-yellow.png'|static}}" />
% elif finished and finished['passed'] and not res['failed']
<link rel="icon" type="image/png" href="{{'favicon-green.png'|static}}" />
% endif
% endblock
% block banner
% if spyglass_link
<div id="page-top-banner">
	This job view page is being replaced by Spyglass soon. <a href="{{spyglass_link}}">Check out the new job view</a>.
</div>
% endif
% endblock
% block header
<h1>{% if pr and pr != "batch"  %}<a href="/pr/{{pr_path}}{{pr}}">{% if repo != "kubernetes/kubernetes"%}{{repo}} {% endif %}PR #{{pr}}</a> {% endif %}
	% if testgrid_query
		<a href="{{testgrid_query|tg_url}}">{{job}}</a>
	% else
		{{job}}
	% endif
	#{{build}}</h1>
	<p><a href="/builds{{job_dir}}">Recent runs</a>
	% if spyglass_link
	|| <a href="{{spyglass_link}}">View in Spyglass</a>
	% endif
	</p><br>
% endblock
% block content
<div id="summary">
	<table class="build-meta">
	% if pr and pr_digest
		% set pl = pr_digest.payload
		<tr><td>PR<td><a href="/pr/{{pl['author']}}">{{pl['author']}}</a>: {{pl['title']}}
	% endif
		% if finished
			% set result = finished['result']
		% else
			% set result = 'Not Finished'
		% endif
		<tr><td>Result<td><span class="build-{{result | slugify}}">{{result}}</span>
	% if started
		% if finished
			<tr><td>Tests<td>
			% if res['failed']
				<span class="text-failure">{{res['failed']|length}} failed</span>
			% else
				{{res['failed']|length}} failed
			% endif
			/ {{res['passed']|length}} succeeded
		% endif
		<tr><td>Started<td>{{started['timestamp']|timestamp}}
		{% if finished %}<tr><td>Elapsed<td>{{(finished['timestamp']-started['timestamp'])|duration}}{% endif %}
		<tr><td>Revision<td><a href="https://github.com/{{repo}}/commit/{{commit}}">{{started['revision'] or finished['revision']}}</a>
		% if 'node' in started
			<tr><td>Builder<td>{{started['node']}}
		% endif
		% if refs
			<tr><td>Refs<td>
			% for name, sha in refs
				{%- if name.isdigit() -%}
					<a href="https://github.com/{{repo}}/pull/{{name}}">{{name}}</a>
				{%- else -%}
					{{name}}
				{%- endif -%}
				{%- if sha %}:{{sha|github_commit_link(repo)}}{% endif %}<br>
			{%- endfor %}
		% endif
		% if 'metadata' in started
			% for k, v in started['metadata']|dictsort
			<tr><td>{{k}}<td>{{v|maybe_linkify}}
			% endfor
		% endif
		% if finished and 'metadata' in finished and finished['metadata']
			% for k, v in finished['metadata']|dictsort
			<tr><td>{{k}}<td>{{v|maybe_linkify}}
			% endfor
		% endif
	% endif
	</table>
	<ul class="nav">
		<li class="nav"><a href="{{build_dir | gcs_browse_url}}">artifacts</a></li>
		<li class="nav"><a href="?log#log">build log</a></li>
	</ul>
	</div>
	<div id="failures">
	% if issues
		<h4>References</h4>
		% for issue in issues
		<a href="{{issue.url}}">
		{% if issue.is_pr %}PR{% else %}Issue{% endif %} #{{issue.number}} {{issue.payload['title']}}</a>
		<br>
		% endfor
		<hr>
	% endif
	% if res['failed']
		<h2>Test Failures</h2>
		% for name, time, text, filename, output in res['failed']
			<hr>
			<h3><a class="anchor" id="{{name|slugify}}" href="#{{name|slugify}}">{{name}}<span class="time"> {{time|duration}}</span></h3></a>
			% if 'junit_runner' not in filename
				<pre class="cmd" onclick="select(this)">{{name | testcmd}}</pre>
			% endif
			% if text
				<pre class="error">{{text|linkify_stacktrace(commit, repo)}}
				% if output
				<div class="hidden"><hr>{{output|linkify_stacktrace(commit, repo)}}</div>
				<span class="expand inset-expand">Click to see stdout/stderr</span><span class="inset-filename">from <a href="https://storage.googleapis.com{{filename}}">{{filename|basename}}</a></span></pre>
				% else
				<span class="inset-filename">from <a href="https://storage.googleapis.com{{filename}}">{{filename|basename}}</a></span></pre>
				% endif
				% set pod_name = text|parse_pod_name
				% if pod_name
					<p>Find <tt>{{pod_name}}</tt> mentions in <a id="{{pod_name|slugify}}" href="/build{{build_dir}}/nodelog?pod={{pod_name}}&junit={{filename|basename}}&wrap=on">log files</a>
				% else
					<p>Filter through <a href="/build{{build_dir}}/nodelog?junit={{filename|basename}}&wrap=on">log files</a>
				% endif
				% if testgrid_query
					| View <a href="{{testgrid_query|tg_url(name)}}">test history</a> on testgrid
				% endif
			% else
				<span class="inset-filename">from <a href="https://storage.googleapis.com{{filename}}">{{filename|basename}}</a></span>
			% endif
		% endfor
	% else
		<h2>{{"No Test Failures!" if finished else "Build Still Running!"}}</h2>
	% endif
	</div>
	% for kind in ['passed', 'skipped']
		% if res[kind]
			<hr>
			<div id="{{kind}}" class="testlist">
			<span class="expand">Show {{res[kind]|length}} {{kind|title}} Tests</span>
			<h2 class="hidden">{{kind|title}}</h2>
			% for name in res[kind]
				<p class="hidden">{{name}}
			% endfor
			</div>
		% endif
	% endfor
	% if build_log
	<div id="log">
		<a name="log"></a>
		<hr>
		<h2 id="log">Error lines from build-log.txt</h2>
		<ul class="log">
			<li class="log"><button onclick="javascript:expand_all(this.parentElement)">Expand Skipped Lines</button></li>
			<li class="log"><a id="rawloglink" href="{{build_log_src or "https://storage.googleapis.com%s/build-log.txt" % build_dir}}">Raw build-log.txt</a></li>
		</ul>
		<pre data-src="{{build_log_src or "%s/build-log.txt" % build_dir}}">{{build_log | safe}}</pre>
	</div>
	% endif
% endblock
