← Back to issue list

fix global environment expansion

View original Github issue

Metadata

Project
rockcraft
Number
#336
Type
pull request
State
merged
Author
cjdcordeiro
Labels
—
Created
Updated
Closed

Current evaluation

PR #336 (commit 42627c1a) by cjdcordeiro merged, fixing missing global variable expansion so CRAFT_PROJECT_VERSION and other CRAFT_ vars are set before parts lifecycle; project loading now returns YAML for unmarshal.

Resolution: closed resolved

Reason: The PR was merged into main as commit 42627c1a ("project: global environment expansion (#336)"), resolving issue #333. jnsgruk confirmed locally it fixes #333 and cmatsuoka approved, noting the workaround should be revisited when rebasing on craft-application.

Evaluated by: mr-cal-bot

No scores available.

Issue body

- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? ----- Fixes https://github.com/canonical/rockcraft/issues/333 In this PR: - fix the global variable expansion which was not being called and thus resulting in `CRAFT_` variables not being set before running the parts' lifecycle steps - refactor the project loading so that it returns a YAML instead of the project itself. The latter can still be retrieved by explicitly calling the `unmarshal` function - adjust the unit tests accordingly - add `CRAFT_PROJECT_VERSION` to a spread test **NOTE:** Although it works, I feel there might be a better way to handle this, by fiddling with the callbacks and `ProjectInfo` directly in the craft-parts module. Why can't the variable expansion be handled by the craft-parts, implicitly? I.e. the `PartsLifecycle` already takes `project_vars` as an argument, so it doesn't need access to the whole YAML

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved PR #336 (commit 42627c1a) by cjdcordeiro merged, fixing missing global variable expansion so CRAFT_PROJECT_VERSION and other CRAFT_ vars are set before parts lifecycle; project loading now returns YAML for unmarshal.
stealth/space-bunny-alpha — closed resolved PR #336 by cjdcordeiro merged as commit 42627c1a, fixing global env expansion so CRAFT_ variables (incl. CRAFT_PROJECT_VERSION) are set before parts lifecycle runs; refactored project loading to return YAML. Closes #333.
stealth/space-bunny-alpha — closed resolved Merged canonical/rockcraft#336 (42627c1a), fixing global variable expansion so CRAFT_PROJECT_VERSION and other CRAFT_ variables are set before parts lifecycle steps.
qwen/qwen3.6-35b-a3b — — Merged fix for global environment expansion preventing CRAFT_ variable setup before parts lifecycle. Updates tests, adds CRAFT_PROJECT_VERSION to spread tests, and resolves issue #333 after local verification and approval.
qwen3.6-35b-a3b-mtp-q6 — — Merged fix for global environment expansion preventing CRAFT_ variables from setting before parts lifecycle steps. Refactored project loading to return YAML. Resolves #333 after local verification, with future craft-application refactoring planned.

Update history

No update history recorded yet.

Related work

  • Duplicate Of: canonical/rockcraft#333 (confidence 95%)

    Issue #333 (CRAFT_PROJECT_VERSION not registered) is the bug this PR fixes and was closed by it.

Related issues

Issue Project State Summary Similarity
#226 environment: expand global variables craft-parts merged Merged #226, adding expansion of global environment variables in parts values for CRAFT-1073 in commit 5b5fbdc5 (merge f8738e42).
79%
#333 global environment not being registered for CRAFT_PROJECT_VERSION rockcraft closed Fixed by merged PR #336 (commit 42627c1a), which registers global project variables, including CRAFT_PROJECT_VERSION, before lifecycle steps.
76%
#4757 fix: set project variables for core24 snapcraft merged Merged #4757 as commit 27957515c, fixing core24 project-variable expansion and closing #4704/#4702; CRAFT_* setup was linked to canonical/craft-application#320.
74%
#4741 fix(env): set global environment variables for craft-app snapcraft closed Closed unmerged in favor of #4757, which added core24 project-variable expansion in commit 27957515c.
74%
#299 Add project env vars like CRAFT_PROJECT_VERSION rockcraft closed CRAFT_PROJECT_VERSION integration coverage was added and #299 was closed; no resolving PR or commit was identified in available history.
72%
#320 Set the project environment in the Lifecycle Service craft-application open Project-aware environment expansion from #101 is now in place, and current integration coverage verifies CRAFT_PROJECT_NAME and CRAFT_PROJECT_VERSION are exported during builds; the omission is resolved.
72%
#757 Export important project variables snapcraft merged Merged PR #757 (commit dc0b68174) exports SNAPCRAFT_PROJECT_NAME, SNAPCRAFT_PROJECT_VERSION, SNAPCRAFT_PROJECT_STAGE and per-part SNAPCRAFT_PART_INSTALL, refactoring _expand_env into the project loader so variables work in fixed yaml fields. LP #1588336.
70%