Phoenix continuous integration with Bitbucket Pipelines

My laboratory for making potions with Elixir…

I recently started a project for a customer. It’s a Mobile app with API and Back-end.

I select Phoenix (Elixir) for this.

I’m searching on-line some documentation for C.I and C.D. and I finally decided to go with Bitbucket Pipelines for Continuous Integration.

Exactly what I’m doing is:

  • Using Git-flow for Version Control
  • Using Gitkraken for visualizing the branches
  • Using Bitbucket for Hosting repositories and C.I. with pipelines

Next step is to deploy the develop branch in a staging site (Heroku? Gigalixir?) and then when we are ready to go in production create another pipeline for the master branch.

With this configuration I can leave the text.exs as is in the project created by mix phx.new:

image: bitwalker/alpine-elixir:1.5.2
pipelines:
  default:
    - step:
      script:
        - MIX_ENV=test mix local.hex --force
        - MIX_ENV=test mix deps.get
        - MIX_ENV=test mix local.rebar --force
        - MIX_ENV=test mix ecto.create
        - MIX_ENV=test mix ecto.migrate
        - mix test
      services:
        - postgres
definitions:
  services:
    postgres:
      image: postgres
      environment:
        POSTGRES_DB: golfcoupons_test
        POSTGRES_USER: postgres
        POSTGRES_PASSWORD: postgres

I would like to thank @pentacent for his article Automating Elixir Tests — Continuous Integration with Bitbucket Pipelines that bootstrap me in the right direction, but I put some optimization specific for phoenix projects.