Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Github Workflow for testing with docker-compose #299

Merged
merged 8 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -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'
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions server/config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down
7 changes: 3 additions & 4 deletions server/test/orcasite_web/graphql/moderator_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -90,9 +91,7 @@ defmodule OrcasiteWeb.ModeratorTest do

assert %{
"data" => %{
"notificationsForCandidate" => [
%{"id" => _} | _
]
"notificationsForCandidate" => []
}
} =
json_response(conn, 200)
Expand Down
Loading