complement_package.gotpl 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. This template is based on https://github.com/haveyoudebuggedit/gotestfmt/blob/f179b0e462a9dcf7101515d87eec4e4d7e58b92a/.gotestfmt/github/package.gotpl
  6. which is under the Unlicense licence.
  7. */ -}}
  8. {{- $settings := .Settings -}}
  9. {{- if and (or (not $settings.HideSuccessfulPackages) (ne .Result "PASS")) (or (not $settings.HideEmptyPackages) (ne .Result "SKIP") (ne (len .TestCases) 0)) -}}
  10. {{- if eq .Result "PASS" -}}
  11. {{ "\033" }}[0;32m
  12. {{- else if eq .Result "SKIP" -}}
  13. {{ "\033" }}[0;33m
  14. {{- else -}}
  15. {{ "\033" }}[0;31m
  16. {{- end -}}
  17. 📦 {{ .Name }}{{- "\033" }}[0m
  18. {{- with .Coverage -}}
  19. {{- "\033" -}}[0;37m ({{ . }}% coverage){{- "\033" -}}[0m
  20. {{- end -}}
  21. {{- "\n" -}}
  22. {{- with .Reason -}}
  23. {{- " " -}}🛑 {{ . -}}{{- "\n" -}}
  24. {{- end -}}
  25. {{- with .Output -}}
  26. {{- . -}}{{- "\n" -}}
  27. {{- end -}}
  28. {{- with .TestCases -}}
  29. {{- /* Passing tests are first */ -}}
  30. {{- range . -}}
  31. {{- if eq .Result "PASS" -}}
  32. ::group::{{ "\033" }}[0;32m✅{{ " " }}{{- .Name -}}
  33. {{- "\033" -}}[0;37m ({{if $settings.ShowTestStatus}}{{.Result}}; {{end}}{{ .Duration -}}
  34. {{- with .Coverage -}}
  35. , coverage: {{ . }}%
  36. {{- end -}})
  37. {{- "\033" -}}[0m
  38. {{- "\n" -}}
  39. {{- with .Output -}}
  40. {{- formatTestOutput . $settings -}}
  41. {{- "\n" -}}
  42. {{- end -}}
  43. ::endgroup::{{- "\n" -}}
  44. {{- end -}}
  45. {{- end -}}
  46. {{- /* Then skipped tests are second */ -}}
  47. {{- range . -}}
  48. {{- if eq .Result "SKIP" -}}
  49. ::group::{{ "\033" }}[0;33m🚧{{ " " }}{{- .Name -}}
  50. {{- "\033" -}}[0;37m ({{if $settings.ShowTestStatus}}{{.Result}}; {{end}}{{ .Duration -}}
  51. {{- with .Coverage -}}
  52. , coverage: {{ . }}%
  53. {{- end -}})
  54. {{- "\033" -}}[0m
  55. {{- "\n" -}}
  56. {{- with .Output -}}
  57. {{- formatTestOutput . $settings -}}
  58. {{- "\n" -}}
  59. {{- end -}}
  60. ::endgroup::{{- "\n" -}}
  61. {{- end -}}
  62. {{- end -}}
  63. {{- /* and failing tests are last */ -}}
  64. {{- range . -}}
  65. {{- if and (ne .Result "PASS") (ne .Result "SKIP") -}}
  66. ::group::{{ "\033" }}[0;31m❌{{ " " }}{{- .Name -}}
  67. {{- "\033" -}}[0;37m ({{if $settings.ShowTestStatus}}{{.Result}}; {{end}}{{ .Duration -}}
  68. {{- with .Coverage -}}
  69. , coverage: {{ . }}%
  70. {{- end -}})
  71. {{- "\033" -}}[0m
  72. {{- "\n" -}}
  73. {{- with .Output -}}
  74. {{- formatTestOutput . $settings -}}
  75. {{- "\n" -}}
  76. {{- end -}}
  77. ::endgroup::{{- "\n" -}}
  78. {{- end -}}
  79. {{- end -}}
  80. {{- end -}}
  81. {{- "\n" -}}
  82. {{- end -}}