Merge branch 'add_make_test' into 'master'

Add make test command

See merge request framasoft/mobilizon!116
This commit is contained in:
Thomas Citharel 2019-04-18 10:48:21 +02:00
commit d87b8c989f
9 changed files with 64 additions and 41 deletions

19
.dockerignore Normal file
View File

@ -0,0 +1,19 @@
_build
CONTRIBUTING.md
deps
docker-compose.yml
Dockerfile
.elixir_ls
.formatter.exs
.git
.gitignore
.gitlab
.gitlab-ci.yml
.graphqlconfig.yaml
LICENSE
Makefile
README.md
SECURITY.md
ssh_match_hostname
support
.js/package-lock.json

View File

@ -1,6 +1,6 @@
FROM elixir:1.7
FROM bitwalker/alpine-elixir:latest
RUN apt-get update && apt-get install -y build-essential inotify-tools postgresql-client
RUN apk add inotify-tools postgresql-client yarn
RUN mix local.hex --force && mix local.rebar --force

View File

@ -10,5 +10,12 @@ stop:
@bash docker/message.sh "stopping MobiliZon"
docker-compose down
@bash docker/message.sh "stopped"
test: stop
@bash docker/message.sh "Building front"
docker-compose -f docker-compose.yml -f docker-compose.test.yml run front yarn run build
@bash docker/message.sh "Front built"
@bash docker/message.sh "Running tests"
docker-compose -f docker-compose.yml -f docker-compose.test.yml run api mix test
@bash docker/message.sh "Tests runned"
target: init

18
docker-compose.test.yml Normal file
View File

@ -0,0 +1,18 @@
version: '3'
services:
postgres:
restart: "no"
environment:
POSTGRES_DB: mobilizon_test
front:
restart: "no"
api:
restart: "no"
environment:
MIX_ENV: "test"
MOBILIZON_DATABASE_DBNAME: mobilizon_test
command: "mix test"
volumes:
pgdata:
.:

View File

@ -1,7 +1,6 @@
version: '3'
services:
postgres:
container_name: mobilizon_db
restart: unless-stopped
@ -9,16 +8,19 @@ services:
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: mobilizon_dev
volumes:
- pgdata:/var/lib/postgresql/data
front:
container_name: mobilizon_front
restart: unless-stopped
build: ./js
volumes:
- './js:/app/js'
- '.:/app'
ports:
- "8888:8080"
entrypoint: entrypoint
command: yarn run dev
api:
container_name: mobilizon_api
@ -30,10 +32,9 @@ services:
- "4000:4001"
depends_on:
- postgres
- front
environment:
# Environment: Prod when ready
MIX_ENV: dev
# Instance
MIX_ENV: "dev"
MOBILIZON_INSTANCE_NAME: My Mobilizon Instance
MOBILIZON_INSTANCE_HOST: mobilizon.me
MOBILIZON_INSTANCE_EMAIL: noreply@mobilizon.me
@ -42,4 +43,7 @@ services:
MOBILIZON_DATABASE_USERNAME: postgres
MOBILIZON_DATABASE_DBNAME: mobilizon_dev
MOBILIZON_DATABASE_HOST: postgres
entrypoint: entrypoint
command: "mix phx.migrate_serve"
volumes:
pgdata:
.:

View File

@ -1,22 +0,0 @@
#!/bin/bash
mix deps.get
# Wait for Postgres to become available.
until PGPASSWORD=$MOBILIZON_DATABASE_PASSWORD psql -h $MOBILIZON_DATABASE_HOST -U $MOBILIZON_DATABASE_USERNAME -c '\q' 2>/dev/null; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
echo "\nPostgres is available: continuing with database setup..."
# Potentially Set up the database
mix ecto.create
mix ecto.migrate
echo "\nTesting the installation..."
# "Proove" that install was successful by running the tests
mix test
echo "\n Launching Phoenix web server..."
iex -S mix phx.server

View File

@ -2,7 +2,8 @@ FROM node:10
LABEL maintainer="tcit"
COPY docker/entrypoint.sh /bin/entrypoint
RUN yarn install
RUN yarn upgrade node-sass
WORKDIR /app/js

View File

@ -1,5 +0,0 @@
#!/bin/bash
yan install
yarn rebuild node-sass
yarn run dev

View File

@ -7,7 +7,7 @@ defmodule Mobilizon.Mixfile do
[
app: :mobilizon,
version: @version,
elixir: "~> 1.4",
elixir: "~> 1.8",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
start_permanent: Mix.env() == :prod,
@ -116,7 +116,8 @@ defmodule Mobilizon.Mixfile do
[
"ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
"ecto.reset": ["ecto.drop", "ecto.setup"],
test: ["ecto.create --quiet", "ecto.migrate", "test"]
test: ["ecto.create --quiet", "ecto.migrate", "test"],
"phx.migrate_serve": ["ecto.create --quiet", "ecto.migrate", "phx.server"]
]
end