Add support for Elixir/Erlang


#21

Thanks @levlaz. Agreed with @DavidAntaramian. First class Elixir support starts with first class support for Erlang. I’ve completely given up on installing Erlang 19 on CircleCI and I’m waiting for CircleCI to provide a solution. Specifying erlang_otp: 18.3 or 19.0.2 would be great. I don’t know what the default Erlang version should be at this time.

Defaulting to the latest stable version of Elixir if none is specified sounds good. Again, it should be possible to specify a version in the machine configuration. Inference can be based on the existence of a mix.exs file in the root of the repository under test.

The default for getting dependencies for Elixir should be along these lines:

dependencies:
  cache_directories:
    - deps
    - _build
  override:
    - mix local.hex --force
    - mix local.rebar --force
    - mix deps.get
    - mix deps.compile

As far as running tests, I would prefer the default be the following, though I can’t speak for the Elixir community as a whole.

test:
  override:
    - MIX_ENV=test mix do compile --warnings-as-errors, test

Alternatively, just mix test.

There should be no need to run migrations for a properly configured Ecto or Phoenix app as the aliases configuration in the mix.exs file should cause test to do that.

"test": ["ecto.create --quiet", "ecto.migrate", "test"]

Thanks again. Really looking forward to Elixir support from Circle.


#22

@nathany Good point on aliases. I forgot about that.


#23

I just generated a Phoenix 1.2.1 app to check the aliases but unfortunately it doesn’t alias test in the manner described here: https://github.com/phoenixframework/phoenix/issues/1564#issuecomment-194957150.

I will find or open an issue in Phoenix, because I think that’s a better solution than specifying additional commands in CI.

UPDATE: https://github.com/phoenixframework/phoenix/issues/1864 Tests will create and migrate the database with apps generated from the next release of Phoenix (already fixed on master).


#24

This is why you shouldn’t ignore warnings in Elixir.

isCrazyMurderingRobot = false
if isCrazyMurderingRobot = true do
  IO.puts("kill humans")
else
  IO.puts("be nice to humans")
end

kill humans
warning: variable isCrazyMurderingRobot is unused

http://elixirplayground.com/?gist=328a07ad396eb01beec6048c3babde11

Avoid the Robot Apocalypse. Implement MIX_ENV=test mix do compile --warnings-as-errors, test today.


#25

It may be nice to support Dialyzer (static type checker) out-of-the-box too.

The first time you use Dialyxir, or each time that you upgrade your Erlang or Elixir version you will need to rebuild the PLT.

mix dialyzer.plt


#26

+1 for Erlang/Elixir


#27

+1 for Elixir/Erlang and Phoenix support.


#28

+1 for Erlang/Elixir


#29

+1 for Erlang support


#30

+1 for Erlang/Elixir support


#31

Still no support? Just being able to declare which elixir and erlang versions we’d like would be immensely helpful.

dependencies:
  cache_directories:
    - ~/.asdf
    - deps
    - _build
    - /opt/circleci/nodejs/v4.2.6/lib/node_modules/aglio
    - /opt/circleci/nodejs/v4.2.6/bin/aglio
  pre:
    - if ! asdf | grep version; then git clone https://github.com/asdf-vm/asdf.git ~/.asdf; fi
    - asdf plugin-add erlang https://github.com/asdf-vm/asdf-erlang.git || true
    - asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git || true
    - asdf install
    - mix local.hex --force
    - mix local.rebar --force
    - if [ ! -e /opt/circleci/nodejs/v4.2.6/bin/aglio ]; then npm install -g aglio; else echo "Aglio seems to be cached"; fi;
  override:
    - mix do deps.get, compile

If we got this guy in, we would be able to trim this down to:

machine:
  elixir: 1.4.2
  erlang: 19.2

dependencies:
  cache_directories:
    - /opt/circleci/nodejs/v4.2.6/lib/node_modules/aglio
    - /opt/circleci/nodejs/v4.2.6/bin/aglio
  pre:
    - if [ ! -e /opt/circleci/nodejs/v4.2.6/bin/aglio ]; then npm install -g aglio; else echo "Aglio seems to be cached"; fi;

#32

Thanks for your patience everyone. Some good news: CircleCI 2.0 (currently in Beta) has support for Elixir.

We’ve published a sample application and getting started guide: https://circleci.com/docs/2.0/language-elixir/

If you try this with 2.0 and have questions, please ask here: https://discuss.circleci.com/c/circleci-2-0/support


#33