Skip to content

Instantly share code, notes, and snippets.

@paulgoetze
Last active July 30, 2018 03:33
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save paulgoetze/b9116605a9471598e79eaca34253f979 to your computer and use it in GitHub Desktop.
Save paulgoetze/b9116605a9471598e79eaca34253f979 to your computer and use it in GitHub Desktop.
Codeship Elixir/Phoenix test setup
#!/bin/bash
# Erlang
ERLANG_VERSION=${ERLANG_VERSION:-20.2}
ERLANG_CACHED_DOWNLOAD="${HOME}/cache/OTP-${ERLANG_VERSION}.tar.gz"
ERLANG_DIR=${ERLANG_DIR:="$HOME/erlang"}
# Elixir
ELIXIR_VERSION=${ELIXIR_VERSION:-1.6.3}
ELIXIR_CACHED_DOWNLOAD="${HOME}/cache/elixir-v${ELIXIR_VERSION}.zip"
ELIXIR_DIR=${ELIXIR_DIR:="$HOME/elixir"}
# Erlang download
echo Installing Erlang version ${ERLANG_VERSION}
wget --continue --output-document "${ERLANG_CACHED_DOWNLOAD}" "https://s3.amazonaws.com/heroku-buildpack-elixir/erlang/cedar-14/OTP-${ERLANG_VERSION}.tar.gz"
mkdir "${ERLANG_DIR}"
tar -xaf "${ERLANG_CACHED_DOWNLOAD}" --strip-components=1 --directory "${ERLANG_DIR}"
${ERLANG_DIR}/Install -minimal ${ERLANG_DIR}
export PATH="${ERLANG_DIR}/bin:$PATH"
# Elixir download
echo Installing Erlang version ${ELIXIR_VERSION}
wget --continue --output-document "${ELIXIR_CACHED_DOWNLOAD}" "https://github.com/elixir-lang/elixir/releases/download/v${ELIXIR_VERSION}/Precompiled.zip"
mkdir ${ELIXIR_DIR}
cd ${ELIXIR_DIR}
unzip -q ${ELIXIR_CACHED_DOWNLOAD}
export PATH="${ELIXIR_DIR}/bin:$PATH"
cd -
# copy the sample file to the actual test config
cp config/sample.test.exs config/test.exs
export MIX_ENV=test
mix local.hex --force
mix local.rebar --force
mix hex.info
mix deps.get
mix deps.compile
mix ecto.create
# in test settings:
# $ mix test
@tieubao
Copy link

tieubao commented Jul 7, 2016

I faced an issue with test setting. It didn't recognize my "mix" command. Any ideas?

@nburkley
Copy link

@paulgoetze, I set my enviroment (export MIX_ENV=test) before running any of the mix commands (i.e. moving it to line 33) as it was trying fire up the dev environment when running mix

@williamweckl
Copy link

williamweckl commented Mar 5, 2017

Anyone else is getting this error?

** (Mix.Config.LoadError) could not load config ../../config/config.exs
** (File.Error) could not read file "../../config/config.exs": no such file or directory
(elixir) lib/file.ex:244: File.read!/1
(mix) lib/mix/config.ex:180: Mix.Config.read!/2
(mix) lib/mix/tasks/loadconfig.ex:36: Mix.Tasks.Loadconfig.load/1
(mix) lib/mix/tasks/loadconfig.ex:27: Mix.Tasks.Loadconfig.run/1
(mix) lib/mix/task.ex:294: Mix.Task.run_task/3
(mix) lib/mix/cli.ex:57: Mix.CLI.run_task/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment