Skip to content

Commit 8bfec7a

Browse files
committed
CI sidebar: render failing results as a sidebar block
1 parent 46aebc1 commit 8bfec7a

3 files changed

Lines changed: 61 additions & 51 deletions

File tree

‎app/views/topics/_ci_sidebar.html.slim‎

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,44 @@
55
/ exist to keep it that width, not for any rule about the data itself
66
- failed_cap = 10
77
- conflicts_cap = 5
8-
details.sidebar-section.ci-thread-section.ci-badges open=true
9-
summary.sidebar-heading CI
10-
.sidebar-section
11-
.ci-thread-row
12-
span.ci-thread-label Applies
13-
span.ci-thread-value
14-
= ci_bucket_badge(row.health_bucket)
15-
- if (behind = ci_behind_label(row.behind_days(status.repo_state)))
16-
span.muted = "#{behind} behind master"
17-
- if (frozen_note = ci_frozen_note(row))
18-
.ci-thread-note.muted = frozen_note
19-
- if row.status == "failed"
20-
.ci-thread-note = ci_patchset_outcome(row)
21-
- if row.conflict_files.any?
22-
- conflicts = row.conflict_files
23-
.ci-thread-note.muted
24-
= "conflicts: #{conflicts.first(conflicts_cap).join(', ')}"
25-
- if conflicts.size > conflicts_cap
26-
= " +#{conflicts.size - conflicts_cap} more"
27-
.ci-thread-row
28-
span.ci-thread-label Build
29-
span.ci-thread-value
30-
- if row.ci_status.present?
31-
= ci_status_badge(row.ci_status, title: ci_skip_reason_for(row))
32-
- else
33-
= ci_muted_dash
34-
- if run
35-
= ci_duration_pair(run)
36-
- if run&.tests_total
37-
.ci-thread-row
38-
span.ci-thread-label Tests
39-
span.ci-thread-value = ci_tests_figure(run, hover: false)
40-
- if failed.any?
41-
ul.ci-thread-failed
42-
- failed.first(failed_cap).each do |name|
43-
li = name
44-
- if failed.size > failed_cap
45-
.ci-thread-note.muted = "+#{failed.size - failed_cap} more"
46-
.ci-thread-links
47-
- if run
48-
= link_to "GitHub run", ci_github_run_url(run), target: "_blank", rel: "noopener"
49-
- if row.pushed_at
50-
= link_to "GitHub branch", ci_github_branch_url(row.branch_name), target: "_blank", rel: "noopener"
51-
= link_to "CI history", ci_topic_path(topic)
8+
.ci-thread-row
9+
span.ci-thread-label Applies
10+
span.ci-thread-value
11+
= ci_bucket_badge(row.health_bucket)
12+
- if (behind = ci_behind_label(row.behind_days(status.repo_state)))
13+
span.muted = "#{behind} behind master"
14+
- if (frozen_note = ci_frozen_note(row))
15+
.ci-thread-note.muted = frozen_note
16+
- if row.status == "failed"
17+
.ci-thread-note = ci_patchset_outcome(row)
18+
- if row.conflict_files.any?
19+
- conflicts = row.conflict_files
20+
.ci-thread-note.muted
21+
= "conflicts: #{conflicts.first(conflicts_cap).join(', ')}"
22+
- if conflicts.size > conflicts_cap
23+
= " +#{conflicts.size - conflicts_cap} more"
24+
.ci-thread-row
25+
span.ci-thread-label Build
26+
span.ci-thread-value
27+
- if row.ci_status.present?
28+
= ci_status_badge(row.ci_status, title: ci_skip_reason_for(row))
29+
- else
30+
= ci_muted_dash
31+
- if run
32+
= ci_duration_pair(run)
33+
- if run&.tests_total
34+
.ci-thread-row
35+
span.ci-thread-label Tests
36+
span.ci-thread-value = ci_tests_figure(run, hover: false)
37+
- if failed.any?
38+
ul.ci-thread-failed
39+
- failed.first(failed_cap).each do |name|
40+
li = name
41+
- if failed.size > failed_cap
42+
.ci-thread-note.muted = "+#{failed.size - failed_cap} more"
43+
- if run || row.pushed_at
44+
.ci-thread-links
45+
- if run
46+
= link_to "GitHub run", ci_github_run_url(run), target: "_blank", rel: "noopener"
47+
- if row.pushed_at
48+
= link_to "GitHub branch", ci_github_branch_url(row.branch_name), target: "_blank", rel: "noopener"
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
- row = status.row
2-
- if ci_all_green?(row)
3-
section.sidebar-block.ci-thread-section.ci-badges
4-
.sidebar-block-head
5-
span.sidebar-block-label CI
6-
= link_to "History ›", ci_topic_path(topic), class: "sidebar-block-more"
2+
section.sidebar-block.ci-thread-section.ci-badges
3+
.sidebar-block-head
4+
span.sidebar-block-label CI
5+
= link_to "History ›", ci_topic_path(topic), class: "sidebar-block-more"
6+
- if ci_all_green?(row)
77
.sidebar-chips
88
span.badge.b-success All green
99
span.sidebar-muted applies · builds · tests pass
10-
- else
11-
= render "topics/ci_sidebar", status: status, topic: topic
10+
- else
11+
= render "topics/ci_sidebar", status: status, topic: topic

‎spec/requests/ci_public_spec.rb‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,19 @@ def sidebar
130130
expect(sidebar).to include("+4 more")
131131
end
132132

133+
it "renders a failing result in the same block shell as a green one" do
134+
repo_state
135+
topic = thread_with_run({ ci_status: "tests_failed" },
136+
{ status: "tests_failed", tests_total: 5, failed_tests: %w[regress/foo] })
137+
138+
get topic_path(topic)
139+
140+
block = Nokogiri::HTML(response.body).at_css(".ci-thread-section")
141+
expect(block.name).to eq("section")
142+
expect(block.at_css(".sidebar-block-head a")["href"]).to eq(ci_topic_path(topic))
143+
expect(block.css("summary, .sidebar-section")).to be_empty
144+
end
145+
133146
it "renders no block on a thread with no patchset" do
134147
repo_state
135148
topic = create(:topic, last_message_at: Time.current)

0 commit comments

Comments
 (0)