Running Sobelow in a bitbucket pipeline

I’m trying to wire up Sobelow checks in a bitbucket pipeline.

    - step:
        name: Backend | Quality Check
        script:
          - mix format --check-formatted
          - mix credo --strict
          - mix ecto.create
          - mix ecto.migrate
          - mix test --exclude acceptance --exclude skip_ci
          - mix sobelow -r apps/storefront_web --exit Low
          - mix sobelow -r apps/data_layer  --exit Low

The above mix commands for sobelow work locally but the pipeline fails at this step with this error:

+ mix sobelow -r apps/storefront_web --exit Low
** (Mix) The task "sobelow" could not be found

Has anyone been able to setup Sobelow checks in a pipeline?

1 Like

Do you have sobelow in your dependencies and are you installing them (mix deps.get) before this step?

Here’s an example of a pipeline running sobelow on GitHub Actions.

Yeah there is a backend build step that looks like this:

 - step:
        name: Backend | Build
        script:
          - mix deps.get
          - mix compile
        caches:
          - elixir-build
          - elixir-deps
        artifacts:
          - deps/**

Sobelow is in the mix.exs file (of the umbrella application, it’s not in any of the applications themselves).

Oh I think the issue may be that the docker-compose.release.yml has the environment set to MIX_ENV: prod and Sobelow is installed only: :dev. It seems like the best work around here is to remove only: :dev and add runtime: false to the dependency? I’m not sure if there would be any harm in having Sobelow installed in production but I’d rather that than change the pipeline’s environment.

Since that series of commands under “Backend | Quality Check” does a mix ecto.create, I’m guessing that MIX_ENV is not prod there - likely it’s test.

You could broaden the dependency to only: [:dev, :test] to ensure this works.

1 Like