Skip to content

Check the lockfile when installing dependencies in CI - #1912

Merged
polvalente merged 3 commits into
elixir-nx:mainfrom
blasphemetheus:ci/check-locked-deps
Nov 27, 2026
Merged

polvalente merged 3 commits into
elixir-nx:mainfrom
blasphemetheus:ci/check-locked-deps

Conversation

@blasphemetheus

Copy link
Copy Markdown
Contributor

Runs mix deps.get --check-locked on every CI job.

This branch is built on #1911, which removes the lockfile entry this check would otherwise fail on. Until that is merged, the diff here also shows its two lockfile lines.

Why

The workflow installs dependencies only when the deps cache is missing:

- name: Install dependencies
  if: ${{ steps.mix-cache.outputs.cache-hit != 'true' && env.should_run == 'true' }}
  run: mix deps.get

mix deps.get may rewrite mix.lock when it fetches. If it does, the job still passes and saves deps to the cache. The next job restores that cache, skips mix deps.get, and fails at compile time with a lock mismatch, on a commit that changed no dependency.

The change

- name: Install dependencies
  if: ${{ env.should_run == 'true' }}
  run: mix deps.get --check-locked
  • --check-locked makes mix deps.get fail when it would change the lockfile.
  • The step no longer depends on the cache, so a restored cache is checked against the lockfile too. With a warm cache it has nothing to fetch.

The same edit is made in the Linux and Windows jobs.

What it looks like when it catches something

On main today, without #1911, in exla/:

$ mix deps.get --check-locked
Upgraded:
  telemetry 1.4.2 => 1.4.3
** (Mix) Your mix.lock is out of date and must be updated without the --check-locked flag

With #1911 it passes in nx, exla and torchx.

🤖 Generated with Claude Code

blasphemetheus and others added 2 commits November 26, 2026 13:25
Both lockfiles still lock nx as the Hex package 0.13.1, while both projects
depend on nx by path. With that entry present, mix deps.get does not keep
telemetry at its locked version and fetches the newest release, so it
moved from 1.4.2 to 1.4.3 once 1.4.3 was published. CI caches deps under
the hash of the committed lockfile and skips mix deps.get on a cache hit,
so the run after a cache miss fails with a lock mismatch.

Without the entry, mix deps.get keeps telemetry at 1.4.2.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
mix deps.get ran only when the deps cache was missing, and could rewrite
mix.lock without failing. A lockfile that no longer matched what gets
fetched went unnoticed until a later run restored the cache and failed
with a lock mismatch.

It now runs on every job with --check-locked, so a fetch that would
change the lockfile fails on the run that introduces it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@blasphemetheus

blasphemetheus commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor Author

a candidate fix to make the current CI messup not happen in the future

Comment thread .github/workflows/ci.yml
Comment on lines -111 to +112
if: ${{ steps.mix-cache.outputs.cache-hit != 'true' && env.should_run == 'true' }}
run: mix deps.get
if: ${{ env.should_run == 'true' }}
run: mix deps.get --check-locked

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep the cache checks. If the lock changes, the cache is invalidated anyway

The lockfile is part of the cache key, so a changed lock already
invalidates the cache. Only the --check-locked flag stays.

Co-authored-by: Paulo Valente <polvalente@users.noreply.github.com>
@polvalente
polvalente merged commit ba84f51 into elixir-nx:main Nov 27, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants