This guide covers configuring Elixir projects on Semaphore. If you’re new to Semaphore please read our Guided tour first.
- Hello world
- Phoenix example project
- Supported Elixir versions
- Dependency caching
- Environment variables
- System dependencies
# .semaphore/semaphore.yml version: v1.0 name: Hello Semaphore agent: machine: type: e1-standard-2 os_image: ubuntu1804 blocks: - name: Elixir example task: jobs: - name: Run some code commands: - elixir 'IO.puts "Hello world!"'
Phoenix example project
Semaphore provides a tutorial and demo Phoenix application with a working CI pipeline that you can use to get started quickly:
Supported Elixir versions
Semaphore supports all versions of Elixir. You have the following options:
- Linux: Elixir is available out-of-the-box in the Ubuntu 18.04 VM image.
- Docker: use semaphoreci/elixir or your own Docker image with the version of Elixir and other packages that you need.
Follow the links above for details on currently available language versions and additional tools.
Selecting an Elixir version on Linux
Semaphore uses kiex to manage Elixir versions. Any version installable with kiex is supported on Semaphore. You may install new versions and change them with
sem-version. Here's an example:
blocks: - name: Tests task: prologue: commands: - kiex install 1.6 - sem-version elixir 1.6 jobs: - name: Tests commands: - elixir --version
You can use Semaphores
cache command to store and load the build and dependency cache. In the following configuration example, we install dependencies and warm the cache in the first block, then use the cache in subsequent blocks.
version: v1.0 name: Elixir & Phoenix Example agent: machine: type: e1-standard-2 os_image: ubuntu1804 blocks: - name: Install dependencies task: env_vars: - name: MIX_ENV value: test jobs: - name: mix and cache commands: - checkout # Be sure to use --force to skip confirmation prompts - mix local.hex --force - mix local.rebar --force - cache restore - mix do deps.get, compile - cache store - name: Tests task: env_vars: - name: MIX_ENV value: test prologue: commands: - checkout # Restore dependencies and compiled code - cache restore jobs: - name: Everything commands: - mix test
Semaphore doesn't set language specific environment variables like
MIX_ENV. You can set these at the task level.
blocks: - name: Tests task: env_vars: - name: MIX_ENV value: test jobs: - name: Everything commands: - mix test
Projects may need system packages things like database drivers. You have full
sudo access so you may install required packages. Here's an example of installing the Postgres dependencies.
blocks: - name: Tests task: prologue: commands: - sudo apt-get update && sudo apt-get install -y libpq-dev - mix install jobs: - name: Everything commands: - mix test