diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..172102ce --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,23 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build containers + run: docker-compose build --build-arg MIX_ENV=test + + - name: Start containers + run: docker-compose up -d db cache + + - name: Run tests + run: docker-compose run web bash -c 'cd server && mix test' \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index c785cbf3..e86f132a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,9 +43,10 @@ ENV APP_HOME /app RUN mkdir -p $APP_HOME WORKDIR $APP_HOME +ARG MIX_ENV=dev EXPOSE 3000 EXPOSE 4000 -ENV PORT=4000 UI_PORT=3000 MIX_ENV=dev +ENV PORT=4000 UI_PORT=3000 MIX_ENV=${MIX_ENV} # Create a new stage so that local dev setup can stop here # Local dev mounts into the container so there's no point in adding/compiling diff --git a/server/config/test.exs b/server/config/test.exs index c6fd81a3..b2074c4f 100644 --- a/server/config/test.exs +++ b/server/config/test.exs @@ -14,10 +14,12 @@ config :logger, level: :warning # Configure your database config :orcasite, Orcasite.Repo, adapter: Ecto.Adapters.Postgres, - username: "postgres", - password: "postgres", - database: "orcasite_test#{System.get_env("MIX_TEST_PARTITION")}", - hostname: "localhost", + username: System.get_env("POSTGRES_USER") || "postgres", + password: System.get_env("POSTGRES_PASSWORD") || "postgres", + database: + System.get_env("POSTGRES_DATABASE") || "orcasite_test#{System.get_env("MIX_TEST_PARTITION")}", + port: System.get_env("POSTGRES_PORT") || 5432, + hostname: System.get_env("POSTGRES_HOST") || "localhost", pool: Ecto.Adapters.SQL.Sandbox, types: Orcasite.PostgresTypes, pool_size: 10 @@ -32,6 +34,7 @@ config :orcasite, :cache_adapter, Nebulex.Adapters.Local config :hammer, backend: {Hammer.Backend.ETS, [expiry_ms: 60_000 * 60 * 4, cleanup_interval_ms: 60_000 * 10]} + config :orcasite, OrcasiteWeb.BasicAuth, username: "admin", password: "password" config :ash_graphql, :policies, show_policy_breakdowns?: true config :orcasite, Orcasite.Radio, graphql: [show_raised_errors?: true] diff --git a/server/test/orcasite_web/graphql/moderator_test.exs b/server/test/orcasite_web/graphql/moderator_test.exs index 834a8e36..660ed869 100644 --- a/server/test/orcasite_web/graphql/moderator_test.exs +++ b/server/test/orcasite_web/graphql/moderator_test.exs @@ -39,7 +39,8 @@ defmodule OrcasiteWeb.ModeratorTest do playlist_timestamp: DateTime.to_unix(DateTime.utc_now()), player_offset: 5.54, description: "Test detection", - listener_count: 1 + listener_count: 1, + send_notifications: false }) |> Orcasite.Radio.load!(:candidate) @@ -90,9 +91,7 @@ defmodule OrcasiteWeb.ModeratorTest do assert %{ "data" => %{ - "notificationsForCandidate" => [ - %{"id" => _} | _ - ] + "notificationsForCandidate" => [] } } = json_response(conn, 200)