Skip to content

Commit

Permalink
using env vars in testing config to resolve issues with local dev vs …
Browse files Browse the repository at this point in the history
…ci testing
  • Loading branch information
vforgione committed Jul 4, 2024
1 parent 3298d66 commit 67e94e5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
7 changes: 0 additions & 7 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
FROM elixir:1.17

RUN <<EOF
apt-get update
apt-get install -y --no-install-recommends inotify-tools
rm -rf /var/lib/apt/lists/*
EOF

WORKDIR /code
6 changes: 6 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ services:
environment:
- POSTGRES_USER=pgranges
- POSTGRES_PASSWORD=pgranges
- POSTGRES_DB=pgranges
code:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
command: sleep infinity
environment:
- POSTGRES_USERNAME=pgranges
- POSTGRES_PASSWORD=pgranges
- POSTGRES_DATABASE=pgranges
- POSTGRES_HOSTNAME=db
volumes:
- ..:/code:cached
depends_on:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
env:
POSTGRES_USER: pgranges
POSTGRES_PASSWORD: pgranges
POSTGRES_DB: pgranges
options: >-
--health-cmd pg_isready
--health-interval 10s
Expand Down Expand Up @@ -97,3 +98,8 @@ jobs:
# Step: Execute the tests.
- name: Run tests
run: mix test
env:
POSTGRES_USERNAME: pgranges
POSTGRES_PASSWORD: pgranges
POSTGRES_DATABASE: pgranges
POSTGRES_HOSTNAME: localhost
8 changes: 4 additions & 4 deletions config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import Config
config :elixir, :time_zone_database, Tzdata.TimeZoneDatabase

config :pg_ranges, PgRanges.Repo,
username: "pgranges",
password: "pgranges",
database: "pgranges",
hostname: "db",
username: System.get_env("POSTGRES_USERNAME", "postgres"),
password: System.get_env("POSTGRES_PASSWORD", "postgres"),
database: System.get_env("POSTGRES_DATABASE", "postgres"),
hostname: System.get_env("POSTGRES_HOSTNAME", "localhost"),
pool_size: 10,
pool: Ecto.Adapters.SQL.Sandbox

Expand Down

0 comments on commit 67e94e5

Please sign in to comment.