From 79be23813ea4dc1b68786b68cd5d300527fba955 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Tue, 29 Jul 2025 12:26:35 -0500 Subject: [PATCH] Improve CI/CD stability for frontend integration tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address browser testing reliability in CI environments: ## CI/CD Improvements - **ChromeDriver**: Use latest stable version instead of pinned version for better compatibility - **Timeouts**: Add 10-minute timeout for integration tests to prevent CI hangs - **Environment Variables**: Configure WALLABY_MAX_WAIT_TIME for CI-specific timeouts ## Wallaby Configuration Enhancements - **Chrome Args**: Add CI-stable Chrome options (--no-sandbox, --disable-dev-shm-usage) - **Window Size**: Set consistent 1280x720 window size for reproducible tests - **Dynamic Timeouts**: Environment-configurable max wait time with sensible defaults - **Pool Size**: Limit to single browser instance to prevent resource conflicts ## Benefits - ✅ More reliable test execution in CI environments - ✅ Better error handling and timeout management - ✅ Consistent browser behavior across environments - ✅ Reduced flakiness from resource constraints 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/elixir.yaml | 8 ++++++-- config/test.exs | 17 +++++++++++++++-- test/integration/map_integration_test.exs | 7 ++++--- test/integration/simple_integration_test.exs | 9 +++++---- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/.github/workflows/elixir.yaml b/.github/workflows/elixir.yaml index 6efb23d..188aaf8 100644 --- a/.github/workflows/elixir.yaml +++ b/.github/workflows/elixir.yaml @@ -118,8 +118,7 @@ jobs: # Step: Install ChromeDriver for integration tests - name: Setup ChromeDriver uses: nanasess/setup-chromedriver@v2 - with: - chromedriver-version: '119.0.6045.105' + # Note: Using latest stable version instead of pinned version for better compatibility # Step: Execute the tests. - name: Run tests @@ -128,3 +127,8 @@ jobs: # Step: Run integration tests separately with Wallaby - name: Run integration tests run: mix test --only integration + timeout-minutes: 10 + env: + # Increase timeouts for browser tests in CI environment + WALLABY_SCREENSHOT_ON_FAILURE: true + WALLABY_MAX_WAIT_TIME: 30000 diff --git a/config/test.exs b/config/test.exs index a3ee755..dcbf15b 100644 --- a/config/test.exs +++ b/config/test.exs @@ -83,7 +83,20 @@ config :swoosh, :api_client, false # Configure Wallaby config :wallaby, driver: Wallaby.Chrome, - chromedriver: [headless: true], + chromedriver: [ + headless: true, + # Additional Chrome options for CI stability + args: [ + "--no-sandbox", + "--disable-dev-shm-usage", + "--disable-gpu", + "--window-size=1280,720" + ] + ], screenshot_on_failure: true, screenshot_dir: "test/screenshots", - base_url: "http://localhost:4002" + base_url: "http://localhost:4002", + # Increase default timeouts for CI environment + max_wait_time: "WALLABY_MAX_WAIT_TIME" |> System.get_env("5000") |> String.to_integer(), + # Pool configuration for concurrent tests + pool_size: 1 diff --git a/test/integration/map_integration_test.exs b/test/integration/map_integration_test.exs index 6e21cfc..ae8c118 100644 --- a/test/integration/map_integration_test.exs +++ b/test/integration/map_integration_test.exs @@ -9,13 +9,14 @@ defmodule AprsmeWeb.MapIntegrationTest do import Wallaby.Browser alias Aprsme.Repo + alias Ecto.Adapters.SQL.Sandbox alias Wallaby.Query @moduletag :integration setup do - :ok = Ecto.Adapters.SQL.Sandbox.checkout(Repo) - Ecto.Adapters.SQL.Sandbox.mode(Repo, {:shared, self()}) + :ok = Sandbox.checkout(Repo) + Sandbox.mode(Repo, {:shared, self()}) {:ok, %{}} end @@ -38,4 +39,4 @@ defmodule AprsmeWeb.MapIntegrationTest do |> visit("/info") |> assert_has(Query.css("body")) end -end \ No newline at end of file +end diff --git a/test/integration/simple_integration_test.exs b/test/integration/simple_integration_test.exs index cde6a5c..5845f4b 100644 --- a/test/integration/simple_integration_test.exs +++ b/test/integration/simple_integration_test.exs @@ -6,14 +6,15 @@ defmodule AprsmeWeb.SimpleIntegrationTest do use Wallaby.Feature import Wallaby.Browser - + + alias Ecto.Adapters.SQL.Sandbox alias Wallaby.Query @moduletag :integration setup do - :ok = Ecto.Adapters.SQL.Sandbox.checkout(Aprsme.Repo) - Ecto.Adapters.SQL.Sandbox.mode(Aprsme.Repo, {:shared, self()}) + :ok = Sandbox.checkout(Aprsme.Repo) + Sandbox.mode(Aprsme.Repo, {:shared, self()}) {:ok, %{}} end @@ -22,4 +23,4 @@ defmodule AprsmeWeb.SimpleIntegrationTest do |> visit("/") |> assert_has(Query.text("APRS")) end -end \ No newline at end of file +end