Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit e12ff69

Browse files
authoredJun 15, 2022
Sort failing jobs in Complement CI to the top of the logs to make them easier to read. (#13057)
1 parent de334ac commit e12ff69

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed
 

‎.ci/complement_package.gotpl

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{{- /*gotype: github.com/haveyoudebuggedit/gotestfmt/parser.Package*/ -}}
2+
{{- /*
3+
This template contains the format for an individual package. GitHub actions does not currently support nested groups so
4+
we are creating a stylized header for each package.
5+
6+
This template is based on https://github.com/haveyoudebuggedit/gotestfmt/blob/f179b0e462a9dcf7101515d87eec4e4d7e58b92a/.gotestfmt/github/package.gotpl
7+
which is under the Unlicense licence.
8+
*/ -}}
9+
{{- $settings := .Settings -}}
10+
{{- if and (or (not $settings.HideSuccessfulPackages) (ne .Result "PASS")) (or (not $settings.HideEmptyPackages) (ne .Result "SKIP") (ne (len .TestCases) 0)) -}}
11+
{{- if eq .Result "PASS" -}}
12+
{{ "\033" }}[0;32m
13+
{{- else if eq .Result "SKIP" -}}
14+
{{ "\033" }}[0;33m
15+
{{- else -}}
16+
{{ "\033" }}[0;31m
17+
{{- end -}}
18+
📦 {{ .Name }}{{- "\033" }}[0m
19+
{{- with .Coverage -}}
20+
{{- "\033" -}}[0;37m ({{ . }}% coverage){{- "\033" -}}[0m
21+
{{- end -}}
22+
{{- "\n" -}}
23+
{{- with .Reason -}}
24+
{{- " " -}}🛑 {{ . -}}{{- "\n" -}}
25+
{{- end -}}
26+
{{- with .Output -}}
27+
{{- . -}}{{- "\n" -}}
28+
{{- end -}}
29+
{{- with .TestCases -}}
30+
{{- /* Failing tests are first */ -}}
31+
{{- range . -}}
32+
{{- if and (ne .Result "PASS") (ne .Result "SKIP") -}}
33+
::group::{{ "\033" }}[0;31m❌{{ " " }}{{- .Name -}}
34+
{{- "\033" -}}[0;37m ({{if $settings.ShowTestStatus}}{{.Result}}; {{end}}{{ .Duration -}}
35+
{{- with .Coverage -}}
36+
, coverage: {{ . }}%
37+
{{- end -}})
38+
{{- "\033" -}}[0m
39+
{{- "\n" -}}
40+
41+
{{- with .Output -}}
42+
{{- formatTestOutput . $settings -}}
43+
{{- "\n" -}}
44+
{{- end -}}
45+
46+
::endgroup::{{- "\n" -}}
47+
{{- end -}}
48+
{{- end -}}
49+
50+
51+
{{- /* Then skipped tests are second */ -}}
52+
{{- range . -}}
53+
{{- if eq .Result "SKIP" -}}
54+
::group::{{ "\033" }}[0;33m🚧{{ " " }}{{- .Name -}}
55+
{{- "\033" -}}[0;37m ({{if $settings.ShowTestStatus}}{{.Result}}; {{end}}{{ .Duration -}}
56+
{{- with .Coverage -}}
57+
, coverage: {{ . }}%
58+
{{- end -}})
59+
{{- "\033" -}}[0m
60+
{{- "\n" -}}
61+
62+
{{- with .Output -}}
63+
{{- formatTestOutput . $settings -}}
64+
{{- "\n" -}}
65+
{{- end -}}
66+
67+
::endgroup::{{- "\n" -}}
68+
{{- end -}}
69+
{{- end -}}
70+
71+
72+
{{- /* Then passing tests are last */ -}}
73+
{{- range . -}}
74+
{{- if eq .Result "PASS" -}}
75+
::group::{{ "\033" }}[0;32m✅{{ " " }}{{- .Name -}}
76+
{{- "\033" -}}[0;37m ({{if $settings.ShowTestStatus}}{{.Result}}; {{end}}{{ .Duration -}}
77+
{{- with .Coverage -}}
78+
, coverage: {{ . }}%
79+
{{- end -}})
80+
{{- "\033" -}}[0m
81+
{{- "\n" -}}
82+
83+
{{- with .Output -}}
84+
{{- formatTestOutput . $settings -}}
85+
{{- "\n" -}}
86+
{{- end -}}
87+
88+
::endgroup::{{- "\n" -}}
89+
{{- end -}}
90+
{{- end -}}
91+
{{- end -}}
92+
{{- "\n" -}}
93+
{{- end -}}

‎.github/workflows/tests.yml

+10
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,11 @@ jobs:
348348
with:
349349
path: synapse
350350

351+
- name: "Install custom gotestfmt template"
352+
run: |
353+
mkdir .gotestfmt/github -p
354+
cp synapse/.ci/complement_package.gotpl .gotestfmt/github/package.gotpl
355+
351356
# Attempt to check out the same branch of Complement as the PR. If it
352357
# doesn't exist, fallback to HEAD.
353358
- name: Checkout complement
@@ -389,6 +394,11 @@ jobs:
389394
with:
390395
path: synapse
391396

397+
- name: "Install custom gotestfmt template"
398+
run: |
399+
mkdir .gotestfmt/github -p
400+
cp synapse/.ci/complement_package.gotpl .gotestfmt/github/package.gotpl
401+
392402
# Attempt to check out the same branch of Complement as the PR. If it
393403
# doesn't exist, fallback to HEAD.
394404
- name: Checkout complement

‎changelog.d/13057.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make Complement CI logs easier to read.

0 commit comments

Comments
 (0)
This repository has been archived.