diff options
author | Mark Felder <feld@feld.me> | 2024-09-16 11:39:19 -0400 |
---|---|---|
committer | Mark Felder <feld@feld.me> | 2024-09-16 11:42:55 -0400 |
commit | e59706c201bd71525c0a15008c3cb5dcdfb73289 (patch) | |
tree | 06304e78fffeaca7d964ca65e8ab8b9ef380ecd4 | |
parent | 8250a9764ea07a69a701401fd00f6d55e0ef2003 (diff) | |
download | pleroma-e59706c201bd71525c0a15008c3cb5dcdfb73289.tar.gz pleroma-e59706c201bd71525c0a15008c3cb5dcdfb73289.zip |
Reapply "Custom mix task to retry failed tests once in CI pipeline"
This reverts commit b281ad06de2de331450a5e319e3ba497071d4197.
-rw-r--r-- | .gitlab-ci.yml | 2 | ||||
-rw-r--r-- | changelog.d/fix-test-failures.skip | 0 | ||||
-rw-r--r-- | lib/mix/tasks/pleroma/test_runner.ex | 25 |
3 files changed, 26 insertions, 1 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e04dae76..76d1a4210 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -134,7 +134,7 @@ unit-testing-1.13.4-otp-25: script: &testing_script - mix ecto.create - mix ecto.migrate - - mix test --cover --preload-modules + - mix pleroma.test_runner --cover --preload-modules coverage: '/^Line total: ([^ ]*%)$/' artifacts: reports: diff --git a/changelog.d/fix-test-failures.skip b/changelog.d/fix-test-failures.skip deleted file mode 100644 index e69de29bb..000000000 --- a/changelog.d/fix-test-failures.skip +++ /dev/null diff --git a/lib/mix/tasks/pleroma/test_runner.ex b/lib/mix/tasks/pleroma/test_runner.ex new file mode 100644 index 000000000..69fefb001 --- /dev/null +++ b/lib/mix/tasks/pleroma/test_runner.ex @@ -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 |