Elixir

2 minute read

Versions and setup

Elixir is not installed on CloudBees CodeShip Basic by default, but it can be easily added with this script.

Elixir requires Erlang so you will want to set up your desired Erlang version first:

wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb sudo dpkg -i erlang-solutions_2.0_all.deb sudo apt-get update sudo apt-get install -y erlang=1:25.0.4-1

Optionally you can check the installed version:

erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), "releases", erlang:system_info(otp_release), "OTP_VERSION"])), erlang:display(erlang:binary_to_list(Version)), halt().' -noshell

Next for Elixir itself, set the desired version as an environment variable in your project or add it in the Setup Commands along with the install script:

export ELIXIR_VERSION=1.13.4 source /dev/stdin <<< "$(curl -sSL https://raw.githubusercontent.com/codeship/scripts/master/languages/elixir.sh)"

Dependencies

Installing dependencies with hex is supported once Elixir is installed, as per the instructions above.

Dependency Cache

Elixir dependencies are not automatically cached, but you can do additional steps to make use of the cache.

Frameworks And Testing

Elixir frameworks such as Phoenix, and test tools such as ExUnit, are all supported on CodeShip. Note that you will need to manually install all tools needed, in your project’s setup commands.

Parallel Testing

If you are running parallel test pipelines, you will want to separate your tests into groups and call a group specifically in each pipeline. For instance:

Pipeline 1:

mix test tests/tests_1.exs

Pipeline 2:

mix test tests/tests_2.exs

Parallelization Modules

In addition to parallelizing your tests explicitly via parallel pipelines, some customers have found using ExUnit’s built-in test parallelization is a good way to speed up your tests.

Note that aggressive parallelization can cause resource and build failure issues.

Notes And Known Issues

Due to Elixir version and build issues, you may find it helpful to test your commands with different versions via an SSH debug session if tests are running differently on CodeShip compared to your local machine.