Skip to content

Fix cache key in nx-integration-tests using undefined inputs.ref#379

Merged
rhoerr merged 1 commit into
mage-os:mainfrom
thebraziliandeveloper:fix/nx-integration-tests-cache-key
May 27, 2026
Merged

Fix cache key in nx-integration-tests using undefined inputs.ref#379
rhoerr merged 1 commit into
mage-os:mainfrom
thebraziliandeveloper:fix/nx-integration-tests-cache-key

Conversation

@thebraziliandeveloper
Copy link
Copy Markdown
Contributor

@thebraziliandeveloper thebraziliandeveloper commented May 27, 2026

Summary

The integration-tests job in nx-integration-tests.yml restores the project cache with:

key: ${{ runner.os }}-project-${{ inputs.ref }}

But inputs.ref is not a defined input for this workflow — the declared inputs are repository, pr_head, and pr_base. The expression resolves to an empty string on every run, producing the cache key Linux-project-, which never matches the entry saved by the nx-project-setup job (which correctly uses inputs.pr_head as the ref throughout).

Effect: guaranteed cache miss on any fresh PR run. The ./main directory is empty when the integration-tests job starts, the PHPUnit bootstrap falls back to running setup:install against a tmp-mysql container that was never initialised, and the entire suite crashes at bootstrap before a single test executes. The failure looks like a code or infrastructure problem but is purely a missing cache hit.

This explains why integration tests pass when a warm cache happens to be present on the runner (the key Linux-project- accidentally matches a stale entry) but fail consistently on new or retargeted PRs.

Fix

Replace inputs.ref with inputs.pr_head, consistent with every other place in this workflow that references the head SHA.

Test plan

  • Open a fresh PR against mageos-magento2 — integration-tests job should now find the cache saved by nx-project-setup and proceed past bootstrap

The integration-tests job restored the project cache with:

  key: ${{ runner.os }}-project-${{ inputs.ref }}

But `inputs.ref` is not a defined input for this workflow — the
declared inputs are `repository`, `pr_head`, and `pr_base`. The
expression resolved to an empty string, producing the key
`Linux-project-` on every run, which never matched the entry saved
by the nx-project-setup job (which used `inputs.pr_head` as the
ref throughout).

The result was a guaranteed cache miss on any fresh PR run: the
`./main` directory was empty when the integration-tests job started,
the PHPUnit bootstrap fell back to running `setup:install` against
a `tmp-mysql` container that had never been initialised, and the
entire suite crashed at bootstrap before a single test executed.

Fix: replace `inputs.ref` with `inputs.pr_head`, consistent with
every other place in this workflow that references the head SHA.
Copy link
Copy Markdown
Contributor

@rhoerr rhoerr left a comment

Choose a reason for hiding this comment

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

@rhoerr rhoerr merged commit c36b58f into mage-os:main May 27, 2026
1 check 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