mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2025-01-03 05:48:42 +00:00
Reapply "Custom mix task to retry failed tests once in CI pipeline"
This reverts commit b281ad06de
.
This commit is contained in:
parent
8250a9764e
commit
e59706c201
3 changed files with 26 additions and 1 deletions
|
@ -134,7 +134,7 @@ unit-testing-1.13.4-otp-25:
|
||||||
script: &testing_script
|
script: &testing_script
|
||||||
- mix ecto.create
|
- mix ecto.create
|
||||||
- mix ecto.migrate
|
- mix ecto.migrate
|
||||||
- mix test --cover --preload-modules
|
- mix pleroma.test_runner --cover --preload-modules
|
||||||
coverage: '/^Line total: ([^ ]*%)$/'
|
coverage: '/^Line total: ([^ ]*%)$/'
|
||||||
artifacts:
|
artifacts:
|
||||||
reports:
|
reports:
|
||||||
|
|
25
lib/mix/tasks/pleroma/test_runner.ex
Normal file
25
lib/mix/tasks/pleroma/test_runner.ex
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
defmodule Mix.Tasks.Pleroma.TestRunner do
|
||||||
|
@shortdoc "Retries tests once if they fail"
|
||||||
|
|
||||||
|
use Mix.Task
|
||||||
|
|
||||||
|
def run(args \\ []) do
|
||||||
|
case System.cmd("mix", ["test"] ++ args, into: IO.stream(:stdio, :line)) do
|
||||||
|
{_, 0} ->
|
||||||
|
:ok
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
retry(args)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def retry(args) do
|
||||||
|
case System.cmd("mix", ["test", "--failed"] ++ args, into: IO.stream(:stdio, :line)) do
|
||||||
|
{_, 0} ->
|
||||||
|
:ok
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
exit(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue