|
| 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 -}} |
0 commit comments