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
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
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









