Skip to content

[stack] Take a pinned version without resolving it - #1

Closed
benlangfeld wants to merge 1 commit into
only-parse-files-that-can-declare-a-backendfrom
exact-version-fast-path
Closed

benlangfeld wants to merge 1 commit into
only-parse-files-that-can-declare-a-backendfrom
exact-version-fast-path

Conversation

@benlangfeld

Copy link
Copy Markdown
Owner

Review view for dflook/terraform-github-actions#446, showing only its own changes.

GitHub requires a pull request's base branch to exist in the base repository, so a fork's PR cannot be based on another of that fork's branches. Upstream, dflook#446 is therefore opened against main and its diff includes #444, which it builds on.

This PR is the same head branch based on the dflook#444 branch, so the diff here is the increment alone — 4 files, +255, no changes to terraform/module.py or terraform_backend/.

Not for merging. It exists so the incremental change can be read and commented on; discussion belongs on dflook#446. It closes itself once dflook#444 merges upstream and dflook#446 is rebased, at which point the upstream diff becomes this one.

determine_version fetches the release index as its first statement and loads the
module a few lines later, both before anything has looked at what the version
actually needs. When the version is pinned exactly there is nothing to resolve,
and loading the module means parsing every file in it.

Decide it from what can be read cheaply instead. Only files mentioning
required_version, backend or cloud can say whether the version is pinned, so
parsing those answers it - on a real 245 file module that is 1.7s rather than
32s, and the release index is not fetched at all.

The order sources are considered in is unchanged, which is what the gating is
for. A remote or cloud backend means the workspace version outranks the pin, so
the shortcut is skipped and the usual resolution runs. An exact required_version
otherwise wins, as it already would. Only when the module requires nothing does
the environment get a say, and then only if no version file is present, since
those outrank it too.

Constraints are untouched - a range still needs the available versions, so it
still fetches them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant