Skip to content

Commit

Permalink
fix(elixir): Unify configs (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrapacz authored Feb 24, 2018
1 parent 5bd57d8 commit 678568c
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 164 deletions.
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ install:
- npm install

before_script:
- cp config/travis.exs config/test.exs
- mix do ecto.create, ecto.migrate

script:
Expand All @@ -53,10 +52,9 @@ notifications:
slack:
secure: 0wrGLWdpp9HLujCNNwJnPvmfQmK3phQXbUj/EZ/x/YROEp1TdaDzLnXI4Qo6JyZszmH+zFb3S58iiOUrX2oCJFhdUGz/tN8YSBQBdMDPhi602BfarK4dfOSsnMq60KYzEV+zkM3GQFXIl/UudeZ5AhEpEn4tF6HrjSYqMOAJkjv4REesdY/GLDVSFfNF/KfXhd1afsB5IA5O0VMERr247aCtnr9pbHuE6yqicZCuw0aU41e3zPRm8BVUIP1np5jRaGCJs7Vpx/5Q+SpdTjqdtgB05APvHveupDJrGV2uVH2iXScxHIP5SZOJbaaUxkIvjjrMN4IW3IiFDjxDuN6PAFZfJ3mpTowtDl96t4fgOfTM9a/EVv7OlPeQAVkOvHIdfsZ2PUpGV7+yWN1RssyiaYxcHdJ825on2jb+lj7lhsZmlGDfa/8GhkPQuKJr/msaXaposYDa42460hinn4UPHGrgO4AuGrXF9Cc7/xbGIdAkHogsswYy1X2XDf7aDR5yktgz/sQ1aHnvF9K1SzopDd1TS6YjLpgN0Y4kqWrUqWxHM6Ne1mTYLTREfbs+49+oPaq+n+HilFB0BAjCpwtwvKi+VhPgH5ZCSYL0hqiYpsUNL2Q3oWUHra1YlPIc/2QtIf6E1XtpqADRqnI/Ow8XkTgi4xWq2gKmHn5jEZhW9Ng=

after_success:
after_success:
- |
if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]];
then
.travis/deploy.sh
then
.travis/deploy.sh
fi
10 changes: 3 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ clean: ## Remove local files
rm -rf aion/node_modules

test: ## Run tests
cp aion/config/local_test.exs aion/config/test.exs
cd aion && mix test

lint: ## Run elixir linter
Expand Down Expand Up @@ -52,7 +51,7 @@ docker-stop: ## Stop docker container
## ~> LOCAL DEVELOPMENT PART <~ ##
##################################

development: local-config local-deps local-db start-dev
development: local-deps local-db start-dev
development: ## Setup and run the whole project

start-dev: ## Start the phoenix server
Expand All @@ -64,20 +63,17 @@ local-db: ## Create and migrate db locally
local-deps: ## Download all needed dependencies
cd aion && mix deps.get && npm install && cd web/elm && $(elm-package) install -y

local-config: ## Switch config file to the one containing settings for local use
cp aion/config/local_dev.exs aion/config/dev.exs
cp fixtures/src/local_config.py fixtures/src/config.py

##################################
## ~> DATABASE SEEDING PART <~ ##
##################################

populate-database: ## Seed database with fixtures prepared in fixtures/jpks/
populate-database: local-config
populate-database:
cd fixtures && python3 main.py

populate-rooms: ## Create a set of rooms aggregating all the questions present in the database
populate-rooms: local-config
populate-rooms:
cd fixtures && python3 main.py --rooms

##################################
Expand Down
9 changes: 9 additions & 0 deletions aion/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ config :guardian, Guardian,
ttl: {30, :days},
serializer: Aion.GuardianSerializer

# Configures DB access
config :aion, Aion.Repo,
adapter: Ecto.Adapters.Postgres,
username: "postgres",
password: "postgres",
database: "aion",
hostname: System.get_env("AION_DB_HOSTNAME") || "localhost",
pool_size: 10

# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env()}.exs"
10 changes: 0 additions & 10 deletions aion/config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,4 @@ config :aion, Aion.Endpoint,
]
]

config :logger, :console, format: "[$level] $message\n"

config :phoenix, :stacktrace_depth, 20

config :aion, Aion.Repo,
adapter: Ecto.Adapters.Postgres,
username: "postgres",
password: "postgres",
database: "aion",
hostname: "localhost",
pool_size: 10
43 changes: 0 additions & 43 deletions aion/config/docker_dev.exs

This file was deleted.

43 changes: 0 additions & 43 deletions aion/config/local_dev.exs

This file was deleted.

19 changes: 0 additions & 19 deletions aion/config/local_test.exs

This file was deleted.

7 changes: 0 additions & 7 deletions aion/config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ config :aion, Aion.Endpoint,
url: [host: "aion.mrapacz.pl", port: 8888],
cache_static_manifest: "priv/static/manifest.json"

config :aion, Aion.Repo,
adapter: Ecto.Adapters.Postgres,
username: "postgres",
password: "postgres",
database: "aion",
hostname: "localhost"

config :phoenix, :serve_endpoints, true

# Do not print debug messages in production
Expand Down
2 changes: 1 addition & 1 deletion aion/config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ config :logger, level: :warn
config :aion, Aion.Repo,
adapter: Ecto.Adapters.Postgres,
username: "postgres",
password: "postgres",
password: System.get_env("AION_TEST_DB_PASSWORD") || "postgres",
database: "aion_test",
hostname: "localhost",
pool: Ecto.Adapters.SQL.Sandbox
15 changes: 0 additions & 15 deletions aion/config/travis.exs

This file was deleted.

6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ services:
db:
image: postgres:9.6
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: password
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: aion
volumes:
- ./postgres-data:/var/lib/postgresql/data
Expand All @@ -14,6 +14,8 @@ services:
dockerfile: Dockerfile
depends_on:
- db
environment:
- AION_DB_HOSTNAME="db"
command: bash /scripts/run_server
volumes:
- ./aion/:/aion
Expand Down
5 changes: 3 additions & 2 deletions fixtures/src/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os

dbname = 'aion'
user = 'postgres'
password = 'postgres'
host = 'localhost'

host = os.environ.get('AION_DB_HOSTNAME', 'localhost')
4 changes: 0 additions & 4 deletions fixtures/src/docker_config.py

This file was deleted.

5 changes: 0 additions & 5 deletions fixtures/src/local_config.py

This file was deleted.

1 change: 0 additions & 1 deletion scripts/run_server
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
sleep 2
cp config/docker_dev.exs config/dev.exs
cp fixtures/src/docker_config.py fixtures/src/config.py
mix deps.get
mix ecto.migrate
Expand Down

0 comments on commit 678568c

Please sign in to comment.