itopiz

itopiz

Why does running `mix ecto.create` trigger a new compilation?

In the process of setting up a Gitlab CI pipeline, I noticed something that I don’t understand.

My .gitlab-ci.yml looks like this:

variables:
  POSTGRES_HOST: "postgres"
  POSTGRES_DB: "postgres"
  POSTGRES_USER: "postgres"
  POSTGRES_PASSWORD: "postgres"
  MIX_ENV: "test"
  
stages:
  - build
  - test

default:
  image: elixir:1.9
  before_script:
    - mix local.hex --force
    - mix local.rebar --force

compile:
  stage: build
  script:
    - apt-get update
    - apt-get install -y postgresql-client
    - mix deps.get --only test
    - mix compile --warnings-as-errors
  artifacts:
    paths:
      - _build
      - deps
    expire_in: 1 week

lint:
  stage: test
  script:
    - mix format --check-formatted

test:
  stage: test
  services:
    - postgres:10.10
  script:
    - mix event_store.setup
    - mix ecto.create
    - mix ecto.migrate
    - mix test

Since jobs are run independently from each other, I save the compilation artifacts from the compile job to avoid recompiling in the next jobs. However, when the test job runs the mix ecto.create command, a compilation is triggered again. Why? Did not the compile job compile everything needed when running mix compile --warnings-as-errors?

Marked As Solved

NobbZ

NobbZ

I’ve never checked for that. I always explicitely define dependencies, to make sure to have the artifacts I want.

Anyway, mix does solely rely on the files timestamps when deciding wether or not a file/dependency needs recompilation.

The artifacts might be extracted and carry the original date, while git on a checkout always sets current time as cdate.

This is an assumption though. I usually do not care for rebuilding such stuff on subsequent stages (in elixir), as I have to recompile anyway for different environments…

You might try to recursively touch all artifacts, alternatively some mix tasks allow --no-compile or something like that, you might be able to play with that.

Last Post!

itopiz

itopiz

Ok, that explains why a new compilation happens. Thank you

Where Next?

Popular in Questions Top

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44778 311
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement