From ef894b0546270df2a9aeeb172cdc5039ad5aa676 Mon Sep 17 00:00:00 2001 From: Adam Rutkowski Date: Tue, 21 Feb 2023 10:38:22 +0100 Subject: [PATCH] Fail the CI if tests emit log errors/warnings (#2694) * Make CI fail if tests emit warning/error logs * Swallow log output in GA test case --- .github/workflows/elixir.yml | 2 +- test/workers/import_google_analytics_test.exs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 2b80d880d..1b2e7e811 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -71,7 +71,7 @@ jobs: - name: Check Credo Warnings run: mix credo diff --from-git-merge-base origin/master - name: Run tests - run: mix test --include slow --max-failures 1 --warnings-as-errors + run: mix test --include slow --max-failures 1 --warnings-as-errors | grep -P '\[(warning|error)\]' && echo "Log lines found. Capture log output in tests. Aborting." && exit 1 || exit 0 - name: Check Dialyzer run: mix dialyzer env: diff --git a/test/workers/import_google_analytics_test.exs b/test/workers/import_google_analytics_test.exs index dbea18b99..90185ffa7 100644 --- a/test/workers/import_google_analytics_test.exs +++ b/test/workers/import_google_analytics_test.exs @@ -5,6 +5,8 @@ defmodule Plausible.Workers.ImportGoogleAnalyticsTest do alias Plausible.Workers.ImportGoogleAnalytics + @moduletag capture_log: true + @imported_data %Plausible.Site.ImportedData{ start_date: Timex.today() |> Timex.shift(days: -7), end_date: Timex.today(),