Skip to content

Latest commit

 

History

History
116 lines (102 loc) · 3.16 KB

language-elixir_5bdc647204286356f0a56048.md

File metadata and controls

116 lines (102 loc) · 3.16 KB

This guide covers configuring Elixir projects on Semaphore. If you’re new to Semaphore please read our Guided tour first.

Supported Elixir versions

Semaphore uses kiex to manage Elixir versions. Any version installable with kiex is supported on Semaphore. Version 1.7 is pre-installed. 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

Dependency caching

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-deps-$(checksum mix.lock)
            - cache restore mix-build-$(checksum mix.lock)
            - mix do deps.get, compile
            - cache store mix-deps-$(checksum mix.lock) deps
            - cache store mix-build-$(checksum mix.lock) _build
  - name: Tests
    task:
      env_vars:
        - name: MIX_ENV
          value: test
      prologue:
        commands:
          - checkout
          # Restore dependencies and compiled code
          - cache restore mix-deps-$(checksum mix.lock)
          - cache restore mix-build-$(checksum mix.lock)
      jobs:
        - name: Everything
          commands:
            - mix test

Environment variables

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

System dependencies

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