Wercker configuration for Phoenix
# Obtained and modified from:
# https://engineering.appcues.com/2015/12/21/elixir-wercker.html}
# PROJECT_DIR added because in our github projects we have an intermediate folder
box: grvtylabs/phoenix:1.2.1
build:
services:
- id: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
steps:
- script:
name: Set envs and get versions
code: |
export MIX_ENV=test
export LOGS_PATH=/pipeline/source/$PROJECT_DIR/wercker-logs
export ERL_CRASH_DUMP=$LOGS_PATH/erl_crash.dump
bash -c "echo 'Node version: $(node -v)'"
bash -c "echo 'NPM version: $(npm -v)'"
bash -c "echo 'Elixir version: $(elixir -v)'"
bash -c "echo 'Phoenix version: $(mix phoenix.new -v)'"
mkdir -p $LOGS_PATH
touch $LOGS_PATH/erl_crash.dump
- script:
name: Elixir Dependencies Get
cwd: /pipeline/source/$PROJECT_DIR
code: |
elixir --erl '-smp disable' /usr/local/bin/mix deps.get >> $LOGS_PATH/depsget.txt 2>&1
- script:
name: Elixir Dependencies Compile
cwd: /pipeline/source/$PROJECT_DIR
code: |
elixir --erl '-smp disable' /usr/local/bin/mix deps.compile >> $LOGS_PATH/depscompile.txt 2>&1
- script:
name: Compile Project
cwd: /pipeline/source/$PROJECT_DIR
code: |
elixir --erl '-smp disable' /usr/local/bin/mix compile --long-compilation-threshold 60 >> $LOGS_PATH/compile.txt 2>&1
- script:
name: Database Test
cwd: /pipeline/source/$PROJECT_DIR
code: |
env
# while ! nc -q 1 $POSTGRES_PORT_5432_TCP_ADDR $POSTGRES_PORT_5432_TCP_PORT </dev/null; do sleep 3; done
elixir --erl '-smp disable' /usr/local/bin/mix do ecto.create, ecto.setup, ecto.migrate >> $LOGS_PATH/database.txt 2>&1
- script:
name: Project Tests
cwd: /pipeline/source/$PROJECT_DIR
code: |
mix test --trace >> $LOGS_PATH/test.txt 2>&1
after-steps:
- script:
name: Crash export
code: |
export LOGS_PATH=/pipeline/source/$PROJECT_DIR/wercker-logs
export ERL_CRASH_DUMP=$LOGS_PATH/erl_crash.dump
echo ""
echo "===================================================="
echo "ERL_CRASH.DUMP"
cat $ERL_CRASH_DUMP
echo ""
echo "===================================================="
echo "DEPENDENCIES - GET"
cat $LOGS_PATH/depsget.txt
echo ""
echo "===================================================="
echo "DEPENDENCIES - COMPILE"
cat $LOGS_PATH/depscompile.txt
echo ""
echo "===================================================="
echo "COMPILE"
cat $LOGS_PATH/compile.txt
echo ""
echo "===================================================="
echo "DATABASE"
cat $LOGS_PATH/database.txt
echo ""
echo "===================================================="
echo "TESTS"
cat $LOGS_PATH/test.txt
- wercker/slack-notifier@1.3.0: # Organization vars
url: $SLACK_URL
channel: $SLACK_CHANNEL
icon_url: $SLACK_ICON
username: $SLACK_USER
deploy:
steps:
- script:
name: set env vars
code: |
export MIX_ENV=prod
after-steps:
- wercker/slack-notifier@1.3.0: # Organization vars
url: $SLACK_URL
channel: $SLACK_CHANNEL
icon_url: $SLACK_ICON
username: $SLACK_USER